Hi,

I'm having problems with newforms.

my views.py:

--------
from django import newforms as forms
from newforms.ksiazka.models import Entry,Author
from django.shortcuts import HttpResponse, render_to_response
from django.newforms import form_for_model



def add_entry(request):
   EntryForm = form_for_model(Entry)
   if request.method == "POST":
       form = EntryForm(request.POST)
       if form.is_valid():
           print "form is valid"
           e = Entry(**form.clean_data)
           e.save()
           #tried form.create() instead of 2 above - the same error.
           return HttpResponse("Dodano prawie")
       else:
           context = {'form': form, 'error_msg': "Please correct the
error(s) below"}
   else:
       context = {'form': EntryForm()}
   return render_to_response('entry_form.html', context)

my models.py:
-----------------------------------------

from django.db import models

class Author(models.Model):
   name = models.CharField(blank=False, maxlength="30")

   class Admin:
       pass
   def __str__(self):
       return self.name

class Entry(models.Model):
   author = models.ForeignKey(Author)
   when = models.DateField(blank=False)
   title = models.CharField(blank=False, maxlength="10")
   content = models.TextField(blank=True, null=True)

   class Admin:
       pass

   def __str__(self):
       return self.title

I'm getting:
Invalid value: 'author' should be a <class
'newforms.book.models.Author'> instance, not a <type 'unicode'> error
message when submitting the form.

Thanks,
Robert


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to