I'm just not getting this. I've looked at many examples and can't seem
to pass a hidden value into a form.

The problem is that I initially get to the form with GET, and then
instantiate the form with PUT. The key that I need is part of the
original URL, and I'm trying to push it down into the PUT data as
well, but failing.

I have

 (r'^fences/newFence/(?P<auth_id>.*)$', 'newFence'),

class newFenceForm(forms.Form):
    teaser = forms.CharField(max_length=40)
    url = forms.CharField()
    address = forms.CharField()
    range = forms.IntegerField()
    auth_id = forms.CharField(widget=forms.HiddenInput)

def newFence(request, auth_id):
    if request.method == 'POST':        # if the form has been submitted
        form = newFenceForm(request.POST)
        if form.is_valid():
            # do the geocoding
            print form.cleaned_data['auth_id']
            print form.cleaned_data['teaser']
            print form.cleaned_data['url']
            print form.cleaned_data['address']
            print form.cleaned_data['range']
            # save the object
            u = User.objects.filter(auth_id = id)
            # show them the new map
            return HttpResponseRedirect('../../fences/fenceMap/
%s'%auth_id)
    else:
        print auth_id
        form = newFenceForm({'auth_id' : auth_id})

    return render_to_response("map/newfence.html", {'form': form, })

I call this with, say, '.../newFence/chris' and the first time through
it prints 'chris' and instantiates the empty form. But where my
template says

<input type="hidden" name="auth_id" value="{{auth_id}}"
id="id_auth_id" />

the string between curlies is always empty.

What trick am I missing to get that data initiated? Should a
HiddenInput widget be rendered differently in the template?

(I'm happy to take suggestions for a different way to crack this, too
- the problem is that I have to do some post processing on the input
data before creating the object, or I'd use a generic view.)

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

Reply via email to