On Thu, Jan 9, 2014 at 11:06 AM, luca72 <
luca...@libero.it> wrote:
> Hello
> i have defined an url as:
>
> (r'^tipi/(\w)', 'polls.views.tipi'),
The word 'tipi', followed by a forward slash, followed by a SINGLE
'word' character, and then any other characters before the end of the
URL (but none of them will be captured as an argument to your view,
only the first word character.)
>
> the template is:
>
> (not relevant)
>
> the view is:
> def tipi(request,a):
> if a == 'Barbaresco':
> testo = ['Wine name: BARBARESCO','Region: Piedmont']
> titolo = 'Wines'
> variabile = 'vino'
> return render_to_response('vini.html',{'testo':testo,'titolo':titolo,
> 'testo':testo,'variabile':variabile,})
>
> But i get that i don't have a http response where is the error?
The view only returns a http response if a == 'Barbaresco', if it is
any other value then your view returns nothing. A view must *always*
return a HttpResponse, in every circumstance.
Also, because of the URL issue I pointed out earlier, a will never
equal 'Barbarseco'; at most it will be 'B'.
Cheers
Tom