Tuesday, November 30, 2010

Re: Choices vs. ForeignKeys

Hallöchen!

Todd Wilson writes:

> [...]
>
> [...] Instead of hard-coding the entity types here, you are using
> a constant, presumably because you may want to introduce more
> entity types later. But what are the trade-offs bewteen
> representing types as CharFields with choices, as you are doing
> here, versus a separate table of types to which this model has a
> foreign-key relationship?

I find choices much easier. Additionally, they behave more nicely
in ModelForms as they create a proper widget automatically. I use
FKs only if I want to attach additional information to the choices.

Tschö,
Torsten.

--
Torsten Bronger, aquisgrana, europa vetus
Jabber ID: torsten.bronger@jabber.rwth-aachen.de
or http://bronger-jmp.appspot.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment