Re: Django Project Structure for mixins - best solution?
76 views
Skip to first unread message
Message has been deleted
Mike Dewhirst
unread,
Jun 1, 2016, 7:42:43 PM6/1/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
On 2/06/2016 12:54 AM, sevenr...@gmail.com wrote:
> I seen multiple project structure for Django, but they didn't discuss in
> detail about structuring mixins.
>
> I see that some people use mixins.py , others utils folder.
>
> Taking in consideration that I have many mixins for views(generic
> login,authorization and more specific for the project) and for models
> and I don't know if using only 1 file mixins.py is the best solutions.
>
> So, I'm looking for recommendations, from projects with many mixins
> (views and models) ?
What works for me may not work for you. Just organise things the way you
feel comfortable. The bottom line is that if you use mixins they have to
be imported into the module where they are used.
That means ...
from overthere.mixins import thismixin
If you share mixins across a number of apps in the same project make an
extra app called "common" and make a directory mixins so ...
from common.mixins import thismixin
If you want to keep view and model mixins separate then ...
from common.views.mixins import thismixin
or
from app.views.mixins import thismixin
or
from . import thisviewmixin
from . import thismodelmixin
And so on. Make up a structure which suits your brain productivity-wise
so you don't have to think about where you are importing from and you
can go straight there without thinking when you want to edit them.