philosophy behind sites and applications in Django

32 views
Skip to first unread message

Jojo

unread,
Mar 25, 2012, 8:21:32 PM3/25/12
to django...@googlegroups.com
Hi guys, I'm new in Django (I started with the 1.3 and now I'm playing with the 1.4) and I'd like to understand better the phylosophy behind the concepts of sites and applications.
Ok a site can contain multiple applications and an application can live in many sites, that's simple.

Now.

For me a site is like a "container" of applications and every application accomplish a particular job just like manage polls, articles and so on. But a site must have its own graphic style, and in particular common parts, just like user management.

How do you handle these "trasversal" (common) components?
For example, is it possible to define a css at site level? How to deal with user management and other commont funcionalities?

These are only generic questions, I hope someone can give me a full explanation, or at least point me in the right direction.

Thank you to everybody and good work!

Mario Gudelj

unread,
Mar 26, 2012, 12:11:03 AM3/26/12
to django...@googlegroups.com

The easiest thing to do is to create each site as a separate project. Define a base template for that project inside templates directory and link your css in that template. Extend that template in all your other templates. Same goes for users.  Each project/site will have it's own db and its users.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/xM3TUeVaOA4J.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reinout van Rees

unread,
Mar 26, 2012, 8:09:51 AM3/26/12
to django...@googlegroups.com
On 26-03-12 02:21, Jojo wrote:
> Hi guys, I'm new in Django (I started with the 1.3 and now I'm playing
> with the 1.4) and I'd like to understand better the phylosophy behind
> the concepts of sites and applications.
> Ok a site can contain multiple applications and an application can live
> in many sites, that's simple.
>
> Now.
>
> For me a site is like a "container" of applications and every
> application accomplish a particular job just like manage polls, articles
> and so on. But a site must have its own graphic style, and in particular
> common parts, just like user management.
>
> How do you handle these "trasversal" (common) components?
> For example, is it possible to define a css at site level? How to deal
> with user management and other commont funcionalities?

You're right, a site is a container of applications and an application
should do one thing and one thing only.

Normally, you don't want your site to contain applications and at the
same time have those applications inherit from your site's main template
or so.


But... django sticks all the templates/ and static/ directories of all
apps and sites together. So nothing stops you from sticking a very basic
base template in every app ("yourapp/templates/base.html") with just a
sidebar and main content block or so. You can have your apps use that.

In your site, you provide the real "yoursite/templates/base.html", which
will win because your site is higher up in the INSTALLED_APPS list.
Stuff that one full with the real layout and css, but keep providing the
sidebar and content block (or whatever you need).


Alternative: just make templates in the apps and customize them in the
site. Not as nice imho.


ALternative: start a base UI app that just provides a layout. Use that
in the apps.

Reinout

--
Reinout van Rees http://reinout.vanrees.org/
rei...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

Reply all
Reply to author
Forward
0 new messages