Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Jan. 13, 2011 12:45:49

Олег К.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

model best practice


hello. My models.py file became very big and actually I can divide that
app for 2-3 different apps. But the problem is that almost all models
are related to one model which is common and will be in different app.
Is it still a good idea to divide into different apps and make import
from external app?

Thankssignature.ascDescription:OpenPGP digital signature

Attachments:
attachment signature.asc (262 bytes)

Offline

#2 Jan. 13, 2011 13:21:15

Marc A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

model best practice


On Thu, Jan 13, 2011 at 1:45 PM, Олег Корсак
<kamikaze.is.waiting....@gmail.com> wrote:
>
> hello. My models.py file became very big and actually I can divide that
> app for 2-3 different apps. But the problem is that almost all models
> are related to one model which is common and will be in different app.
> Is it still a good idea to divide into different apps and make import
> from external app?
>
> Thanks
>


I'm not an expert, but I think that you should not be afraid to split
the project into multiple apps. My project also have a common model
and I put it into a dedicated app called 'common' :)

--
Marc

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 13, 2011 13:23:25

Mike D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

model best practice


On 13/01/2011, at 11:45 PM, Олег Корсак<kamikaze.is.waiting....@gmail.com>
wrote:

> hello. My models.py file became very big and actually I can divide that
> app for 2-3 different apps. But the problem is that almost all models
> are related to one model which is common and will be in different app.
> Is it still a good idea to divide into different apps and make import
> from external app?

Yes.

As soon as you can logically split stuff (functionally or into apps if you
prefer) you should do it purely for the sake of reducing complexity.

If your project is on the python path then you can import the app modules
(models) which are common.

Remember you are programming in python and just using Django libraries.

>
> Thanks
>

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Jan. 13, 2011 13:23:30

Thomas W.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

model best practice


I`ve asked for almost the exact same thing some time ago, but the
answer was that normal python knowledge regarding modules and packages
should help you organize your project.

For example, instead of having several models in one models.py file,
you can create a folder in your app-folder called models, put each
model in a seperate <modelname>.py-file, put a __init__.py in the
folder which imports all your model-files ( and probably remove the
old models.py). Then you can still do from appname.models import *,
but the files containing your model are smaller and easier to
navigate.

Don`t know it it helps you much.I still would like to see more
documentation and examples on how to manage big project with large
models.

Regards,
Thomas

On Thu, Jan 13, 2011 at 1:45 PM, Олег Корсак
<kamikaze.is.waiting....@gmail.com> wrote:
> hello. My models.py file became very big and actually I can divide that
> app for 2-3 different apps. But the problem is that almost all models
> are related to one model which is common and will be in different app.
> Is it still a good idea to divide into different apps and make import
> from external app?
>
> Thanks
>
>



--
Mvh/Best regards,
Thomas Weholthttp://www.weholt.org--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#5 Jan. 14, 2011 00:44:56

S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

model best practice


Alternatively, you can just split your models module into a package
containing multiple models. You'll just need to manually set the app_name on
the Meta class of each app, since isn't automagically set for classes
defined outside of the models module.

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 15th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support