tags:

views:

109

answers:

1

I want to be able to provide a list of possible values when entering a text field in django admin. I have a legacy database so I can't add a new model and reference that.

Could I provide something like:

possible_values = ['one','two',three']

to the fieldsets tuple, for a particular field in model handler?

Sorry for the newbie question.

+1  A: 

Ok, I figured this one out with the help of the excellent djangoproject documentation: http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/

You add a tuple:

COUNT_OPTIONS = (
  ('1','one'),
  ('2','two'),
)

Then in for a particular model

count = models.CharField(max_length=3, blank=True, choices=COUNT_OPTIONS)

I knew there had to be an easy way ...

Zemogle