python - How to get the link of a table in the admin page -


for example admin/appname/mytable

i need link of tables put in navbar, how can ?

my urls.py

url(r'^admin/', admin.site.urls), 

i want this

  url(r'^admin/myapp/mytable', ..... name="..."), 

but django says need put view

i think need django interospection,

before adding admin need table name. , register each table admin.py

so try this, list entire table presented in django app.

>>> django.db import connection >>> tables = connection.introspection.table_names()  >>> len(tables) # length of entire table defined db 101 >>> avail_table = connection.introspection.installed_models(tables) >>>tbl_list = [i._meta.model.__name__ in avail_table] >>> len(tbl_list) # length of available/based on usage tables 77 >>> in avail_table: >>>    "admin.site.register({})".format(i._meta.model.__name__) 

you need register model before use... try above script print this, admin.site.register(yourmodel)

paste in admin.py

then try work...


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -