• 坐看云起时
    2021-04-17
    我的 Django 版本 3.1.7,跟着视频做的时候遇到这些问题并解决,仅供参考: 1. 在 第一次 访问 /accounts/register/ 时(还没配置 LOGIN_REDIRECT_URL 和 SIMPLE_BACKEND_REDIRECT_URL),需要确保没有任何用户登录。如果有,请先注销;否则,就不会显示注册页面,而是出错,原因是会自动跳转到 http://127.0.0.1:8002/accounts/profile/,显然我们还没 这个 /accounts/profile/ 页面。 2. 执行 ./manage.py migrate 会有一个警告: WARNINGS: ?: (2_0.W001) Your URL pattern '^accounts/' has a route that contains '(?P<', begins with a '^', or ends with a '$'. This was likely an oversight when migrating to django.urls.path(). 原因是视频中的 url 用法已经被 deprecated,需要换成 re_path。 我看了 作者的 https://gitee.com 里面的 代码,实际是已经 更新为 re_path了,大家可以去参考 https://gitee.com/geektime-geekbang/django/blob/master/recruitment/urls.py#L72, 避免上述警告。
    展开

    作者回复: 感谢分享总结

    
    5
  • 任宇鹏
    2022-04-18
    老师我这儿一直提示 No module named 'registrationdjango' 改如何解决

    作者回复: 两个拼写连在一起了,检查一下拼写对吗

    共 2 条评论
    
  • sanpang228
    2022-03-22
    请问,如果想替换Registration现有的template,该如何替换?

    作者回复: 找一下registration的源码,修改了重新打包安装到本地或者服务器上

    
    
  • 溪知源
    2021-03-10
    django3.0 django-registration-redux 2.9 注册后 登陆功能还需要到管理后台 人员个人信息详情里 的权限下 点一下有效按钮 才能登陆成功 你们的也是这样么

    作者回复: 注册的是普通用户。管理后台标记后才可以登录管理后台

    共 2 条评论
    
  • Eric Ren
    2020-12-08
    吕老师你好, 我也遇到了留言里面同样的问题,困扰了好几天也没能解决,我错误提示是没有base.html去render。 希望能帮助解答一下,谢谢 : ) 在地址 http://127.0.0.1:8000/accounts/ 跳出提示 Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/accounts/ Using the URLconf defined in recruitment.urls, Django tried these URL patterns, in this order: [name='joblist'] job/<int:pk>/ [name='jobdetail'] newjoblist/ [name='newjoblist'] new_job_detail/<int:pk>/ [name='new_job_detail'] grappelli/ admin/ accounts/ ^register/closed/$ [name='registration_disallowed'] accounts/ ^register/$ [name='registration_register'] accounts/ ^login/$ [name='auth_login'] accounts/ ^logout/$ [name='auth_logout'] accounts/ ^password/change/$ [name='auth_password_change'] ...... The current path, accounts/, didn't match any of these. 但是进入上面list里面给出的地址 比如 http://127.0.0.1:8000/accounts/register/ 显示如下 TemplateDoesNotExist at /accounts/register/ base.html Request Method: GET Request URL: http://127.0.0.1:8000/accounts/register/ Django Version: 3.1.2 Exception Type: TemplateDoesNotExist Exception Value: base.html Exception Location: G:\Anaconda3\envs\MyDjangoEnv\lib\site-packages\django\template\backends\django.py, line 84, in reraise Python Executable: G:\Anaconda3\envs\MyDjangoEnv\python.exe Python Version: 3.8.5 Python Path: ['C:\\Users\\renxi\\github\\django-prac-project\\Geekbang\\recruitment', 'G:\\Anaconda3\\envs\\MyDjangoEnv\\python38.zip', 'G:\\Anaconda3\\envs\\MyDjangoEnv\\DLLs', 'G:\\Anaconda3\\envs\\MyDjangoEnv\\lib', 'G:\\Anaconda3\\envs\\MyDjangoEnv', 'G:\\Anaconda3\\envs\\MyDjangoEnv\\lib\\site-packages', 'G:\\Anaconda3\\envs\\MyDjangoEnv\\lib\\site-packages\\win32', 'G:\\Anaconda3\\envs\\MyDjangoEnv\\lib\\site-packages\\win32\\lib', 'G:\\Anaconda3\\envs\\MyDjangoEnv\\lib\\site-packages\\Pythonwin'] Error during template rendering In template G:\Anaconda3\envs\MyDjangoEnv\lib\site-packages\registration\templates\registration\registration_base.html, error at line 1 base.html 1 {% extends "base.html" %} 2
    展开

    作者回复: 你的代码跟gitee仓库的对比一下看看。还有问题的话,可以传到 gitee或者github上我看下

    共 3 条评论
    
  • 只用号码
    2020-11-20
    老师我输入/accounts/register/为什么回车就变这个 /accounts/profile/ 提示没有匹配 Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/accounts/profile/ Using the URLconf defined in recruitment.urls, Django tried these URL patterns, in this order: admin/ joblist/ [name='joblist'] ^accounts/ ^register/closed/$ [name='registration_disallowed'] ^accounts/ ^register/$ [name='registration_register'] ^accounts/ ^login/$ [name='auth_login'] ^accounts/ ^logout/$ [name='auth_logout'] ^accounts/ ^password/change/$ [name='auth_password_change'] ^accounts/ ^password/change/done/$ [name='auth_password_change_done'] ^accounts/ ^password/reset/$ [name='auth_password_reset'] ^accounts/ ^password/reset/complete/$ [name='auth_password_reset_complete'] ^accounts/ ^password/reset/done/$ [name='auth_password_reset_done'] ^accounts/ ^password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$ [name='auth_password_reset_confirm'] The current path, accounts/profile/, didn't match any of these.
    展开

    作者回复: 对比一下gitee上面的原始代码库,看看有什么差别。django和 register 库的版本也看一下

    共 9 条评论
    
  • 金金金
    2020-11-28
    如果有访问,显示/accounts/profile提示没有匹配到的,就是你已经在登陆状态所以才报错了,换成这样/accounts/logout/在浏览器输入后,再次进入就好了。
    共 7 条评论
    43
  • AJ
    2021-08-31
    1、安装 - 安装应用 pip install django-registration-redux - 在settings.base 中install app 'registration', # 用户登陆注册功能 - 有新的库表数据,需要迁移 python manage.py makemigrations/ python manage.py migrate 2、用户注册 项目url设置登陆url: path('accounts/', include('registration.backends.simple.urls')), 先到django后台将用户登出 访问:/accounts/register/ 注册用户 3、用户登陆 accounts/login/ 输入用户名密码登陆 4、注册跳转、登陆跳转 4-1、settings.base 中设置跳转URL: # 登陆后跳转首页 LOGIN_REDIRECT_URL = '/' # 注册后跳转登陆 SIMPLE_BACKEND_REDIRECT_URL = '/accounts/login/' 4-2、设置首页是招聘列表joblist 项目url(recrument.urls): url(r"^", include("jobs.urls")), 应用url(jobs.urls): path("", views.joblist, name="name"),
    展开
    
    1
  • 埃塔
    2022-05-21
    按步骤配置好以后,、尝试识注册账户,结果页面报错“[WinError 10061] 由于目标计算机积极拒绝,无法连接。” 后台再查看发现账号其实建好了。 那么这个页面报错怎么解决呀
    
    
  • 紫薯酸牛奶
    2022-05-02
    请教,这里的职位列表浏览的界面,为啥不是第21讲已经更换过的界面样式?如果更改成同样样式的话,应该如何编制代码
    
    