- Where Developers Learn, Share, & Build Careers
- Why would I create a recursive relationship?
- Is it like the above?
class a class (models.model): eiffel = model.
-
When you use the same model structure, If the father and child want to node, you may need to make a recurring relationship. For example, if you have any comments with text, data and user_id:
class comment (models.model): text = models.TextField () create_date_time = models.DateTimeField () parent_comment = Models.ForeignKey ('self')
I think yes (you can try testing it), but this is not a good form If you change the name of a class, then you have to change the string value in the brackets. If you use 'self' then you do not do this headache.
- Is it like the above?
Comments
Post a Comment