[Answered ]-Could there be any issues naming a Django model "Model"?

1πŸ‘

βœ…

It is not a problem naming a class Model as long as that Model is not used as super class for other models. Indeed, one can define a:

from django.db import models

class Model(models.Model):
    # …

class WrongOtherModel(Model):
    # …

class CorrectOtherModel(models.Model):
    # …

Here the WrongOtherModel will inherit from the Model class defined in the file, which is likely not what we want to do: only if you want to use the defined Model as supercass, you use Model as superclass. If you want to define another model, you can do this by inheriting from models.Model.

That being said, I would advise not to name a model Model, since it makes it more likely that such mistakes will happen, but perhaps more importantly: it can result in a lot of confusion if you have to explain how the modeling works.

Leave a comment