Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- content_type = models.ForeignKey(
- ContentType,
- on_delete=models.CASCADE
- )
- object_id = models.PositiveIntegerField()
- content_object = GenericForeignKey('content_type', 'object_id')
- class Meta:
- abstract = True
- class Discussion(GenericModel):
- author = models.ForeignKey(
- 'auth.User'
- )
- name = models.CharField(
- max_length=200
- )
- description = models.TextField()
- created_data = models.DateTimeField(
- default=timezone.now
- )
- comments = models.ManyToManyField(
- 'discussions.Comment',
- default='',
- blank=True,
- related_name='discussion_comments'
- )
- is_closed = models.BooleanField(
- default=False
- )
- visits = models.IntegerField(
- default=0
- )
- def __str__(self):
- return self.name
- COMMON_FIELDS = (
- 'pk',
- 'author',
- 'name',
- 'description',
- 'created_data',
- 'comments',
- 'is_closed',
- 'visits'
- class Meta:
- model = Discussion
- fields = COMMON_FIELDS
- Could not resolve URL for hyperlinked relationship using view name "contenttype-detail". You may have failed to include the related model in your API, or incorrectly configured the `lookup_field` attribute on this field.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement