Advertisement
Guest User

Untitled

a guest
May 26th, 2016
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. content_type = models.ForeignKey(
  2. ContentType,
  3. on_delete=models.CASCADE
  4. )
  5.  
  6. object_id = models.PositiveIntegerField()
  7.  
  8. content_object = GenericForeignKey('content_type', 'object_id')
  9.  
  10. class Meta:
  11. abstract = True
  12.  
  13. class Discussion(GenericModel):
  14.  
  15. author = models.ForeignKey(
  16. 'auth.User'
  17. )
  18.  
  19. name = models.CharField(
  20. max_length=200
  21. )
  22.  
  23. description = models.TextField()
  24.  
  25. created_data = models.DateTimeField(
  26. default=timezone.now
  27. )
  28.  
  29. comments = models.ManyToManyField(
  30. 'discussions.Comment',
  31. default='',
  32. blank=True,
  33. related_name='discussion_comments'
  34. )
  35.  
  36. is_closed = models.BooleanField(
  37. default=False
  38. )
  39.  
  40. visits = models.IntegerField(
  41. default=0
  42. )
  43.  
  44. def __str__(self):
  45. return self.name
  46.  
  47. COMMON_FIELDS = (
  48. 'pk',
  49. 'author',
  50. 'name',
  51. 'description',
  52. 'created_data',
  53. 'comments',
  54. 'is_closed',
  55. 'visits'
  56.  
  57. class Meta:
  58. model = Discussion
  59. fields = COMMON_FIELDS
  60.  
  61. 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