In your def __unicode__ convert the current returned int to string : def __unicode__(self): # Python 3: def __str__(self): > return str(self.vm_id) >
credit to https://janetalkscode.wordpress.com/2013/09/28/django-long-object-has-no-attribute-encode/comment-page-1/ On Monday, July 14, 2014 10:38:19 PM UTC+1, G Z 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 [email protected]. To post to this group, send email to [email protected]. 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/2f878caf-fa52-4517-a467-3441168c54b5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

