Django Categories v0.4.8 documentation
To create a many-to-one relationship (foreign key) between a model and Django Categories, you register your model with the register_fk function.
Parameters: |
|
---|
Example, in your models.py:
import categories
categories.register_fk(MyModel)
If you want more than one field on a model you have to have some extra arguments:
import categories
categories.register_fk(MyModel, 'primary_category')
categories.register_fk(MyModel, 'secondary_category', {'related_name':'mymodel_sec_cat'})
The extra_args allows you to specify the related_name of one of the fields so it doesn’t clash.
To create a many-to-many relationship between a model and Django Categories, you register your model with the register_m2m function.
Parameters: |
|
---|
Example, in your models.py:
import categories
categories.register_m2m(MyModel)