Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Jan. 29, 2011 19:41:49

g.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

query did not work


would like to post one bug, since i was sitting 4h on it

For some reasons query did not work.
In the end appeared that it depends on how urls.py are formulated:

urlpatterns = patterns('',
(r'^searchbooks','Finnish2.Fin.views.searchbooks'), # pagehttp://127.0.0.1:8000/searchbooksis displayed, query works
(r'^SB','Finnish2.Fin.views.searchbooks'), # pagehttp://127.0.0.1:8000/SBis displayed, query does not work, already print query statement in
views.searchbooks gives empty string
)

Maybe smbd can comment why this happens.


according oldmanualhttp://www.djangobook.com/en/1.0/chapter07/#################################################### Finnish2/Fin/
templates/trial/searchbooks.hmtl

<form action="/searchbooks" method="GET">
<input type="submit" value="checkdata" name="choice">
<textarea cols="100" rows="10" name="q" value="{{ query.0|escape }}">
< </textarea>
</form>

################################################### Finnish2/Fin/
forms.py

from django import forms
from models import Item

class ContactBooksF(forms.Form):
serial_number = forms.CharField(widget=forms.Textarea())


################################################### Finnish2/Fin/
models.py
from django.db import models

class Item(models.Model):
serial_number = models.CharField(max_length=15)

################################################### Finnish2/Fin/
views.py
from forms import ContactBooksF
from django.shortcuts import render_to_response,

def searchbooks(request):
query = request.GET.get('q', ''); print 'searchbooks query=',
query
if query:
print 'in query'
#seehttp://www.djangobook.com/en/1.0/chapter07/return render_to_response("c:/Python27/Scripts/Finnish2/Fin/
templates/trials/searchbooks.html", {"query": query })
})

def contactbooks(request):
form = ContactBooksF()
return render_to_response('c:/Python27/Scripts/Finnish2/Fin/
templates/trial/contactbooks.html', {'form': form})

################################################### Finnish2/
urls.py

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^searchbooks','Finnish2.Fin.views.searchbooks'),
)

--
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
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 23rd of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support