Wednesday, November 2, 2011

Re: Set of choices of which several can be chosen without using a ManyToManyField

On Wed, Nov 2, 2011 at 12:15 PM, Jaroslav Dobrek
<jaroslav.dobrek@gmail.com> wrote:
> I now use ManyToManyFields and hide certain data from administrators
> by simply not importing them into admin.py. What I don't like about
> this solution is that this data still is in the database and not in my
> source code. In my view, it should be part of the source code, because
> it is part of the program logic: Any instance of my program is
> supposed to use these data, independently of any other set of data it
> might use. Much as any instance of a program that uses the notion of
> gender should have the genders "male" and "female". Administrators
> should not have to or be able to manipulate gender objects.
>

As you've alluded to, you can control this by not giving them
interfaces to adjust those items.

With respect to the data being constant and unchanging, this makes it
ideally suited to become part of a initial_data fixture, that will
automatically be loaded into the database when an app is synched to
the database. This fixture then becomes a part of your source code.

https://docs.djangoproject.com/en/1.3/howto/initial-data/#providing-initial-data-with-fixtures

Cheers

Tom

--
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