Django: Dynamically add apps as plugin, building urls and other settings automatically

后端 未结 5 1348
慢半拍i
慢半拍i 2021-01-03 01:29

I have following structure of my folders in Django:

./project_root
    ./app
       ./fixtures/
       ./static/
       ./templates/
       ./blog/
       ./         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 02:10

    Have you tried something like:

    for app in INSTALLED_APPS:
    
        # You'll want to check that you can import the urls of that app here
    
        urlpatterns += patterns('',
            url(r'^%s/' % app, include('%s.urls' % app) )
        )
    

提交回复
热议问题