Yes, But when my models.py/admin.py reach to +2000 line then django
standard way not gonna help. That's why i seperate the classes into files
and pkgs.
I'm wonder is there any performance issue on this approach, since each
class is in separate file, when i import them i'm sure python should find
them at the filesystem and initial them or they will be initialized by
django ?


On Wed, Jun 27, 2012 at 6:28 PM, Daniel Roseman <dan...@roseman.org.uk>wrote:

> On Wednesday, 27 June 2012 08:54:07 UTC+1, Alireza Savand wrote:
>>
>> Hi
>> Common way to create [model|admin] classes is implement and create them
>> in [models|admin].py file.
>> But as standard non-django way is to create a python package named admin
>> for AdminClass es and  create a file for each admin class.
>> But i couldn't find any standard way to register those admin classes, i
>> mean should i register them in admin/__init__.py or register each class in
>> it own file then import them at admin/__init__.py ?
>> Sometimes when i register all of them at admin/__init__.py it's happening
>> that classes will initialed multiple times and i don't know the reason.
>> I'm just looking for common or standard way to do it.
>>
>> Thanks.
>>
>
> There is absolutely a standard way to do this, which is fully documented.
>
> Define all your ModelAdmin classes in an admin.py inside each app.
> Register the classes in that file (usually together at the end). In your
> main urls.py, call `admin.autodiscover()`, which imports all the admin.py
> files which causes them to be registered.
>
> If you do anything else, you may well run into multiple registration
> problems. Don't. Follow the standard.
> --
> DR.
>
> --
> 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/-/h2g8jTwkmrAJ.
>
> 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