Search Results

Search found 1 results on 1 pages for 'rayan'.

Page 1/1 | 1 

  • app_label in an abstract Django model

    - by rayan
    Hi all, I'm trying to get an abstract model working in Django and I hit a brick wall trying to set the related_name per the 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 common model is in [project_root]/models.py. It is the parent object of this model, which is located in an 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 common model so that I'll always be able to tell when and by whom database entries were created. When I run "python manage.py validate" I get this error message: KeyError: 'app_label' Am I missing something here?

    Read the article

1