Ver Mensaje Individual
  #6 (permalink)  
Antiguo 03/01/2012, 22:58
Avatar de razpeitia
razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 2 meses
Puntos: 1360
Respuesta: Problema con ImageWithThumbsField

Código Python:
Ver original
  1. #models.py
  2. from django.db import models
  3. from thumbs import ImageWithThumbsField
  4.  
  5. class Person(models.Model):
  6.     photo = ImageWithThumbsField(upload_to='images', sizes=((125,125),(200,200)))

Código Python:
Ver original
  1. #views.py
  2. from django.shortcuts import render_to_response
  3. from models import Person
  4.  
  5. def vista(request):
  6.     p = Person.objects.all()[0]
  7.     return render_to_response('template.html', {'person': p})

Código django-template:
Ver original
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <!-- template.html -->
  4. <head>
  5.     <title></title>
  6. </head>
  7.  
  8. <body>
  9.  
  10.     <div id="content">
  11.        <img src="{{ person.photo.url }}" alt="" />
  12.        <img src="{{ person.photo.url_200x200 }}" alt="" />
  13.        <img src="{{ person.photo.url_125x125 }}" alt="" />
  14.     </div>
  15. </body>
  16. </html>

En el settings.py tengo
Código Python:
Ver original
  1. MEDIA_ROOT = '/ruta/a/media'
  2. MEDIA_URL = 'http://url/a/media/'
  3. STATIC_URL = '/media/'

A mi me funciona perfecto.