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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:56:57+00:00 2026-05-25T16:56:57+00:00

I am going mad trying to figure this problem out. I have a form

  • 0

I am going mad trying to figure this problem out. I have a form which has multiple models. Basically someone writes a story and then puts their username in and this username is associated with that story. It’s all pretty basic…apparently not for django. Aside from searching for hours to find something that helps with what are essentially multiple SQL inserts it seems to be impossible. I get the error failed to return HTTPResponseOBject even though I’ve verified the indentation.

Here is my view:

def submit_story(request):
    if request.method == 'POST':
        f = request.POST.copy()
        sdata = {
            'author': f['username']
            }
        a = AuthorForm()
        p = StoryForm(sdata)
        if a.is_valid():
            a.save()
            if p.is_valid():
                p.save()
                return HttpResponseRedirect('/thanks/')

Here are my models:

class Author(models.Model):
    username = models.CharField(max_length=120, unique="True")
    email = models.EmailField()
    firstname = models.CharField(max_length=500)
    lastname = models.CharField(max_length=500)

class Story(models.Model):
    title = models.CharField(max_length=1000)
    text = models.CharField(max_length=5000)
    date = models.DateField()
    likes = models.IntegerField()
    dislikes = models.IntegerField()
    views = models.IntegerField()
    author = models.ForeignKey('Author')

Thanks in advance. I changed to django from PHP thinking this would be simpler but this multiple form submission is just plain irritating.

  • 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-25T16:56:58+00:00Added an answer on May 25, 2026 at 4:56 pm

    This has nothing to do with multiple models or inserts. The issue should be obvious: you have a set of nested if statements, and only one return right at the most deeply nested bit. What happens if it’s not a POST, or if form a is not valid, or form p is not valid? Django expects a view to return a response in all circumstances, so you need a return no matter what happens.

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

Sidebar

Related Questions

I have been going mad trying to figure out why my scripts weren't working,
Im going mad trying to figure out why the title link (in the left)
I'm going slidely mad over here, maybe someone can help me figure out what's
I was wondering if someone could work this one out as I've been trying
i am going mad with this problem now - if u goto http://talll.com and
I'm going mad with the following problem which does not happen on any other
I'm going mad on this stupid problem. I've a tree like this: src |---
I'm going mad with, probably, a stupid problem. I have 3 strings: year, month
Sorry, but I think I am going mad. I have this in C++: std::stringstream
This problem has driven me mad for over a day now. I can create

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.