Django urls.py reload (not from database)

267 views
Skip to first unread message

Thomas

unread,
Jun 23, 2016, 11:46:40 AM6/23/16
to Django users
Hy django lovers,

it's my first post for being helped, sorry if I miss something.

I want two list of urls available :
  • one (limited) before initializing (verify licence, etc...)
  • one (large) after initializing success

Here is my settings.ROOT_URLCONF :

from constance import config

if not config.L7V_INITIALIZATED:
    urlpatterns
= [
        url
(r'^admin/', admin.site.urls),
        url
(r'^initialization/', include('apps.initialization.urls'), name='initialization'),
   
]
else:
    urlpatterns
= [
        url
(r'^admin/', admin.site.urls),
        url
(r'^dashboard/', include('apps.dashboard.urls')),
        url
(r'^vmAPI/', include('apps.vmAPI.urls')),
        url
(r'^protobook/', include('apps.protobook.urls')),
   
]

config.L7V_INITIALIZATED is just a boolean updated if initialization has been success.

So, in my initialization view, I set the boolean to True and need to reload settings.ROOT_URLCONF to understand the new list of urlpatterns.

I saw a snippet but doesn't work under django 1.9 (says working under django 1.4) :

import sys
from django.conf import settings

def reload_urlconf(urlconf=None):
   
if urlconf is None:
        urlconf
= settings.ROOT_URLCONF
   
if urlconf in sys.modules:
       
reload(sys.modules[urlconf])

I also tried the method '
django.core.urlresolvers.set_urlconf' but doesn't works......

Any suggestions ?

Thanks a lot !

Thomas

Luis Zárate

unread,
Jun 23, 2016, 4:47:38 PM6/23/16
to django...@googlegroups.com
so if not
config.L7V_INITIALIZATED


I raise a 404 exception.  

No need to reload urls.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2ac2ea9e-55eb-479f-9e30-271aeece1c26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
"La utopía sirve para caminar" Fernando Birri


Reply all
Reply to author
Forward
0 new messages