我已经使用django内置管理系统创建了一个登录页面,我想在同一页面上添加注册表单,请帮助
我已经在Google上搜索了所有内容,但没有成功
我的urls.py
from django.contrib import admin
from django.urls import path,include
from django.contrib.auth import views as auth_views
from user import views
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('user.urls')),
path('accounts/login/',auth_views.LoginView.as_view(),
{'template_name':'user/template/login.html'},name='login'),
path('logout/',auth_views.LogoutView.as_view(),name='logout'),
]
我的views.py
class HomeView(TemplateView):
template_name = 'home.html'
def signup(request):
if request.method == 'POST':
form1 = SignUpForm(request.POST)
if form1.is_valid():
form1.save()
username = form1.cleaned_data.get('username')
raw_password = form1.cleaned_data.get('password1')
user = authenticate(username=username,
password=raw_password)
login(request, user)
return redirect('home')
else:
form1 = SignUpForm()
return render(request, 'registration/login.html', {'form1': form1})
现在我想将此form1发送到login.html,并同时显示登录表单和注册表单