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:
Ismail Šošić
2022-05-09 07:55:30 +00:00
11 changed files with 46 additions and 3 deletions

1
.gitignore vendored
View File

@@ -7,3 +7,4 @@ db.sqlite3
venv
.vscode
/media
settings.py

View File

View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class GeneratorConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Generator'

View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@@ -0,0 +1,6 @@
from django.urls import path
from Generator import views
urlpatterns = [
path('', views.HexaGenerator)
]

View 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})

View File

@@ -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'
}
}

View File

@@ -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")),
]