class User(models.Model):
name = models.CharField(max_length=100)
class Comment(models.Model):
text = models.TextField()
user = models.ForeignKey(User, related_name="comments")
I would hope that I could run G(User, comments=[F(), F()]) to make a user with a few test comments.
However, this creates a user, but creates no comments.
G(Comment, user=F()) creates a comment, and a user.
The solution is to do
x = G(User)
comments = [G(Comment), G(Comment)]
x.comments.set(comments)
But this seems extraneous when F() exists for a reason. Would there be a way to make it so reverse relation managers behave the same way that a regular relation manager works?
With models like such:
I would hope that I could run
G(User, comments=[F(), F()])
to make a user with a few test comments.However, this creates a user, but creates no comments.
G(Comment, user=F())
creates a comment, and a user.The solution is to do
But this seems extraneous when F() exists for a reason. Would there be a way to make it so reverse relation managers behave the same way that a regular relation manager works?