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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:51:45+00:00 2026-05-15T08:51:45+00:00

I have a simple view in which I’m saving a form. The code seems

  • 0

I have a simple view in which I’m saving a form. The code seems ‘clean’, but I can’t get rid of the error:

"The view didn’t return an HttpResponse object."

Though I’ve searched on the web, I did not find a relevant indication.

def classroom_privacy(request,classname):
         theclass = Classroom.objects.get(classname=classname)
     if request.method == 'POST':  
       form = PrivacyClass(request.POST)
       if form.is_valid():
           new_obj = form.save(commit=False)
           new_obj.save()
           return HttpResponseRedirect('.')    
       else:
           form = PrivacyClass()     
       return render_to_response('classroom/classroom_privacy.html', {'form': form}, 
          context_instance=RequestContext(request))
  • 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-15T08:51:46+00:00Added an answer on May 15, 2026 at 8:51 am

    verify the indentation of your code

    def classroom_privacy(request, classname):
        theclass = Classroom.objects.get(classname=classname)
        if request.method == 'POST':
            form = PrivacyClass(request.POST)
            if form.is_valid():
                new_obj = form.save(commit=False)
                new_obj.save()
                return HttpResponseRedirect('.') 
        else:
            form = PrivacyClass()  
    
        return render_to_response('classroom/classroom_privacy.html', {'form': form}, context_instance=RequestContext(request))
    

    if it is get request, render a unbound form

    if it is post request and invalid form render a bound form

    if it is post request and valid form redirect the page

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

Sidebar

Related Questions

I have a simple view, but can't get it to do what it's supposed
I have a simple form on a view page, implemented as a user control,
I have a simple table view which is editable. All I need the user
I have a simple view in which I am trying to access the Model
I have a simple ASP.Net MVC View which contains an FCKeditor text box (created
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
I have a navigation view with a cell that has something as simple as
I have a simple view function that's designed to allow the user to choose
I have a simple View and I wish to add a JQuery DatePicker JavaScript
I have a simple view defined MSSQL 2008. The view is defined as follows:

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.