问题:使用django-registration-redux无法进入注册页面。
问腿描述:我是按照django-registration-redux文档进行配置的,代码如下:
1,注册到settings.py中的INSTALLED_APPS:
INSTALLED_APPS = [
...
'registration', # should be immediately above 'django.contrib.admin'
'django.contrib.admin',
...
]
2,在项目urls.py中导入URL:
urlpatterns = [
...
path('accounts/', include('registration.backends.simple.urls')),
path('admin/', admin.site.urls),
...
]
3,migrate迁移数据:
PS F:\PythonProjects\web\projects\meet> python manage.py makemigrations
No changes detected
PS F:\PythonProjects\web\projects\meet> python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, interview, schedule, registration, sessions
Running migrations:
Applying registration.0001_initial... OK
Applying registration.0002_registrationprofile_activated... OK
Applying registration.0003_migrate_activatedstatus... OK
Applying registration.0004_supervisedregistrationprofile... OK
Applying registration.0005_activation_key_sha256... OK
4,运行开发服务器,访问http://127.0.0.1:8000/accounts/register/,结果页面跳转到http://127.0.0.1:8000/accounts/profile/,页面显示以及控制台显示如下:
[08/Nov/2021 22:43:14] "GET /accounts/register/ HTTP/1.1" 302 0
Not Found: /accounts/profile/
[08/Nov/2021 22:43:14] "GET /accounts/profile/ HTTP/1.1" 404 5872
尝试过的解决方法:
1,确认是否使用流程有误:无,以上四步是按照插件的官方文档一步一步执行的,检查无误。
2,从控制台302状态码可知,404页面是从/accounts/register/ 重定向来的。查看了源码,如果像我这样没有额外的配置什么东西的话,访问/accounts/register/会执行类视图RegistrationView,其中代码显示注册失败时会重定向到name='registration_disallowed'的url,我又顺着simple.urls.py找了一下,是会跳转到“Sorry, but registration is closed at this moment. Come back later.”页面才对啊。所以是没解决了。
3,在stackoverflow上找了一下也没什么头绪。
请用过这插件的铁铁帮帮忙,非常感谢