Hey guys thanks for your respond. First of all i read the tutorial and the form works in /search with the template and the view. For now I am trying to achieve a searchfield in another folder, /blog. Are you guys saying i have to copy/ repeat the form in the /blog view and template? To be as DRY as possible I'd like to have 1 template/view search function and I'd like to pass data from elsewhere to that place. So I understand my question was a bit vague but what I'd like to do in the /blog template is:
<form method="get" action="../search/"> ********* send from /blog to template/view of search <table> {{ form.as_table }} ********* load form from /search template/view into /blog <tr> <td> </td> <td> <input type="submit" value="Search"> </td> </tr> </table> This is the (standard) views.py from haystack which i have in the app folder: http://dpaste.com/132922/ And this is the (standard) forms.py http://dpaste.com/132923/ Thanks 2009/12/13 oliver <oliver.bock...@gmail.com>: > 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> </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. > > > -- Mark Schuuring M: mj.schuur...@gmail.com -- 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.