4👍
✅
I’d do something along these lines:
MyProject/
|- films/
|- __init__.py
|- urls.py
|- models/
|- __init__.py
|- genre.py
|- actor.py
|- title.py
|- actorrole.py //M2M through with actors and their roles in specific titles
|- admin/
|- __init__.py
|- genre.py
|- actor.py
|- title.py
|- views/
|- __init__.py
|- someview.py
|- myproject/
|- __init__.py
|- urls.py
|- wsgi.py
|- settings/
|- __init__.py
|- production.py
|- staging.py
|- local.py
3 or 4 models isn’t so many that I would spread this into several apps. BUT for organization, keep your models and admin classes in separate files and import them in the folder’s __init__.py
s
important notes:
in your model make sure you include app_name in the inner Meta class.
class Genre(models.Model):
...
class Meta:
app_label = _(u'films') #app's name
...
make sure that any FKs are passed as strings not as classes (helps avoid cyclic dependencies)
title = models.ForeignKey("films.Title")
in your films/models/__init__.py
import in the proper order so as not to have cyclic deps.
from films.models.genre import Genre
from films.models.actor import Actor
from films.models.title import Title
from films.models.actorrole import ActorRole
in your films/admin/__init__.py
register each of your admin classes
from django.contrib import admin
from lottery.models import Genre, Actor, Title
from lottery.admin.actor import ActorAdmin
admin.site.register(Actor, ActorAdmin)
...
Source:stackexchange.com