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

  • SEARCH
  • Home
  • 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 7041247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:00:58+00:00 2026-05-28T02:00:58+00:00

My form is like this class SubmitForm(forms.Form): title = forms.CharField(max_length=100) story = forms.CharField(max_length=3000) #

  • 0

My form is like this

class SubmitForm(forms.Form):
    title = forms.CharField(max_length=100)
    story = forms.CharField(max_length=3000)
    # lat = forms.DecimalField(max_digits=25, decimal_places=20)
    # lng = forms.DecimalField(max_digits=25, decimal_places=20)

    def clean_title(self):  
        if len(self.cleaned_data['title']) < 4:
            raise forms.ValidationError("Enter your full title")


    def clean_story(self):
        if len(self.cleaned_data['story']) < 4:
            raise forms.ValidationError("Enter your full story")

    def clean(self):
        cleaned_data = self.cleaned_data
        return cleaned_data

The view is like this

def test(request):
ctxt = {}
if request.method == 'POST':
        form = SubmitForm(request.POST) # A form bound to the POST data 
        if form.is_valid():
            lat1 = -48.543543543
            lng1 = 34.543543543
            # title1 = form.cleaned_data['title']
            titlepost = form.cleaned_data['title']
            ctxt = {'titlehere':titlepost}
            catid = "test1234"
            cat = Category(category=catid)
            cat.full_clean()
            cat.save()
            marker = Marker(lat=lat1, lng=lng1,category=cat, title=titlepost)
            marker.full_clean()
            marker.save()
            return render_to_response('home.html', ctxt, context_instance=RequestContext(request))          

        else:
            return render_to_response('test.html', ctxt, context_instance=RequestContext(request))          
else:
        now = datetime.datetime.now()
        form = SubmitForm()
        latest_marks = Marker.objects.all().order_by('-submitted')[0:10]
        ctxt = {
        'marks':latest_marks,
        'now':now.date(),
        'form': form,
        }

        return render_to_response('test.html', ctxt, context_instance=RequestContext(request))

Ive tried all that I can think of but i still get different error messages.

With this code I get one that says

Exception Value: locations_marker.title may not be NULL

Any suggestions of what I should do. I just want to have a form on a page that when it is submitted a new object is created in the database. I’ve been messing around the entire day and cant figure it out.

  • 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-28T02:00:59+00:00Added an answer on May 28, 2026 at 2:00 am

    Your clean_title and clean_story need to return the clean value regardless of whether you’ve changed it or not.

    class SubmitForm(forms.Form):
        title = forms.CharField(max_length=100)
        story = forms.CharField(max_length=3000)
        # lat = forms.DecimalField(max_digits=25, decimal_places=20)
        # lng = forms.DecimalField(max_digits=25, decimal_places=20)
    
        def clean_title(self):  
            if len(self.cleaned_data['title']) < 4:
                raise forms.ValidationError("Enter your full title")
            # Always return the cleaned data
            return self.cleaned_data['title']
    
    
        def clean_story(self):
            if len(self.cleaned_data['story']) < 4:
                raise forms.ValidationError("Enter your full story")
            # Always return the cleaned data
            return self.cleaned_data['story']
    
        def clean(self):
            cleaned_data = self.cleaned_data
            return cleaned_data
    

    Here are the relevant Django docs: https://docs.djangoproject.com/en/1.3/ref/forms/validation/#cleaning-a-specific-field-attribute

    • 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
If I have two models like class Author(models.Model): name = models.CharField(max_length=100) title = models.CharField(max_length=3,
Given an example like this: class MyForm(forms.Form): name = forms.CharField() I'm trying to grasp
I created a form for login, just like this: class LoginForm(AuthenticationForm): username = forms.CharField
I have a simple form that looks like this: class SettingsForm(forms.ModelForm): theme = forms.CharField(required=True,
I have a Django my_forms.py like this: class CarSearchForm(forms.Form): # lots of fields like
I've got a form like this: class SomeForm(forms.Form): first = forms.IntegerField(max_value= DontWantToSetYet) second =
I have a form looking like this: class MarketingActionForm(forms.ModelForm): contact = ManyToManyByLetter(Contact, field_name=first_name) #contact
I've got a bit of Django form code that looks like this: class GalleryAdminForm(forms.ModelForm):
I have a form like this: class MyForm(forms.Form): [...] which is rendered in my

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.