File tree Expand file tree Collapse file tree 8 files changed +51
-1
lines changed
Expand file tree Collapse file tree 8 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 1+ from django .contrib import admin
2+
3+ # Register your models here.
Original file line number Diff line number Diff line change 1+ from django .apps import AppConfig
2+
3+
4+ class App1Config (AppConfig ):
5+ default_auto_field = "django.db.models.BigAutoField"
6+ name = "app1"
Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 1+ from django .test import TestCase
2+
3+ # Create your tests here.
Original file line number Diff line number Diff line change 1+ from django .shortcuts import render
2+
3+ # Create your views here.
Original file line number Diff line number Diff line change 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
4248MIDDLEWARE = [
121127# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
122128
123129DEFAULT_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+ }
Original file line number Diff line number Diff line change 1414 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515"""
1616from 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
1920urlpatterns = [
2021 path ("admin/" , admin .site .urls ),
22+ path ('' , include ('django_dyn_api.urls' )),
23+ path ('login/jwt/' , view = obtain_auth_token ),
2124]
You can’t perform that action at this time.
0 commit comments