Opened 4 years ago
Closed 4 years ago
#32167 closed Bug (invalid)
app.ready() is called after models ready, but the site's urlpatterns are not parsed yet, so how to add code after the whole site is ready?
Reported by: | zencore-cn | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 2.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
app.ready() is called after models ready, but the site's urlpatterns are not parsed yet, so how to add code after the whole site is ready, so that we can update models and reverse urls?
from django.apps import AppConfig from django.urls import reverse class Test002Config(AppConfig): name = 'test002' def ready(self): try: url = reverse("admin:auth__user__changelist") print(url) # reverse raise errors except Exception as error: pass # the admin site broken even we try...catch.. here # the admin site can login, but got error in admin index page
Attachments (1)
Change History (2)
by , 4 years ago
Attachment: | test001.zip added |
---|
comment:1 by , 4 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Please don't use Trac as a support channel. Also, there is a typo in your example, it should be admin:auth_user_changelist
.
Closing per TicketClosingReasons/UseSupportChannels.
Note:
See TracTickets
for help on using tickets.
Example code, and the screen shot of error page.