Re: {{ form.as_table }} not displaying in template

2009-12-13 Thread Mark Schuuring
Oh and I am not familiar with Ajax I am sorry because I've been
told that's a way to handle it...
Regards

2009/12/13 Mark Schuuring :
> 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:
>
>        * send from
> /blog to template/view of search
>          
>              {{ form.as_table }}          * load form from
> /search template/view into /blog
>                  
>                  
>                  
>                      
>                  
>              
>          
>
> 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 :
>> 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  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.as_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
>



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




Re: {{ form.as_table }} not displaying in template

2009-12-13 Thread Mark Schuuring
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:

   * send from
/blog to template/view of search
         
             {{ form.as_table }}  * load form from
/search template/view into /blog
                 
                 
                 
                     
                 
             
         

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 :
> 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  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.as_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.




Re: {{ form.as_table }} not displaying in template

2009-12-13 Thread oliver
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  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.as_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.




Re: {{ form.as_table }} not displaying in template

2009-12-12 Thread Brian Neal
On Dec 12, 5:04 pm, GoSantoni  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.as_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!

I'm not really sure what you are asking. If the {{ form }} isn't
displaying, then look to your view that renders the template. Are you
building the form right and passing it to the template correctly?

--

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.




Re: form.as_table not displaying in template

2008-04-22 Thread Explore

Thank you all for your quick responses.  I was passing the class
instead of the instance.  Everything is working great now!

On Apr 22, 12:20 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-04-22 at 09:02 -0700, Explore wrote:
> > Hi. I am new to django and I am trying to get a handle around the form
> > processing.  I am using the svn trunk Revision: 7419 on Windows with
> > the development server.  I have a views.py setup in my app that looks
> > like this:
>
> >   form = TestingForm()
> >   print form.as_table()
> >   print form.as_table
> >   return render_to_response('testing.html', { 'form':TestingForm })
>
> You're passing in a class to the template, rather than an instance of
> the form. Your need to pass the "form" variable via the dictionary, not
> the TestingForm class.
>
> Regards,
> Malcolm
>
> --
> I just got lost in thought. It was unfamiliar 
> territory.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: form.as_table not displaying in template

2008-04-22 Thread Explore

Karan and Malcolm,

Thank you both - that was the problem. It is working great now!

On Apr 22, 12:20 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-04-22 at 09:02 -0700, Explore wrote:
> > Hi. I am new to django and I am trying to get a handle around the form
> > processing.  I am using the svn trunk Revision: 7419 on Windows with
> > the development server.  I have a views.py setup in my app that looks
> > like this:
>
> >   form = TestingForm()
> >   print form.as_table()
> >   print form.as_table
> >   return render_to_response('testing.html', { 'form':TestingForm })
>
> You're passing in a class to the template, rather than an instance of
> the form. Your need to pass the "form" variable via the dictionary, not
> the TestingForm class.
>
> Regards,
> Malcolm
>
> --
> I just got lost in thought. It was unfamiliar 
> territory.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: form.as_table not displaying in template

2008-04-22 Thread Malcolm Tredinnick


On Tue, 2008-04-22 at 09:02 -0700, Explore wrote:
> Hi. I am new to django and I am trying to get a handle around the form
> processing.  I am using the svn trunk Revision: 7419 on Windows with
> the development server.  I have a views.py setup in my app that looks
> like this:
> 
>   form = TestingForm()
>   print form.as_table()
>   print form.as_table
>   return render_to_response('testing.html', { 'form':TestingForm })

You're passing in a class to the template, rather than an instance of
the form. Your need to pass the "form" variable via the dictionary, not
the TestingForm class.

Regards,
Malcolm

-- 
I just got lost in thought. It was unfamiliar territory. 
http://www.pointy-stick.com/blog/


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



Re: form.as_table not displaying in template

2008-04-22 Thread Karen Tracey
On Tue, Apr 22, 2008 at 12:02 PM, Explore <[EMAIL PROTECTED]>
wrote:

>
> Hi. I am new to django and I am trying to get a handle around the form
> processing.  I am using the svn trunk Revision: 7419 on Windows with
> the development server.  I have a views.py setup in my app that looks
> like this:
>
>  form = TestingForm()
>  print form.as_table()
>  print form.as_table
>  return render_to_response('testing.html', { 'form':TestingForm })
>
>
You are passing the TestingForm class into the template context instead of
the form instance you created.  This should be:

return render_to_response('testing.html', { 'form': form })

Karen


>
> When I look at the output of this on my development server I see that
> form.as_table prints out the object info and form.as_table() prints
> out the tr tags for the form. So this looks like form.as_table() is
> working as it should when printing to the command line.
>
> However, when I try to use this in my template testing.html like this:
>
>  test 1
>  
>{{ form.as_table }}
>  
>
> nothing prints out (maybe because it is trying to print the object
> instead of calling the method?)  However, when I try:
>
> form.as_table() I get the following syntaxerror:
> Could not parse the remainder: '()' from 'form.as_table()'
>
> How can I use form.as_table in my template?
>
> I am new to both python and django so any help would be appreciated.
> Thanks very much.
> >
>

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



Re: form.as_table not displaying in template

2008-04-22 Thread Kenneth Gonsalves


On 22-Apr-08, at 9:32 PM, Explore wrote:

>  test 1
>   
> {{ form.as_table }}
>   
>
> nothing prints out (maybe because it is trying to print the object
> instead of calling the method?)

this is correct. It should work, but to diagnose you should post the  
full template and the full view

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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