Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6887053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:50:14+00:00 2026-05-27T05:50:14+00:00

I have this form: class CollaboratorForm(forms.Form): user = forms.CharField(label=Username,max_length=100) canvas = forms.IntegerField(widget=forms.HiddenInput) …. def

  • 0

I have this form:

class CollaboratorForm(forms.Form):
    user = forms.CharField(label="Username",max_length=100)
    canvas = forms.IntegerField(widget=forms.HiddenInput)
    ....
    def clean_user(self):
        user = self.cleaned_data['user']
        canvas = self.cleaned_data['canvas']

In the view I’m simply calling

if form.is_valid():

I get the error:

KeyError at /canvas/1/add-collaborator/
'canvas'

According to firebug the value is posting, it’s just doesn’t seem to be making it to my clean function. Am I doing it wrong?

EDIT: Post data

canvas  1
csrfmiddlewaretoken 2cb73be791b32ca9a41566082c804312
user    username

EDIT2: I would also be willing to take an answer that could tell me how to send the primary key to the clean_user function, where the primary key is the /1/ in the example url above. The function in the view that is called is:

def canvas_add_collaborator(request, pk):

So I would want to send the pk to the clean_user function which would solve my problem by not needing the hidden field.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:50:14+00:00Added an answer on May 27, 2026 at 5:50 am

    You need to change the method name to clean(), not clean_user(). ‘canvas’ is not in the cleaned_data if you are just validating the user field.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that looks like this: class SampleForm(forms.Form): text = forms.CharField(max_length=100) In
Say I have this simple form: class ContactForm(forms.Form): first_name = forms.CharField(required=True) last_name = forms.CharField(required=True)
I have a simple Django form: class CommentForm(forms.Form): comment = forms.CharField(max_length=2000, required=True) post_id =
I have a Django my_forms.py like this: class CarSearchForm(forms.Form): # lots of fields like
I have this form class : class MyForm(forms.Form): def __init__(self, *args, **kwargs): self.notvalidate =
I Have this Form class MyModelForm(forms.ModelForm): boolfield = forms.TypedChoiceField(coerce=bool, choices=((False, 'No'), (True, 'Yes')), widget=forms.RadioSelect
I have this simple Post model: class Post(models.Model): title = models.CharField(_('title'), max_length=60, blank=True, null=True)
Let's say I have this form: class SimpleUploadForm(forms.Form): file = forms.FileField() I have this
..whatdoyoucallitanyway.. I have this model: class Kaart(models.Model): name = models.CharField(max_length=200, name=Kaardi peakiri, help_text=Sisesta kaardi
I have this simple form: class PagoDesde(forms.Form): from django import forms as f desde

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.