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 8437539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:27:34+00:00 2026-06-10T07:27:34+00:00

I have a view which validates data from a form which just has some

  • 0

I have a view which validates data from a form which just has some basic information about an item. I’m confused with how the is_valid method works here even after reading
this . If the user doesn’t input some of the required fields like name or image 1, I want them to see the error on the page “this field is required” or something of that nature. I thought if the form.is_valid returned False, these messages would automatically be raised on the page for the user. Or do I need to specify what error message for each field somewhere that I would want the user see?

    #view
            def sell(request):
                if request.method == "POST":
                    form = AddItem(request.POST, request.FILES)
                    if form.is_valid():
                        item = form.save(commit=False)
                        item.user = request.user
                        item.is_active = True
                        item.slug = slugify(item.name)
                        item.save()
                        return HttpResponseRedirect('thanks.html')  
                else:
                    form = AddItem()
                    return render_to_response('forsale.html', locals(), context_instance=RequestContext(request))

    #form    
        class AddItem(forms.ModelForm):
            name = forms.CharField(label="Title")


            class Meta:
                model = Item
                exclude = ('user','slug','is_active',)

#model

class Item(models.Model):
    user = models.ForeignKey(User)
    name = models.CharField(max_length=75)
    slug = models.SlugField(max_length=50, unique=True)
    is_active = models.BooleanField(default=True, blank=True)
    image1 =  models.ImageField(upload_to='img')
    image2 =  models.ImageField(upload_to='img', blank=True)
    image3 =  models.ImageField(upload_to='img', blank=True)
    image_caption1 = models.CharField(max_length=200, blank=True)
    image_caption2 = models.CharField(max_length=200, blank=True)
    image_caption3 = models.CharField(max_length=200, blank=True)
    price = models.DecimalField(max_digits=8, decimal_places=2)
    quantity = models.IntegerField(default=1)
    description = models.TextField()
    created = models.DateTimeField(auto_now_add=True)
    shipping_price = models.DecimalField(decimal_places=2, max_digits=6)
    categories = models.ManyToManyField(Category)
  • 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-06-10T07:27:35+00:00Added an answer on June 10, 2026 at 7:27 am

    You need to extract the errors from the form object using form.errors then deal with the dict however you want. If you’re using ajax, simply send the dict as json back over and use javascript to handle it. If it was a direct html form submit, then you need to render and respond with a page with the errors in the passed dictionary and deal with the passed error in the template (usually with an {% if errors %} tag

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

Sidebar

Related Questions

I have a view which has two labels. When I swipe left I fill
I have 5 view which have deferent json data , in all my 5
I am trying to use a textarea form entry which I have some javascript
I have view on which I defined a custom tagName. I need to be
i have view controller which contains a button which show the image library ,if
I have a view which I would like to fill up the entire screen
I have a view which is composed of top, left and bottom headers and
I have a view which was working fine when I was joining my main
I have a view which I built in Interface builder with a tableview and
I have a view with two subviews: A UIImageView A small Custom View which

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.