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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:27:55+00:00 2026-06-08T23:27:55+00:00

I try to apply the django poll application to my own application (an IMC

  • 0

I try to apply the django poll application to my own application (an IMC calculator) to improve and build a little project for my first step in python/django.

I try to save the data of my first form that is on accueil.html:

<form action="" method="post">
  <table>
    {{ form.as_table }}
  </table>

 <input type ="submit" value="Submit">
</form>

Here is my forms.py:

from django import forms

class IndividuDataForm(forms.Form):
    nom = forms.CharField(max_length=100)
    prenom = forms.CharField(max_length= 100)
    anniversaire = forms.DateField()
    taille = forms.IntegerField()
    poids = forms.IntegerField()

Here is my models.py:

from django.db import models

from django.forms import ModelForm

class Individu(models.Model):

    nom = models.CharField(max_length=100)
    prenom = models.CharField(max_length= 100)
    anniversaire = models.DateField()
    taille = models.IntegerField()
    poids = models.IntegerField()

    def __unicode__(self):

       return self.nom

class ImcResultat(models.Model):

    individu = models.ManyToManyField(Individu)

    imc = models.IntegerField()

    date_imc = models.DateField()

class IndividuForm(ModelForm):

    class Meta:

        model = Individu


class ImcResultatForm(ModelForm):

    class Meta:

        model = ImcResultat

And finally my *views.py* is here:
the problem is at the line 13 * a = cd.create() * when I try to save the data from the form to the database.

from django.shortcuts import render_to_response
from django.http import HttpResponse, HttpResponseRedirect
from models import Individu, ImcResultat
from forms import IndividuDataForm

def accueil(request):

    if request.method == 'POST':

        form = IndividuDataForm(request.POST)

        if form.is_valid():

            cd = form.cleaned_data

            a = cd.create() **#this is the problem**

            return HttpResponseRedirect('/accueil/page2/')

    else:

        form = IndividuDataForm()

        return render_to_response('accueil.html', {'form':form})





def page2(request):



    return render_to_response('page2.html')

i guess it is on the first part of the views.py that my function do not work well, it does not save the form in the database.
def accueil(request):

if request.method == 'POST':

    form = IndividuDataForm(request.POST)

    if form.is_valid():

        cd = form.cleaned_data

        a = cd.create() **#this is the problem**

        return HttpResponseRedirect('/accueil/page2/')

after checking if the form is valid, I clean the data in the form then try to save it.
and I got this error:

Exception Type: AttributeError 
Exception Value: 'dict' object has no attribute 'create'

I guess it is from a dictionnary but never in my code i use { } for dictionnary list.
So I have no idea and stuck in the process of learning.

Thanks for your help and I hope from my first stackoverflow post I didn’t made too many mistakes.

  • 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-08T23:27:56+00:00Added an answer on June 8, 2026 at 11:27 pm

    You should use a ModelForm, which will define the fields automatically to match those on the model. Then you can call form.save() to create the instance directly from the form.

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

Sidebar

Related Questions

I try to apply image filters using python's PIL . The code is straight
Whenever i try to apply my own constructor instead of the default one in
This particular example relates to Django in Python, but should apply to any language
I'm new to Django and for my first project I'm building a portfolio. And
I just started a project to try and get a very simple Django Celery
if i try to apply multiple background images, works great: .selector{ background-image: url(image1.png), url(image2.pnng);
I have download and install the jQuery UI 1.8.17 and I try to apply
So I try to apply an image but cannot see any changes... What do
I always try to apply the S.O.L.I.D principles and I really like the Qt
I'm trying to do a django-south migration to an existing application to add django-audit-log

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.