You're using parens instead of brackets.

Change

        fields = ('username', 'email', 'password')

to

        fields = ['username', 'email', 'password']


On Thu, Jun 19, 2014 at 1:07 PM, G Z <[email protected]> wrote:

> I'm trying to write my forms.py class for editing customers but I'm
> getting some strange issues where it says the field is unknown but im
> typing it exactly how it is in the model.
>
> Forms.Py
>
> from portal.models import UserProfile, Customer
>> from django.contrib.auth.models import User
>> from django import forms
>> class UserForm(forms.ModelForm):
>>     password = forms.CharField(widget=forms.PasswordInput())
>>     class Meta:
>>         model = User
>>         fields = ('username', 'email', 'password')
>> class UserProfileForm(forms.ModelForm):
>>     class Meta:
>>         model = UserProfile
>>         fields = ('website', 'picture')
>>
>>
>> class ecForm(forms.ModelForm):
>>     class Meta:
>>         model = Customer
>>         fields = ('customer_id', 'customer_name', 'inactive',)
>
>
>
> Models.Py Customer
>
> class Customer(models.Model):
>>    customer_id = models.BigIntegerField(primary_key = True, editable =
>> False, db_column = 'customer_id')
>>    customer_name = models.CharField(max_length = 30)
>>    inactive = models.CharField(max_length = 1)
>>    class Meta:
>>       managed = False
>>       db_table = 'customers'
>>       ordering = ['customer_name']
>
>
>
>>
>> Error
>>
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/portal/37/
>> Django Version: 1.6.5
>> Python Version: 2.7.5
>> Installed Applications:
>> ('django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'portal')
>> Installed Middleware:
>> ('django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
>> Traceback:
>> File
>> "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in
>> get_response
>>   99.                 resolver_match = resolver.resolve(request.path_info)
>> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
>> in resolve
>>   339.                     sub_match = pattern.resolve(new_path)
>> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
>> in resolve
>>   223.             return ResolverMatch(self.callback, args, kwargs,
>> self.name)
>> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
>> in callback
>>   230.         self._callback = get_callable(self._callback_str)
>> File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py"
>> in wrapper
>>   32.         result = func(*args)
>> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
>> in get_callable
>>   97.             mod = import_module(mod_name)
>> File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py"
>> in import_module
>>   40.         __import__(name)
>> File "/home/grant/workspace/Django Projects/trunk/holon/portal/views.py"
>> in <module>
>>   8. from portal.forms import UserForm, UserProfileForm, ecForm
>> File "/home/grant/workspace/Django Projects/trunk/holon/portal/forms.py"
>> in <module>
>>   18. class ecForm(forms.ModelForm):
>> File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in
>> __new__
>>   292.                 raise FieldError(message)
>> Exception Type: FieldError at /portal/37/
>> Exception Value: Unknown field(s) (customer_id) specified for Customer
>
> Environment:
>
>>
>
>  --
> 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/67b4c709-bb7f-48d2-b3d0-89c59068ee0f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/67b4c709-bb7f-48d2-b3d0-89c59068ee0f%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 [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/CALLzXtQd0H1v4g7qqWsLNiOvX_yaGK%3DLoKcGds%2BsdJGMremO%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to