Hi!

I'm creating a model 'Print' with a field 'paper_type' that would contain a value from a paper types list. As I understand I can make it two different ways:

1. Create a PaperType table and refer to it from Print with a foreign key:
 class PaperType:
   name=meta.CharField(maxlength=20)

 class Print:
   ...
   paper_type=meta.ForeignKey(PaperType)

2. Supply a choices tuple for the field inline:
 PAPER_TYPES=(
   (1,'Letter),
   (2,'A4'),
 )

 class Print:
   ...
   paper_type=meta.IntegerField(choices=PAPER_TYPES)

What should I consider when choosing between them? I suppose choices tuple is easier to work with when making views since Django automatically generates <select> for it (or am I wrong here?). On the other hand lookup table is more flexible since I can extend it later to contain more than just 'name' field. Are there any other differences?

Reply via email to