Skip to content

Instantly share code, notes, and snippets.

@eclecticmiraclecat
Last active November 4, 2020 13:01
Show Gist options
  • Save eclecticmiraclecat/472fd64723aa4d19010abde1eba4d0b6 to your computer and use it in GitHub Desktop.
Save eclecticmiraclecat/472fd64723aa4d19010abde1eba4d0b6 to your computer and use it in GitHub Desktop.
# forms.py
from django import forms

class UserRegistrationForm(forms.Form):
  firstName = forms.CharField()
  lastName = forms.CharField()
  email = forms.CharField()
# views.py
from .forms import UserRegistrationForm

def display(request):
  form = UserRegistrationForm()
  return render(request, 'firstApp/index.html', {'form': form})
<!-- index.html -->
<form method="post">
  {{ form.as_p }}
  {% csrf_token %}
  <input type="submit" value="Submit">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment