VIEWS
from django.shortcuts import render
from django.views.generic import(ListView, CreateView)
from models import UserProfileInfo
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.models import User
from forms import UserForm
# Create your views here.
class UserCreateView(CreateView):
template_name = "message_app/post_list.html"
form_class = UserForm
model = UserProfileInfo
FORMS
from django import forms
from models import UserProfileInfo
class UserForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
class Meta():
model = UserProfileInfo
fields = "__all__"
POST_LIST.html
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1>Please Sign Up</h1>
<form method="post ">
{{ form.as_p }}
{% csrf_token %}
<input type="submit" value="SignUp">
</form>
<a href="{% url 'admin:index' %}">Admin</a>
</body>
</html>
When I go inside my admin site I can't see an of this information saved
Isn't the create class view already supposed to automatically save it or am I missing something
CodePudding user response:
Make sure in your urls.py, your path is like this
path('', UserCreateView.as_view())
CodePudding user response:
I had to change a small space in
<form method="post " >
<form method="post" >