The __unicode__ method must return a unicode string.

The function unicode(), or string formatting would suffice.

Cheers

Tom


On Mon, Jul 14, 2014 at 10:38 PM, G Z <zuk...@gmail.com> wrote:

> how do I fix this?
>
>
> class Vm_licenses(models.Model):
>    vm_license_id = models.BigIntegerField(primary_key = True, editable =
> False, db_column = 'vm_license_id')
>    license= models.ForeignKey(License,  on_delete = models.PROTECT)
>    vm= models.ForeignKey(Vm,  on_delete = models.PROTECT)
>
>    class Meta:
>       managed = False
>       db_table = 'vm_licenses'
>
>    def __unicode__(self):  # Python 3: def __str__(self):
>       return self.vm_id
>
> Request Method:GETRequest URL:
> http://127.0.0.1:8000/admin/portal/vm_licenses/Django Version:1.6.5Exception
> Type:AttributeErrorException Value:
>
> 'int' object has no attribute 'encode'
>
> Exception 
> Location:/usr/local/lib/python2.7/dist-packages/django/db/models/base.py
> in __str__, line 430Python Executable:/usr/bin/pythonPython Version:2.7.5
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/06de81a6-131a-4e6e-9f24-c370cdd14076%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/06de81a6-131a-4e6e-9f24-c370cdd14076%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1%2B%2BWz6%3DSJ9Q6%2BLWbN6OJoW4jnC-%2BFHC1ma8rM4YtmaNtA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to