[Answer]-Inherit/Extend Django Module or cram into same Module?

1👍

I would consider a folder structure like this:

myproject
-> task
----> models
--------> __init__.py
--------> base.py
--------> math.py
--------> etc.
----> views
--------> __init__.py
--------> math.py
--------> etc.
----> urls
--------> __init__.py
--------> etc.
-> check
----> models
--------> __init__.py
--------> base.py
--------> etc.

-etc.- (you get the idea)

This way, you’ll divide your Django project in three separate apps, and you’ll divide each apps’ models, views, forms, etc. into separate files.

To import a specific model, view, form etc. you’ll just do:

from task.models.math import MathTask
from task.views.image import ImageView
etc.

This is how you’ll make the abstract base models:

class BaseTask(models.Model):
    # your fields goes here

    class Meta:
        abstract = True

Leave a comment