views:

526

answers:

3

Hello, I haven't exactly found the answer to this, maybe there is no best one. Django docs are not clear on this thing.

I'm not sure what is a good practice to set up a django project. Sure I have re-usable apps. But I always need some glue-code.

I find myself always creating "core" app for each project, which usually serves homepape.

Then in project url config I do something like this:

(r'^/$', include(core.urls))

Is this the way to go? Or do you have a better idea?

+1  A: 

Hello,

I think it's a good idea to use a glue app/module that also contains further helper functions/reusable code (if any), however I'm not sure if that's the way the other djangonauts do these kind of stuff.

Also, in order to match the homepage I think that the correct regexp is r'^$'. With the above solution you propose, you'll have to be careful because every url defined in core.urls will be 'mounted' under your site's root directory.

Also, and for the case of the homepage I used something like this

(r'^$', 'apps.core.views.homepage')

just to distinguish this url. I guess it's just a matter of how one wants things organized.

Andrew Brown
+1  A: 

Don't put the slash and the dollar. This is how I did it.

(r'^', include('core.urls')),

You're already on the right track. ;)

jpartogi
+1  A: 

The approach you mention is a good one. I tend to stash away stuff like that into a views.py file in the root of the project. There is already a urls.py in the root folder.

ayaz