Answers for "RuntimeError: Model class payments_app.models.Product doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS."

2

RuntimeError: Model class payments_app.models.Product doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

When it says "Model class xxx doesn't declare an explicit app_label" your models can specify Meta to define their app_label. You can also customise the database table name along with a bunch of other options as part of the meta data.

Example: If your application name is user_app
You need to do something like this on all your models;

class Author(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    profile_picture = models.ImageField()

    class Meta:
        app_label = 'user_app'

    def __str__(self):
        return self.user.username
Posted by: Guest on February-21-2022

Code answers related to "RuntimeError: Model class payments_app.models.Product doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS."

Python Answers by Framework

Browse Popular Code Answers by Language