Such as
Urlpatterns = [
URL (r ' ^xadmin/', ([
URL (r ' ^add/$ ', Views.add)
URL (r ' ^delete/$ ', views.delete)
], None,none)),
This completes the first level distribution
Then make a self-designed URL
Need 3 sheets, additions and deletions, 12 URLs
Such as
127.0.0.1:8000/xadmin/app01/add/
127.0.0.1:8000/xadmin/app01/delete/
Edit in urls.py
def list_view (Request):
Return HttpResponse (' Userindex ')
def add_view (Request):
Return HttpResponse (' User_add ')
def change_view (request, ID):
Return HttpResponse (' User_change ')
def delete_view (request, ID):
Return HttpResponse (' User_delete ')
Def has_urls ():
temp = []
Temp.append (URL (r ' ^$ ', List_view))
Temp.append (URL (r ' ^add/$ ', Add_view))
Temp.append (url (r ' ^ (\d+)/change/$ ', Change_view))
Temp.append (url (r ' ^ (\d+)/delete/$ ', Delete_view))
Print (temp)
Return Temp
Def get_urls ():
Print (Admin.site._registry)
temp = []
For Model,admin_class_obj in Admin.site._registry.items ():
App_name = Model._meta.app_label
Model_name = Model._meta.model_name
Print (App_name,model_name)
Temp.append (URL (r ' ^{0}/{1}/'. Format (app_name,model_name), (Has_urls (), None,none)),)
Return Temp
Urlpatterns = [
Path (' admin/', admin.site.urls),
URL (r ' ^xadmin/', (Get_urls (), None,none)),]
settings.py
Set up
Installed_apps = [
' App01.apps.App01Config ',
' App02.apps.App02Config ',
]
admin.py under the APP01 project
From Django.contrib Import admin
From APP01 import Models
# Register your models here.
Admin.site.register (models. Book)
Admin.site.register (models. Publish)
models.py under the APP01 project
admin.py under the APP02 project
From Django.contrib Import admin
From APP02 import Models
# Register your models here.
Admin.site.register (models. Order)
models.py under the APP01 project
From django.db import Models
Class Order (models. Model):
title = models. Charfield (MAX_LENGTH=32)
def __str__ (self):
Return Self.title
Design URL Xadmin_demo by distribution