i am trying to save the basic information about a person
i have created a model form for it but i am unable to save the object (unable to update the database)
here is my views file
@login_required
def dashboard(request):
if request.method=="post":
form = linkform(request.POST)
if form.is_valid():
try:
notes = form.cleaned_data['note']
link = form.cleaned_data['link']
number = form.cleaned_data['number']
perso = person.object.create_person(notes,link,number)
perso.save()
return HttpResponse('succeess')
except:
return HttpResponse('can not create object')
else:
return HttpResponse('bad form')
else:
form = linkform(request.POST)
return render(request, 'dashboard.html', {'form':form})
here is my model file :
class personmanager(models.Manager):
def create_person(self,note,link,number):
pers = self.create(note=note,link=link,number=number)
return pers
class person(models.Model):
notes = models.TextField()
link = models.URLField()
number = models.IntegerField()
object = personmanager()