Hi everyone, So I have a problem here. I have a series of forms to allow someone to create recipes, and I decided to build them with Django's form objects. The issue is that newly saved data doesn't appear as an option on another form that I bring in as part of a ChoiceField. An example that I will provide relevant code for is someone fills out a form to add a new IngredientType. They save and all is well (it goes in the DB and everything). However, when I go to the Ingredient form which has all IngredientTypes in a dropdown, the new type isn't listed (although old ones are). The data doesn't appear until I restart my development server.
Here's the relevant code: >From forms.py: class IngredientForm(forms.Form): title = forms.CharField(max_length=50, widget=forms.TextInput(attrs=attrs_dict), label=_(u'Ingredient Name')) type = forms.ChoiceField(choices=chain([('', 'Type')],IngredientType.objects.values_list('id', 'type')), label=_(u'Ingredient Type')) >From views.py: def ingredient(request): if request.POST.has_key('saveobj'): f = IngredientForm(request.POST,auto_id='id-%s') if f.is_valid() and f.cleaned_data['title'] != '': ingredient = Ingredient(title=f.cleaned_data['title'], type_id=f.cleaned_data['type']) ingredient.save() return render_to_response('cbook/object_done.html', {'value': ingredient.id, 'title': escape(ingredient.title) }) else: f = IngredientForm(auto_id='id-%s') return render_to_response('cbook/object_add.html', {'form': f, 'title': 'Add Ingredient'}) If anyone has any idea, it would be greatly appreciated. Also, if you need more of the code, just let me know. Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---