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)

test001.zip (67.1 KB ) - added by zencore-cn 4 years ago.
Example code, and the screen shot of error page.

Download all attachments as: .zip

Change History (2)

by zencore-cn, 4 years ago

Attachment: test001.zip added

Example code, and the screen shot of error page.

comment:1 by Mariusz Felisiak, 4 years ago

Resolution: invalid
Status: newclosed

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.
Back to Top