ERRORS: forums.Topic.topic_author: (fields.E304) Reverse accessor for 'Topic.topic_author' clashes with reverse accessor for 'Topic.topic_last_reply_by'. HINT: Add or change a related_name argument to the definition for 'Topic.topic_author' or 'Topic.topic_last_reply_by'. forums.Topic.topic_author: (fields.E305) Reverse query name for 'Topic.topic_author' clashes with reverse query name for 'Topic.topic_last_reply_by'. HINT: Add or change a related_name argument to the definition for 'Topic.topic_author' or 'Topic.topic_last_reply_by'. forums.Topic.topic_last_reply_by: (fields.E304) Reverse accessor for 'Topic.topic_last_reply_by' clashes with reverse accessor for 'Topic.topic_author'. HINT: Add or change a related_name argument to the definition for 'Topic.topic_last_reply_by' or 'Topic.topic_author'. forums.Topic.topic_last_reply_by: (fields.E305) Reverse query name for 'Topic.topic_last_reply_by' clashes with reverse query name for 'Topic.topic_author'. HINT: Add or change a related_name argument to the definition for 'Topic.topic_last_reply_by' or 'Topic.topic_author'.
Voici le code de mon app "forums" :
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Forum(models.Model):
forum_name = models.CharField(max_length=20, unique=True)
forum_description = models.CharField(max_length=200)
class Topic(models.Model):
topic_name = models.CharField(max_length=20)
topic_description = models.CharField(max_length=200)
topic_author = models.ForeignKey(User, related_name="topics", on_delete=models.CASCADE)
topic_creation_date = models.DateTimeField(auto_now_add=True)
topic_replies_number = models.IntegerField(default=0)
topic_views_number = models.IntegerField(default=0)
topic_last_reply_by = models.ForeignKey(User, related_name="topics", on_delete=models.CASCADE)
class Post(models.Model):
topics = models.ForeignKey(Topic, related_name="posts", on_delete=models.CASCADE)
post_author = models.ForeignKey(User, related_name="posts", on_delete=models.CASCADE)
post_created_date = models.DateTimeField(auto_now_add=True)
post_updated_date = models.DateTimeField(null=True)
post_content = models.CharField(max_length=10000)
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
Développeur Web autodidacte HTML5/CSS3/JS + C# (ASP.NET Core) / Python (Django)