I am thinking about how to split my website into smaller reusable apps. I've finally figured out something and need your opinion.

My main problem was that each app uses Profile model. This is of course a snippet of my work with the most important parts.

# App Userdata
class BaseProfile(models.Model):
    city = models.CharField(max_length=100, null=True, blank=True)
    user = models.OneToOneField(User)

class Photo(models.Model):
    profile = models.ForeignKey(BaseProfile)
    url = models.URLField()

# App Social Connect
class SocialConnectProfile(models.Model):

class SocialConnect(models.Model):
    profile = models.ForeignKey(SocialConnectProfile)

# App Forum
class ForumProfile(models.Model):

class Question(models.Model):
    profile = models.ForeignKey(ForumProfile)

class Answer(models.Model):
    profile = models.ForeignKey(ForumProfile)
    question = models.ForeignKey(ForumProfile)

# App Base
class Profile(BaseProfile, SocialConnectProfile, ForumProfile):

What I am worrying about is that there are 5 tables with a one-to-one relationship. What do you think? Are there any better options?

Yes, the code has been pretty much simplified. Each app has many models indeed. (BaseProfile has 8, SocialConnect only 1, Forum 18)

My target is to extract them as Python-Django components in future, but I haven't done it before.

I want to project them in this way now to save time in future with new applications or extending existing one, but I am not sure if it's the best approach.

  • \$\begingroup\$ Why don't you just use BaseProfile? None of your other classes seem to add anything. \$\endgroup\$ Oct 14, 2013 at 1:00
  • \$\begingroup\$ @WinstonEwert I would guess the specifics of the other models have been removed for clarity. \$\endgroup\$ Oct 14, 2013 at 2:02
  • 2
    \$\begingroup\$ @JamesKhoury, perhaps. In that case I think the problem has been simplified past the point of being able to evaluate possible solutions. \$\endgroup\$ Oct 14, 2013 at 2:15

1 Answer 1


It depends really on how you will use those models. For example if you always, always get question object then find the answers that belong to it. there is no point adding profile relation with answers models and keep it to questions only.

If in rare cases (not in loops) you might deal with an answer without getting its question object first, its still ok to do answer.question.profile


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.