Sounds like you are not creating the form in your view .. read the
tutorial the part about creating a form ..
you need the form class, and the view that process your form (a)
creates an empty form b) process the submitted one)

see this relative simple example of a login form ..

class userLoginForm(forms.Form):
  email = forms.CharField(max_length=45, label="Email address",
error_messages={'required': 'Please enter an email address.'})
  password = forms.CharField(widget=forms.PasswordInput(),
label="Password", error_messages={'required': 'Please enter a
password.'})


def userLogin(request):
  context_instance = RequestContext(request)
  try:
    nextUrl = request.GET['next']
  except:
    nextUrl = "/myopal/"
  if request.POST:
    form = userLoginForm(request.POST)
    username = request.POST['email']
    password = request.POST['password']
    if form.is_valid():
      user = authenticate(username=username, password=password)
      if user is not None:
        if user.is_active:
          login(request, user)
          return HttpResponseRedirect(nextUrl)
        else:
          error = "This account as been disabled, please contact
support."
          return render_to_response('registration/login.html',
{'form': form, 'login_error': error, 'nextUrl': nextUrl},
context_instance)
      else:
        error = "Wrong details entered, please try again."
        return render_to_response('registration/login.html', {'form':
form, 'login_error': error, 'nextUrl': nextUrl}, context_instance)
    else:
      return render_to_response('registration/login.html', {'form':
form, 'nextUrl': nextUrl}, context_instance)
  else:
    form = userLoginForm()
  return render_to_response('registration/login.html', {'form': form,
'nextUrl': nextUrl}, context_instance)



On Dec 12, 11:04 pm, GoSantoni <mj.schuur...@gmail.com> wrote:
> Hey i've got a very basic question about django form processing. Got
> haystack installed and searching works fine in the standard search
> template (http://haystacksearch.org/docs/tutorial.html#search-
> template) in the /search . Though i want to use the search box defined
> by {{ form.as_table }} in another template in /blog . Just copying
> {{ form.as_table }} fails to display the input field so what part of
> the views.py or the forms.py needs to be copied from the haystack app?
> Or what is another solution? So far in /blogs/blogs.html
>
> <form method="get" action="../search/">
>         <table>
>             {{ form.as_table }}
>
>                 <tr>
>                 <td>&nbsp;</td>
>                 <td>
>                     <input type="submit" value="Search">
>                 </td>
>             </tr>
>         </table>
>
> My goal is just to display the input box and send the query to /search
> so the results are displayed on that page
>
> Thanks in advance!

--

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


Reply via email to