Hello

I am new to django and try to use the ModelForm paradigma, but can't get the 
point ;-((


My example:

models.py:
class Project(models.Model):
     id = models.AutoField(primary_key=True)
     deletetime = models.DateTimeField()
     name = models.CharField(max_length=50)
     beginDate = models.DateField()
     endDate = models.DateField()
     memo = models.TextField()

Doing:
project = Project()
project.save()
works fine (autofield increased, other fields empty)


forms.py:
class ProjectForm(ModelForm):
     class Meta:
         model = models.Project


- first try for empty record, expecting an empty Project-object to be created
from the form automatically:
projectForm = forms.ProjectForm()
projectForm.save()
=> result: 'ProjectForm' object has no attribute 'cleaned_data'

- second try for empty record by providing an empty Project-instance:
project = Project()
projectForm = forms.ProjectForm(instance=project)
projectForm.save()
=> result: 'ProjectForm' object has no attribute 'cleaned_data'

The _errors and errors attribute are present, but empty: {}


- first try to save an existing unmodified record:
project = Project.objects.get(id=1)
projectForm = forms.ProjectForm(instance=project)
project = projectForm.save()
=> result: 'ProjectForm' object has no attribute 'cleaned_data'

- second try to save an existing record with data from request.POST:
project = Project.objects.get(id=1)
projectForm = forms.ProjectForm(request.POST, instance=project)
project = projectForm.save()
The content of request.POST:
<QueryDict: {u'endDate': [u''], u'name': [u'Maissau'], u'memo': [u'aaa'], u'id':
[u'1'], u'savebutton': [u'savebutton'], u'beginDate': [u'2009-10-11']}>
=> result: The Project could not be changed because the data didn't validate.



Can anybody point me the right direction?


Thanks in advance
gerhard


-- 
O(ettl) GER(hard)

--~--~---------~--~----~------------~-------~--~----~
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 at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to