Hello list. I'm a newbie with django and have a problem with the encoding. I use postgreSQL 8.3 with psycopg2. My database is in latin1 and i can't change this to utf-8(i don't have the permission), however the database have a client-encoding in utf-8. I think this solves the problem.
Now my problem: I have this code: ------------------------------------------- # -*- coding: utf-8 -*- from django.db.models import Q from django.shortcuts import render_to_response from models import Book,Publisher from forms import ContactForm def search(request): query = request.GET.get('q', '') if query: qset = ( Q(title__icontains=query) | Q(authors__first_name__icontains=query) | Q(authors__last_name__icontains=query) ) results = Book.objects.filter(qset).distinct() else: results = [] return render_to_response("search.html", { "results": results, "query": type(query), #"aaa":results.query, }) and his template ------------------------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html lang="en"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>Search{ % if query %} Results{ % endif %}</title> </head> <body> <h1>Search</h1> <form action="" method="GET"> <label for="q">Search: </label> <input type="text" name="q" value="{{ query|escape }}"> <input type="submit" value="Search"> </form> {{ query|escape }} {% if query %} <h2>Results for "{{ query|escape }}":</h2> {% if results %} {{ results|escape }} <ul> {% for book in results %} <li>{{ book|escape }}</li> {% endfor %} </ul> {% else %} <p>No books found</p> {% endif %} {% endif %} </body> </html> ------------------------------------------- is a simple page to search coincidences When i type "ó" in the input box all works fine, and returns all coincidences and the url says "http://localhost/prueba_1/search/?q=ó" However when i type directly in the url "http://localhost/prueba_1/ search/?q=ó" and press enter Django throw an error "Caught DatabaseError while rendering: carácter 0xefbfbd de codificación «UTF8» no tiene equivalente en «LATIN1»" and the url in the browser change to "http://localhost/prueba_1/ search/?q=%F3". Why happens that?, I'm really confused with the themes about the encoding. That's is my question, thanks for read, and sorry for my poor english -- 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.