Register multiple models to show in admin page

2010-03-09 Thread andrew_scfc
Hi,

I'm new to using Django and have come across some redundancy in my
implementation that I would like to irradicate.

I have defined several models in the models.py file as normal. I would
like to register all of my models to be available via the admin
interface. Currently I need to register models one by one in the
admin.py as show below:

from mysite.models import model1, model2, model3, model4, model5
from django.contrib import admin

admin.site.register(model1)
admin.site.register(model2)
admin.site.register(model3)
admin.site.register(model4)
admin.site.register(model5)


Is it possible to just register all models? Perhaps get hold of a
collection containing all the models. I am quite new to python so I
may have missed something quite simple, if so, I apologise.

Cheers
Andy

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Re: Register multiple models to show in admin page

2010-03-09 Thread rebus_
On 9 March 2010 10:31, andrew_scfc  wrote:
> Hi,
>
> I'm new to using Django and have come across some redundancy in my
> implementation that I would like to irradicate.
>
> I have defined several models in the models.py file as normal. I would
> like to register all of my models to be available via the admin
> interface. Currently I need to register models one by one in the
> admin.py as show below:
>
> from mysite.models import model1, model2, model3, model4, model5
> from django.contrib import admin
>
> admin.site.register(model1)
> admin.site.register(model2)
> admin.site.register(model3)
> admin.site.register(model4)
> admin.site.register(model5)
>
>
> Is it possible to just register all models? Perhaps get hold of a
> collection containing all the models. I am quite new to python so I
> may have missed something quite simple, if so, I apologise.
>
> Cheers
> Andy
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

models = [model1, model2, model3, model4, model5]
admin.site.register(models)

This should work i think.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.