Reputation: 4292
I'm working on my Django threaded comments.My model is:
class Comment(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField(max_length=75)
content = models.TextField()
published = models.DateTimeField('Date published')
updated = models.DateTimeField('Date updated')
author = models.ForeignKey(User)
how can i relate author with user? Am i right?
I'm not sure with last line of code.
Upvotes: 0
Views: 423
Reputation: 5726
Your question is no quite clear, but you are relating your Comment class to a User. So you got that one right.
I assume one comment can only be related to a single user (probably the one that has created it). If so it is correct to use the ForeignKey relation as well, as it is made for exactly that kind of relationship.
Upvotes: 1