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
|
||||
.vscode
|
||||
/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.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
|
||||
'rest_framework',
|
||||
'Generator'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@@ -75,9 +79,12 @@ WSGI_APPLICATION = 'kivi_cars.wsgi.application'
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
}
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'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
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.urls.conf import include
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('generator/', include("Generator.urls")),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user