I have a page set up where a user can submit data, they write the data
into the text field and press submit but i keep getting this error

Traceback:
File "c:\Python26\lib\site-packages\django\core\handlers\base.py" in
get_response
  92.                 response = callback(request, *callback_args,
**callback_kwargs)
File "c:\Python26\lib\site-packages\django\contrib\auth\decorators.py"
in __call__
  78.             return self.view_func(request, *args, **kwargs)
File "c:\django\views.py" in add_stuff
  173.             new_stuff = form.save()
File "c:\django\models.py" in save
  164.         return
Stuff.objects.create(title=self.cleaned_data['title'],

Exception Type: KeyError at /add_stuff/
Exception Value: title

here is my models.py code
########
class Stuff(models.Model):
    title = models.CharField(max_length=255)
    author = models.ForeignKey(User)
    description = models.TextField()
    pub_date = models.DateTimeField(editable=False)
    updated_date = models.DateTimeField(editable=False)

class Meta:
    ordering = ['-pub_date']

class Admin:
    pass

def __unicode__(self):
    return self.title

def save(self):
    if not self.id:
        self.pub_date = datetime.datetime.now()
        self.updated_date = datetime.datetime.now()
        super(Stuff, self).save()

def get_absolute_url(self):
    return ('links.html', (), { 'object_id': self.id })
get_absolute_url = models.permalink(get_absolute_url)



class AddStuffForm(forms.Form):
    def __init__(self, author, *args, **kwargs):
        super(AddStuffForm, self).__init__(*args, **kwargs)
        self.author = author

        title = forms.CharField(max_length=255)
        description = forms.CharField(widget=forms.Textarea())

    def save(self):
        return Stuff.objects.create(title=self.cleaned_data['title'],
 
description=self.cleaned_data['description'])

here is my views.py code
########
def add_stuff(request):
    if request.method == 'POST':
        form = AddStuffForm(author=request.user, data=request.POST)
        if form.is_valid():
            new_stuff = form.save()
            return HttpResponseRedirect(new_stuff.get_absolute_url())
    else:
        form = AddStuffForm(author=request.user)
    return render_to_response('add_stuff.html',
                               { 'form': form })
add_stuff = login_required(add_stuff)


I have never seen this error before!

Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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