21👍
Yes, just do this:
class Example(models.Model):
parent_example = models.ForeignKey('self')
- [Django]-How to create a custom decorator in Django?
- [Django]-Django Admin app or roll my own?
- [Django]-How to make the foreign key field optional in Django model?
1👍
You can do this using quotes too:
class Example(models.Model):
parent_example = models.ForeignKey('Example')
- [Django]-Do I need Nginx with Gunicorn if I am not serving any static content?
- [Django]-How do I match the question mark character in a Django URL?
- [Django]-How to remove all relations from manytomany?
Source:stackexchange.com