I'm kind of new to webapps and database stuff in general so this might be a dumb question. I want to make a model ("CategoryModel") with a field that points to the primary id of another instance of the model (its parent).
class CategoryModel(models.Model):
parent = models.ForeignKey(CategoryModel)
How do I do this? Thanks!
parent
instead ofparentId
, sincemy_category_model.parent
will be an instance ofCategoryModel
. Django will automatically create a memberparent_id
which will be the primary key of the related model. – Scott