For the record, there is a plan to refactor the concept of 'app' completely,
granted any recent development on that front seems to be mostly restricted
to discussions in django-developers. I believe the proposed changes draw
from the way the admin encapsulates itself in an App class.

https://github.com/django/django/tree/soc2010%2Fapp-loading
http://groups.google.com/group/django-developers/search?&q=app+loading


Cheers,
André

On Fri, Jul 8, 2011 at 11:58 AM, Tom Evans <tevans...@googlemail.com> wrote:

> On Fri, Jul 8, 2011 at 3:43 PM, Thomas Denmark <mrve...@gmail.com> wrote:
> > Thanks Tom. So I have now read about AdminSite.
> >
> > It seems like they have encapsulated an application into a class. It
> > is the first time I see this. And to use the application, one must
> > instantiate the class. To have several instances, you just instantiate
> > several. That seems kind of straight forward.
> >
> > But it leaves me with more questions.
> >
> > 1) Is there a recipe for encapsulating an application as a class? I
> > can see that the AdminSite has no super class. And I did not find much
> > with googling.
> >
> > 2) All the Django documentation, that I have read has only dealt with
> > building applications like folders with a few files: models.py,
> > views.py and urls.py. That is what happens, when one writes 'admin.py
> > startapp foo'. Is it possible to make several instances of such an
> > application?
> >
> > Thomas
> >
> >
>
> It's really to do with the URL namespace, and nothing to do with
> classes, that is just how the admin is encapsulated.
>
> If you have a project called 'foo' then you might include it's URLs like
> so:
>
>  urlpatterns = patterns(....
>     (r'^foo/', include('foo.urls')),
>  )
>
> If you wanted to include a second instance of it, you would do this:
>
>  urlpatterns = patterns(....
>     (r'^foo/', include('foo.urls'), app_name='foo'),
>     (r'^bar/', include('foo.urls'), namespace='bar', app_name='foo'),
>  )
>
> So now you have two instances of 'foo' installed. When reversing
> 'foo:some_named_url', Django will look at the current app - if it is
> 'bar', the URLs will resolve to the 'bar' instance. The key thing here
> is that the templates are the same, and Django DTRT when working out
> which urlconf to use.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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

Reply via email to