Ideally your Django project would contain many different applications,
which in turn have their own models.py module. I've yet to work on a
project large enough to warrant that i try this, so what I'm about to say
is completely untested... but I would think that creating a 'models'
directory inside of an app (instead of models.py), creating+populating
various .py modules that will constitute your model classes, and then
creating an __init__.py that imports the previously created model classes
would work. Something like:

project/
    app1/
        models/
            __init__.py (would import classes from models1.py and
models2.py)
            models1.py
            models2.py
    app2/
        models.py

As for your second question, I tend to try my best to keep my views slim,
and let my models grow as they need too (containing all the business
logic). I can't speak for others, but when my views start getting too large
it's usually a sign to me that something could be designed better, but
large and complex models are common on my end.

Hope this helps,
Jonathan


On Thu, Jul 25, 2013 at 4:03 PM, Ivan Voras <ivo...@gmail.com> wrote:

> Thanks!
>
> While I have a newbie thread going, let me ask you one more thing: I like
> the concepts behind Django models, but what are the best practices for
> organizing models into files for large-ish scale projects? Keeping all
> model classes in a single models.py file is not scalable, and I'd rather
> have a file-per-class situation, at least for some of them. The reason for
> this is that I suspect the models will grow functionalities encapsulating
> more complex behaviour than simple database operations.
>
> Or is the best practice to keep models simple - basically a database
> schema description - and create new, more complex classes containing
> specific code?
>
>
>
> On Thursday, 25 July 2013 23:36:49 UTC+2, jondbaker wrote:
>
>> Hi Ivan, and welcome. Django >= 1.5 features custom User models, which I
>> believe would solve your problem: https://docs.**
>> djangoproject.com/en/dev/**topics/auth/customizing/#**
>> specifying-a-custom-user-model<https://docs.djangoproject.com/en/dev/topics/auth/customizing/#specifying-a-custom-user-model>
>>
>>
>> On Thu, Jul 25, 2013 at 3:25 PM, Ivan Voras <ivo...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I'm new to Django, and still finding out how it all fits together. I've
>>> seen django.contrib.auth and I'm wondering - is it a common practice to
>>> actually use it as a basis for application authentication?
>>>
>>> If so, I have a question: the username field as defined (30 characters)
>>> is too short for me. Is there an easy way to override the default field
>>> size?
>>>
>>> What I'm actually trying to do is this: I'm thinking of using e-mail
>>> addresses for user names, with the "username" field holding a lowercase
>>> address (to make use of the unique index) and the "email" field will store
>>> the address as entered by the user. The default length of the "email" field
>>> is good enough (75) but the "username" field is too short.
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users<http://groups.google.com/group/django-users>
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> Jonathan D. Baker
>> Developer
>> http://jonathandbaker.com
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Jonathan D. Baker
Developer
http://jonathandbaker.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to