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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:16:23+00:00 2026-06-04T20:16:23+00:00

New to Django and I have exhausted every forum and tutorial I can and

  • 0

New to Django and I have exhausted every forum and tutorial I can and I am still having problems getting my form data to the database. I have a simple model that consists of a name and an email field that I will eventually reference in the program. I can load different pages after clicking submit, but my data will not post to the database. I have tried everything I can think of, so my code is probably jacked at this point, but in the current iteration this is what I have:

#models.py
    from django.db import models
from django.forms import ModelForm

class Patron(models.Model):
    name = models.CharField(max_length=200)
    email = models.EmailField(max_length=75)


    def _unicode_(self):
        return self.name

class PatronForm(ModelForm):
    class Meta:
        model = Patron

#view.py

from django.shortcuts import render_to_response, get_object_or_404
from patrons.models import Patron 
from django.template import RequestContext
from django.core.context_processors import csrf
from django.core.urlresolvers import reverse
from django.forms import ModelForm


def index(request):
    if request.method == 'POST':
        post = request.POST
        name = post['name']
        email = post['email']
        f = PatronForm(request.Post)
        new_patron = f.save()
    return render_to_response('patrons/index.html',
                               context_instance=RequestContext(request))

#html
 <body>
    <h1>/Picture Taker/</h1>



    <form aciton="." name="patron" method="post" >
    {% csrf_token %}

        <label>
            <div>name</div> <input type="text" name="name" id="name" value="{{name}}">
        </label>
        <label>
            <div>email</div> <input type="text" name="email" id="email" value="{{email}}">
        </label>

        <div class="error">{{error}}</div>
        <input type="submit" value="Submit">
    </form>

</body>

Any help would be greatly appreciated

  • 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-04T20:16:24+00:00Added an answer on June 4, 2026 at 8:16 pm

    All of

    post = request.POST
    name = post['name']
    email = post['email']
    f = PatronForm(request.Post)
    new_patron = f.save()
    

    can be re-written as (note the case of request.POST):

    f = PatronForm(request.POST)
    new_patron = f.save()
    

    but you should be checking for errors in the form before saving, so:

    f = PatronForm(request.POST)
    if f.is_valid():
        new_patron = f.save()
    

    You also have a typo in your form tag, it should be “action”, not “aciton”. The {{ error }} you have in your template doesn’t refer to anything present in your view. While debugging, it might be helpful to let the form render itself, like:

    {{ form.as_p }}
    

    so you can see any errors in the form submission.

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

Sidebar

Related Questions

I have an existing PostgreSQL database that I'm using for a new Django site.
I'm new to Django, trying to process some forms. I have this form for
I'm new to Django and have only been using sqlite3 as a database engine
I am new to Django I have a MySQL database - which I want
I'm still relatively new to Django and have just started poking around at Django-CMS,
I'm new to Django and I have some problems to gasp how to deal
Hi I am still new to Django and have not worked with Ajax before.
Everybody have to change the settings.py file every time you start a new django
I am rather new to django templates and have an impression that I have
I'm new to Django but I seem to have nearly identical code working on

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.