Oh sorry, thought you wanted multiple categories per photo. Tim's
response above is good.
As he said, I'd go with the ForeignKey approach, this makes the
categories easier to manage and gives you further flexibility of
storing additional information within each category (if you want).
Also his
For something like categories, I would go with a separate model and
use ForeignKey. For that 1% chance when you have to add a new
category, it will be a lot easier. Plus, what if requirements change
in the future and you are adding/deleting categories more than you
anticipated?
Using choices
Hello Peter,
sorry, I was talking about choices, not a choice field:
http://docs.djangoproject.com/en/dev/ref/models/fields/#choices
Since any photo can only belong to one category (because I say so :) I
would tend towards using 1:N instead of M:N. Or did I missunderstand
you? If one photo can
Hey Léon,
ChoiceField is a form field, not a table column—maybe you're thinking
about CommaSeparatedIntegerField? You could use that and hardcode
which categories represent which ids in your python code.
http://docs.djangoproject.com/en/dev/ref/models/fields/#commaseparatedintegerfield
On the
Hello,
let's assume we have a model for photos with the fields id, user,
photo. Any user should be able to categorize his foto with a given
number of categories, e.g. person, car, building. In future it's
possible that I add more categories.
My question is whether the new category field should
5 matches
Mail list logo