Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7866429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:24:00+00:00 2026-06-03T00:24:00+00:00

I was reading over the following code, and the models were structured such that

  • 0

I was reading over the following code, and the models were structured such that each class/model had a separate file and then it was imported in __init__.py. For example:

# __init__.py
from service            import Service
from note               import Note
etc...

# service.py (one example of the imports)
from django.db import models

class Service(models.Model):

    #: service provider name (e.g. Hulu)
    name                = models.CharField(max_length=64, verbose_name="Title Name", unique=True)

    def __unicode__(self):
        return u'Service id=%s, name=%s' % (self.pk, self.name)

Which way is better practice, to have all models in one models.py file, or to have one file-per model? I usually keep all my models for an app in one file, and I had never seen the models separated, which is why I’m asking this question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:24:01+00:00Added an answer on June 3, 2026 at 12:24 am

    Best practice is to put them in one file. Look at the django source for example.

    The reason you’ve never seen it is because it’s practically never done.

    If you can justify it somehow then by all means do it, but it’s definitely not the recommended structure. People start to explore splitting models when the file gets too large / can be logically separated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following is the code that I'm using for reading data over a .NET socket.
I have been reading over some code lately and came across some lines such
When I'm reading the C++ standard, it seems that the following code is perfectly
After reading about dynamic class loading (that is, loading a .class file from disk)
I've been reading over the internet about a partial method that I can use
I am using the following code to load my flash file, contact a php
So I went over this block of code several times in a book that
Love this website! My issue is as follows: I'm reading a zip file that's
I wrote the following code under MacOSX in XCode. When moving the code over
Based on my reading, the following code: string aggregate = give + 'n'; Should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.