On 26 Aug 2014 14:38, "James Schneider" <jrschneide...@gmail.com> wrote:
>
> Try changing the 'name' argument to 'verbose_name' like so:
>
> name = models.CharField(max_length=30, verbose_name='Vlan name')
>
> I don't believe model fields accept 'name' as a keyword arg.
This would also explain the slightly confusing error due to the overlap of
'name' appearing in multiple spots.
>

Just like I pointed out in my earlier mail. Remove the name argument or
change it to verbose_name as recommended by James

> https://docs.djangoproject.com/en/dev/ref/models/fields/#field-options
>
>
> -James
>
>
>
> On Tuesday, August 26, 2014, Przemek Ciborowski <cibo...@gmail.com> wrote:
>>
>> So to be more clearly, let create new django project with one
application for example with name networks.
>> Add those lines to the networks/models.py:
>>
>> class Vlan(models.Model):
>>
>>     name = models.CharField(max_length=30, name='Vlan name')
>>
>>     def __unicode__(self):
>>         return self.name
>>
>> add those two lines to networks/admin.py
>>
>> from .models import *
>> admin.site.register(Vlan)
>>
>> It should be (and was) enough to run admin interface. Unfortunately when
I'm trying to add new vlan or list current vlans I get:
>> -------------------
>> 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:
>> C:\Scripts\Test1\networks\models.py in __unicode__, line 11
>> Python Executable:
>> C:\Python\Main\Scripts\python.exe
>> Python Version:
>> 2.7.8
>> Python Path:
>>
>> ['C:\\Scripts\\Test1',
>>  'C:\\Scripts\\Test1',
>>  'C:\\Windows\\SYSTEM32\\python27.zip',
>>  'C:\\Python\\Main\\DLLs',
>>  'C:\\Python\\Main\\lib',
>>  'C:\\Python\\Main\\lib\\plat-win',
>>  'C:\\Python\\Main\\lib\\lib-tk',
>>  'C:\\Python\\Main\\Scripts',
>>  'C:\\Python27\\Lib',
>>  'C:\\Python27\\DLLs',
>>  'C:\\Python27\\Lib\\lib-tk',
>>  'C:\\Python\\Main',
>>  'C:\\Python\\Main\\lib\\site-packages']
>>
>> Server time:
>> Tue, 26 Aug 2014 14:12:06 +0200
>>
>>
>>
>> -----------------------
>>
>> More information here : http://dpaste.com/26QQPKZ
>>
>> Look this is code from first part of official django tutorial.
>> When I delete def __unicode__(self) method from models file, it works
fine but in vlan list I get Vlan object, Vlan object.... etc instead of
names.
>>
>>
>> Regards
>> Przemek.
>>
>>
>>
>>
>> W dniu poniedziałek, 25 sierpnia 2014 22:47:10 UTC+2 użytkownik Przemek
Ciborowski napisał:
>>>
>>> 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+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/01dd14d6-43d7-4519-bffb-b6d33a083f54%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+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/CA%2Be%2BciWRN00qpz1SRvzgC_k0av92MQyPsN0TSU1CBdBh-QFbWw%40mail.gmail.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+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/CA%2BWjgXPeNsd26zZqto-j9ySg_5mPFwyGunwykP3%3DsOmguan2og%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to