Merge branch 'hexa_generator' into 'main'
Add hexa id generator See merge request saburly/marketalarm/kivi-za-auta!8
This commit was merged in pull request #8.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ db.sqlite3
|
|||||||
venv
|
venv
|
||||||
.vscode
|
.vscode
|
||||||
/media
|
/media
|
||||||
|
settings.py
|
||||||
|
|||||||
0
kivi_cars/Generator/__init__.py
Normal file
0
kivi_cars/Generator/__init__.py
Normal file
3
kivi_cars/Generator/admin.py
Normal file
3
kivi_cars/Generator/admin.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
6
kivi_cars/Generator/apps.py
Normal file
6
kivi_cars/Generator/apps.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class GeneratorConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'Generator'
|
||||||
0
kivi_cars/Generator/migrations/__init__.py
Normal file
0
kivi_cars/Generator/migrations/__init__.py
Normal file
3
kivi_cars/Generator/models.py
Normal file
3
kivi_cars/Generator/models.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
3
kivi_cars/Generator/tests.py
Normal file
3
kivi_cars/Generator/tests.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
6
kivi_cars/Generator/urls.py
Normal file
6
kivi_cars/Generator/urls.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from django.urls import path
|
||||||
|
from Generator import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', views.HexaGenerator)
|
||||||
|
]
|
||||||
12
kivi_cars/Generator/views.py
Normal file
12
kivi_cars/Generator/views.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from rest_framework.decorators import api_view
|
||||||
|
from rest_framework.response import Response
|
||||||
|
import secrets
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
|
||||||
|
@api_view(['GET'])
|
||||||
|
def HexaGenerator(request):
|
||||||
|
if request.method == 'GET':
|
||||||
|
hexa_id = secrets.token_hex(16)
|
||||||
|
return Response({"message": "Search id:", "data": hexa_id})
|
||||||
|
|
||||||
@@ -37,6 +37,10 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
|
||||||
|
|
||||||
|
'rest_framework',
|
||||||
|
'Generator'
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@@ -75,8 +79,11 @@ WSGI_APPLICATION = 'kivi_cars.wsgi.application'
|
|||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
'NAME': 'kivi_cars',
|
||||||
|
'USER': 'postgres',
|
||||||
|
'HOST': 'localhost',
|
||||||
|
'PASSWORD': 'b18'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,11 @@ Including another URLconf
|
|||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
|
from django.urls.conf import include
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('generator/', include("Generator.urls")),
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user