1đź‘Ť
If I get correctly your problem, I think it would more “Django-compliant” to define two models: one containing the commodity_type, and one containing the grade_quantity. Then, you can create a foreign key in commodity_type to link it with grade_quantity.
As general documentation, you may read https://docs.djangoproject.com/en/1.7/topics/db/examples/one_to_one/
Exemple:
class Commodity (models.Model):
type = models.CharField(...)
quantity = models.ForeignKey('Commodity')
class Grade (models.Model):
type = models.<your type adapted to the grade quantity field>
Warning: I haven’t test this exact example, but it looks like what you’re trying to achieve. Have a look at the page https://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey
For your questions:
a) For tips on how to create models, see the first links with OneToOne examples. Usually, it is useful to add a str(self) function for displaying correctly the name of the model instance. Read carefully the examples in Django documentation to have tips about how to correctly write your model (usually you define first the fields, then the methods of the models, and often the str method).
b) The ForeignKey field is the link between two models (oneToOne). A ManyToMany link exists also with the ManyToManyField field (see https://docs.djangoproject.com/en/dev/topics/db/examples/many_to_many/)
c) Normally: yes. The example I propose may need you to write on a different way the validation you already developed.