Skip to content

Commit b888b37

Browse files
committed
Integrate Dynamic API Module
1 parent a4965eb commit b888b37

File tree

8 files changed

+51
-1
lines changed

8 files changed

+51
-1
lines changed

app1/__init__.py

Whitespace-only changes.

app1/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

app1/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class App1Config(AppConfig):
5+
default_auto_field = "django.db.models.BigAutoField"
6+
name = "app1"

app1/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from django.db import models
2+
3+
# Create your models here.
4+
5+
class Book(models.Model):
6+
7+
title = models.CharField(max_length=100)
8+
info = models.CharField(max_length=100, default='')
9+
10+
class Cities(models.Model):
11+
12+
name = models.CharField(max_length=100)

app1/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

app1/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.

core/settings.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
"django.contrib.sessions",
3838
"django.contrib.messages",
3939
"django.contrib.staticfiles",
40+
41+
"app1",
42+
43+
'django_dyn_api', # Django Dynamic API # <-- NEW
44+
'rest_framework', # Include DRF # <-- NEW
45+
'rest_framework.authtoken', # Include DRF Auth # <-- NEW
4046
]
4147

4248
MIDDLEWARE = [
@@ -121,3 +127,17 @@
121127
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
122128

123129
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
130+
131+
DYNAMIC_API = {
132+
# pattern:
133+
# API_SLUG -> Import_PATH
134+
'books' : "app1.models.Book",
135+
'cities' : "app1.models.Cities",
136+
}
137+
138+
REST_FRAMEWORK = {
139+
'DEFAULT_AUTHENTICATION_CLASSES': [
140+
'rest_framework.authentication.SessionAuthentication',
141+
'rest_framework.authentication.TokenAuthentication',
142+
],
143+
}

core/urls.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515
"""
1616
from django.contrib import admin
17-
from django.urls import path
17+
from django.urls import path, include
18+
from rest_framework.authtoken.views import obtain_auth_token
1819

1920
urlpatterns = [
2021
path("admin/", admin.site.urls),
22+
path('', include('django_dyn_api.urls')),
23+
path('login/jwt/', view=obtain_auth_token),
2124
]

0 commit comments

Comments
 (0)