Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » simplest for example, Error object has no attribute 'cleaned_data' [RSS Feed]

#1 Jan. 30, 2011 08:02:17

g.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

simplest for example, Error object has no attribute 'cleaned_data'


Is it possible by making small change to resolve the error below:
(I did not yet finished reading all manual, maybe the error disappears
if i make custom code for every line in the model, but my model has
over 30 fields thus i would like to have automated save and post of
all these fields)

Django Version: 1.2.4
Exception Type: AttributeError
Exception Value: 'WordFormM' object has no attribute 'cleaned_data'
Exception Location: c:\Python27\lib\site-packages\django\forms
\models.py in save_m2m, line 78

###################views.py
from forms import FindWordM
from models import Word
from django.shortcuts import render_to_response,

def first(request):
w=Word.objects.get(pk=90);
formWord=WordFormM(instance=w);
formWord.save();
return render_to_response("c:/Python27/Scripts/Finnish2/Fin/
templates/trials/correct.html", {
"formWord": formWord})


###################forms.py
from django.forms import ModelForm
from models import Word

class FindWordM(ModelForm):
class Meta:
model=Sent

###################models.py
from django.db import models

class Word(models.Model):
WordSentences=models.TextField(max_length=1000,
blank=True,default='')
WordSentencesMM=models.ManyToManyField('self', null=True,
blank=True)
WordGramNotesDeclFK=models.ForeignKey(WordDeclN,
related_name='DeclNWord', null=True, blank=True)
...

###################urls.py
from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^first','Finnish2.Fin.views.first')
)

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 30, 2011 14:41:08

Daniel R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

simplest for example, Error object has no attribute 'cleaned_data'


On Sunday, January 30, 2011 8:02:08 AM UTC, gintare wrote:

> Is it possible by making small change to resolve the error below:
> (I did not yet finished reading all manual, maybe the error disappears
> if i make custom code for every line in the model, but my model has
> over 30 fields thus i would like to have automated save and post of
> all these fields)
>
> Django Version: 1.2.4
> Exception Type: AttributeError
> Exception Value: 'WordFormM' object has no attribute 'cleaned_data'
> Exception Location: c:\Python27\lib\site-packages\django\forms
> \models.py in save_m2m, line 78
>
> ###################views.py
> from forms import FindWordM
> from models import Word
> from django.shortcuts import render_to_response,
>
> def first(request):
> w=Word.objects.get(pk=90);
> formWord=WordFormM(instance=w);
> formWord.save();
> return render_to_response("c:/Python27/Scripts/Finnish2/Fin/
> templates/trials/correct.html", {
> "formWord": formWord})
>
>
> ###################forms.py
> from django.forms import ModelForm
> from models import Word
>
> class FindWordM(ModelForm):
> class Meta:
> model=Sent
>
> ###################models.py
> from django.db import models
>
> class Word(models.Model):
> WordSentences=models.TextField(max_length=1000,
> blank=True,default='')
> WordSentencesMM=models.ManyToManyField('self', null=True,
> blank=True)
> WordGramNotesDeclFK=models.ForeignKey(WordDeclN,
> related_name='DeclNWord', null=True, blank=True)
> ...
>
> ###################urls.py
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
> (r'^first','Finnish2.Fin.views.first')
> )
>

It's not very likely to encourage people to help you if you admit you
haven't read the documentation.

What exactly are you trying to do here? You instantiate a form from an
instance, and immediately try and save it, without even passing in values
from the POST. Why? In any case, the error is that forms don't have a
cleaned_data attribute until you call is_valid() on them, which the
documentation does clearly state. The documentation also shows the correct
pattern for using forms in views, so I don't know why you haven't used that.

(Not related to your problem, but the template path in your call to
render_to_response won't work: you should pass a path that is relative to
one of the paths in settings.TEMPLATE_DIRS.)
--
DR.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » simplest for example, Error object has no attribute 'cleaned_data' [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support