Tuesday, August 26, 2014

Re: Model - def __unicode__(self) - doesn't work

Hi, thanks for your reply.

It didn't help, I also trid return unicode(self.name)

Regards
Przemek.

W dniu wtorek, 26 sierpnia 2014 10:24:07 UTC+2 użytkownik monoBOT monoBOT napisał:
Be sure to returm a unicode object like this:

    def __unicode__(self):
        return u"%s" % self.name


2014-08-25 23:48 GMT+01:00 Mario Gudelj <mario....@gmail.com>:

Your problem is in the add view. Post your view code

On 26/08/2014 7:20 am, "Przemek Ciborowski" <cib...@gmail.com> wrote:
Hello guys,

I'm really beginner in django.
I have extremely simple example:

class Vlan(models.Model):
    name = models.CharField(max_length=30, name='Vlan name')
    number = models.IntegerField(default=0, name='Vlan number')

    def __unicode__(self):
        return self.name

When I'm trying to use admin interface, I got this error:

AttributeError at /admin/networks/vlan/add/

'Vlan' object has no attribute 'name'
Request Method:POST
Request URL:http://127.0.0.1:8000/admin/networks/vlan/add/
Django Version:1.6.6
Exception Type: AttributeError
Exception Value:
'Vlan' object has no attribute 'name'
Exception Location: D:\Scripts\Mercury\networks\models.py in __str__, line 10
Python Executable: C:\Python\Main\Scripts\python.exe
Python Version: 2.7.8

I'm sure that it was working a few days ago. And in meantime I did django upgrade.
What I'm doing wrong, and how I can fix it?

Thanks in advance.
Przemek.

--
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...@googlegroups.com.
To post to this group, send email to django...@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/50470bc3-c7a0-4afd-b655-f7a3cf8304a0%40googlegroups.com.
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...@googlegroups.com.
To post to this group, send email to django...@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/CAHqTbj%3DNk8DTt5UNGktqkGb6-Lwqvt8-g2sSW9EpbMZ_8YPRSQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
monoBOT
Visite mi sitio(Visit my site): monobotsoft.es/blog/

--
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+unsubscribe@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/a69ad175-f1e3-4b1f-990b-92402a0c7489%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment