Django URLS & Seperate View Files

11 views
Skip to first unread message

katuricharles

unread,
Jan 20, 2016, 10:37:32 AM1/20/16
to Zimbabwe Python Users Group
I have spend the better part of the day trying to wrap my finger around using seperate url.py and seperate views in a website. I have a django website that has several applications. In each application there is a urls.py specific to that app in which I want to organise its related URLs. As for the views  I have put them in seperate files in a folder called views.
The problem is if i define a url from the main urls.py, the view is displaying, but when i move the url to the app specific url file I am getting a name error. I have checked the urls and they are in the correct format.

Does anyone have experience with this sort of thing?

Anna Makarudze

unread,
Jan 20, 2016, 2:04:36 PM1/20/16
to katuricharles, Zimbabwe Python Users Group
Each of the app should have its own views.py within the app folder not in a seperate folder called views. Make sure each of your app has its own urls.py, views.py, admin.py and models.py. In other words, each app should be self contained. You only need to include urls from each of your app in your root urls.py. That way you will not face those name errors.

Hope that helps. 

--
You received this message because you are subscribed to the Google Groups "Zimbabwe Python Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zimpy+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/zimpy.
To view this discussion on the web, visit https://groups.google.com/d/msgid/zimpy/0acf2674-27ab-46c2-b430-df0e7d3a4573%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages