please I have a problem concerning Gjango programming. I want to recover data from django forms to use it in views.py but i recieved an error : inconsistent use of tabs and spaces in indentation (views.py, line 21). i tried to use cleaned_data or request.POST i always find the same Error, here is my source code: models.py
from django.db import models
# Create your models here.
class Personne(models.Model):
nom=models.CharField(max_length=200)
prenom=models.CharField(max_length=200)
def __unicode__(self):
return self.nom
def __str__(self):
return self.nom
forms.py
from django import forms
from application1.models import Personne
class PersonneForm(forms.ModelForm):
class Meta:
model=Personne
#fields = '__all__'
fields=('nom','prenom')
views.py
from django.shortcuts import render
from django.http import HttpResponseRedirect
from application1.forms import PersonneForm
def get_name(request):
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the request:
form = PersonneForm(request.POST)
# check whether it's valid:
if form.is_valid():
# process the data in form.cleaned_data as required
# ...
# redirect to a new URL:
#I want to recover data here i tried to use cleaned_data or request.POST and i find the same error
nom = form.cleaned_data['nom']
nom=request.POST['nom']
form.save()
# if a GET (or any other method) we'll create a blank form
else:
form = PersonneForm()
return render(request, 'name.html', {'form': form})
Thank you for the help