App_label in Django abstract model

I am trying to get an abstract model working in Django and I hit a brick wall trying to set an appropriate name for a recommendation here: http://docs.djangoproject.com/en/dev/topics/db/models/#be-careful-with -related-name

This is what my abstract model looks like:

class CommonModel(models.Model):

    created_on = models.DateTimeField(editable=False)
    creared_by = models.ForeignKey(User, related_name="%(app_label)s_%(class)s_created", editable=False)
    updated_on = models.DateTimeField(editable=False)
    updated_by = models.ForeignKey(User, related_name="%(app_label)s_%(class)s_updated", editable=False)

    def save(self):
        if not self.id:
            self.created_on = datetime.now()
            self.created_by = user.id

        self.updated_on = datetime.now()
        self.updated_by = user.id
        super(CommonModel, self).save()

    class Meta:
        abstract = True

      

My shared model is in [project_root] /models.py. This is the parent of this model and is located in the app called Feedback [project_root] /feedback/models.py:

from django.db import models
from mediasharks.models import CommonModel

class Feedback(CommonModel):
    message = models.CharField(max_length=255)
    request_uri = models.CharField(max_length=255)
    domain = models.CharField(max_length=255)
    feedback_type = models.IntegerField()

      

Basically I'm trying to set up a generic model so that I can always specify when and by whom the database records were created.

When I run "python manage.py validate" I get this error message: KeyError: 'app_label'

Did I miss something?

+2


a source to share


1 answer


Pay attention to the bold text on your link: "Changed in development version". If you are not using the recent Django connector validation - for example, you are using the latest released version, 1.1 - you should use this link for documentation. This version of the text is not referenced app_label

because it has not yet been introduced.



+1


a source







All Articles