[Django] #32167: 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?

29 views
Skip to first unread message

Django

unread,
Nov 3, 2020, 5:19:45 AM11/3/20
to django-...@googlegroups.com
#32167: 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?
----------------------------------------+------------------------
Reporter: zencore-cn | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------
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

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32167>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 3, 2020, 5:22:43 AM11/3/20
to django-...@googlegroups.com
#32167: 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?
------------------------------+--------------------------------------

Reporter: zencore-cn | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by zencore-cn):

* Attachment "test001.zip" added.

Example code, and the screen shot of error page.

Django

unread,
Nov 4, 2020, 12:22:09 AM11/4/20
to django-...@googlegroups.com
#32167: 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?
------------------------------+--------------------------------------
Reporter: zencore-cn | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: 2.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/32167#comment:1>

Reply all
Reply to author
Forward
0 new messages