Thursday, April 1, 2021

Please help me ? forms are not stored in database

#Model
Form Django import models
Class singupdata(models.model):
     Username=models.CharField(max_len=20)
     Password=models.CharField(max_len=20)
#form
from django import forms
Class Signform (forms.form):
      Username=forms.IntegerFiled(
                     labe='E mail',
                    Widget=forms.Textinput(
                   attr={
                          'class':'form-control',
                          'placeholder':'username'
                   }
              )
           )
       
Password=forms.EmailField(
                     labe='Password',
                    Widget=forms.EmailInput(
                   attr={
                          'class':'form-control',
                          'placeholder':'E-mail'
                   }
              )
           )


#views
from .fomrs import Signform
from app.models import signudata
Def Signup(request):
        If request.method=='POST':
       sform=Signform (request.post)
      If sform.is_valid():
       username=request.POST.get(Username,' ')
       password=request.POST.get(Password,' ')
       data =Signudata (
                   Uname=username,
                  Pwd =password,
      )
     data.save
   sform =Signform ()
   return render (request,sign.html,{'sform':sform}
#sign.html
<form method='post'>
    {% csrf_token%}
    {{ sform}}
<input type='submit' value='submit'>
</form>
 

    
Mahendra Yadav

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAN-6G3y9xAasDRhgGdAPxyK4XYOegLCienE6b3Yxv4pqo3FBWg%40mail.gmail.com.

No comments:

Post a Comment