“Formas django” Respostas de código

Passando a instância do usuário Django Formulário Submissão

if form.is_valid():
    post = form.save(commit=False)
    post.author = request.user
    post.published_date = timezone.now()
    post.save()
Bored Bison

Exemplo de forma de django

from django import forms

# creating a form
class SampleForm(forms.Form):
	name = forms.CharField()
	description = forms.CharField()
Unsightly Unicorn

Django Obtenha o ID do formulário da solicitação

# html
<input type="submit" value="Reply" name ="message_frm">

# views.py
if 'message_frm' in request.POST:
    #do somethings 
Repulsive Raven

formas django

from django import forms
        
class FormName(forms.Form):
         # each field would be mapped as an input field in HTML
        field_name = forms.Field(**options)
vip_codes

Formas django

from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User


# Create your forms here.
class NameForm(forms.Form):
    your_name = forms.CharField(label='Your name', max_length=100)
OHIOLee

Respostas semelhantes a “Formas django”

Perguntas semelhantes a “Formas django”

Procure respostas de código populares por idioma

Procurar outros idiomas de código