2015-10-26 3 views
0

Я не уверен, что происходит с этой системой уведомления взгляд, здесь ошибкаУведомления система имеет проблемы

int() argument must be a string, a bytes-like object or a number, not 'SimpleLazyObject' 

Views.py

def index(request): 
    notifi = Notificaciones.objects.filter(user=request.user, Estado=False) 
    if request.method == 'POST': 
     form = RegistroUserForm(request.POST, request.FILES) 
    else: 
     form = RegistroUserForm() 
    context = { 
     'form': form, 
     'notifi': notifi 
    } 

    return render(request,'app/index.html',context) 

Models.py

class Notificaciones(models.Model): 
    user = models.ManyToManyField(User) 
    Tipo_de_notificaciones = ((1,'Ofertas'),(2,'Error'),(3,'Informacion')) 
    Tipo = models.IntegerField('Tipo de notificacion',choices=Tipo_de_notificaciones, default=3,) 
    titulo = models.CharField("Nombre de la notifiacion",max_length=50) 
    mensaje = HTMLField("Descripcion de la notificacion") 
    imagen = models.ImageField("Imagen de la notificacion",upload_to="notificaciones") 
    Fecha_Caducidad_notificacion = models.DateTimeField("Fecha de caducidad de la notificacion",auto_now_add=False) 
    Estado = models.BooleanField("Estado de la notificacion", default=False) 
    class Meta: 
     verbose_name = 'Notificacion' 
     verbose_name_plural = 'Notificaciones' 
    def __str__(self): 
     return self.titulo 

@receiver(post_save, sender=User) 
def mensaje_bienvenida(sender, **kwargs): 
    if kwargs.get('creado', False): 
     Notificaciones.objects.create(user=kwargs.get('instance'), 
             titulo= "Bienvenido a la plataforma de Vulpini.co",          
             mensaje= 'Gracias por registrarte' 
      ) 

Notificaciones.html

{% if notifi.count > 0 %} 
     {% for notifi in notifi %} 
      <ul> 
       <li> 
       {{ notifi.Tipo }} 
       {{ notifi.titulo }} 
       <img src="{{ notifi.imagen.url }}" alt="{{ notifi.titulo }}"/> 
       {{ notifi.mensaje }} 
       {{ notifi.Fecha_Caducidad_notificacion }} 
       </li> 
      </ul> 
     {% endfor %} 
    {% endif %} 

Почему показать ошибку, если два дня назад работать и я ничего не изменится. Помогите мне, спасибо

+0

Можете ли вы разместить трассировку? Вы не вызываете 'int' в этом коде, поэтому мы не можем определить, где происходит ошибка. –

ответ

1

Вы пробовали что-то подобное в своих views.py?

notifi = Notificaciones.objects.filter(user=request.user.id, Estado=False) 

EDIT:

Может быть, это предыдущий пост может быть полезным для вас. django: Purpose of django.utils.functional.SimpleLazyObject?

Или посмотрите, что я нашел, это может быть также полезно: Django int() argument must be a string or a number

Надеется, что это помогает. :)

+0

Спасибо вам большое –