I've connected my Django app with MongoDB, register/login/logout are all working fine. But when I use the Django default password reset email it throws a database error.
What I've tired:
sqlite3 - register/login/logout (Working)
MongoDB - register/login/logout (Working)
sqlite3 - password reset email (Working)
MongoDB - password reset email (NOT Working)
I was able to land on the Django password reset page, but when I hit confirm it return the error on the browser
DatabaseError at /pw_reset/
No exception message supplied
Request Method: POST
Request URL: http://localhost:8000/pw_reset/
Django Version: 3.2.6
Exception Type: DatabaseError
Exception Location:
C:...venv\lib\site-packages\djongo\cursor.py, line 59, in execute
The above exception ( Keyword: None Sub SQL: None FAILED SQL: ('SELECT "accounts_user"."id", "accounts_user"."password", "accounts_user"."last_login", "accounts_user"."is_superuser", "accounts_user"."username", "accounts_user"."first_name", "accounts_user"."last_name", "accounts_user"."email", "accounts_user"."is_staff", "accounts_user"."is_active", "accounts_user"."date_joined" FROM "accounts_user" WHERE ("accounts_user"."email" iLIKE %(0)s AND "accounts_user"."is_active")',) Params: (('test#test.com',),) Version: 1.3.6) was the direct cause of the following exception:
Console log:
Traceback (most recent call last):
File "C:...\lib\site-packages\django\template\base.py", line 850, in _resolve_lookup
(bit, current)) # missing attribute
django.template.base.VariableDoesNotExist: Failed lookup for key [name] in <URLResolver <URLPattern list> (admin:admin) 'admin/'>
URL Path:
path('pw_reset/', auth_views.PasswordResetView.as_view(), name="reset_password"),
The Views I defined myself (register/login/logout) are all working fine. But the built-in one PasswordRestView is not. I've tried dropping the DB, reinstall djongo, I run out of ideas... Please help!
Fixed by downgrading versions on:
Django==3.0.5
djongo==1.3.4
sqlparse==0.2.4
Related
In my Django project sometimes I get two kinds of errors by mail and I don't know where they are coming from. So far I can see, the user is not logged in.
First kind of error:
Internal Server Error: /
KeyError at /
'HTTP_HOST'
File "./core/views/iam.py", line 45, in prepare_django_request
'http_host': request.META['HTTP_HOST'],
Exception Type: KeyError at /
Exception Value: 'HTTP_HOST'
Request information:
USER: AnonymousUser
Second type of error:
Internal Server Error: /
OneLogin_Saml2_Error at /
SAML Response not found, Only supported HTTP_POST Binding
File "var/www/schoolbox/venv/lib64/python3.6/site-packages/onelogin/saml2/auth.py", line 139, in process_response
OneLogin_Saml2_Error.SAML_RESPONSE_NOT_FOUND
Exception Type: OneLogin_Saml2_Error at /
Exception Value: SAML Response not found, Only supported HTTP_POST Binding
Request information:
USER: AnonymousUser
But users are able to login but, or maybe only some, I don't know where this error is coming from. Maybe I need to post more code in order to help me. Any help will be appreciated.
I deployed a django app using a postresql database with Heroku.
The app works perfectly on my local machine but when I want to create a user or to login using the deployed app, I run into the following error:
ProgrammingError at /register/
relation "register_user" does not exist
LINE 1: SELECT (1) AS "a" FROM "register_user" WHERE "register_user"...
^
Request Method: POST
Request URL: https://the-gecko.herokuapp.com/register/
Django Version: 4.0.3
Exception Type: ProgrammingError
Exception Value:
relation "register_user" does not exist
LINE 1: SELECT (1) AS "a" FROM "register_user" WHERE "register_user"...
^
Exception Location: /app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py, line 89, in _execute
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.9.10
Python Path:
['/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python39.zip',
'/app/.heroku/python/lib/python3.9',
'/app/.heroku/python/lib/python3.9/lib-dynload',
'/app/.heroku/python/lib/python3.9/site-packages']
Server time: Mon, 21 Mar 2022 19:59:58 +0000
I believe this error has something do to with my postgres database, but I don't know what relevant code to share in that case.
Please, let me know if you have any idea how to solve that issue.
I've installed and configured django-rest-auth, everything seems to be working properly except the /rest-auth/password/reset/ endpoint.
When I do a POST to it, passing the email via JSON, a 500 - DoesNotExist error is returned:
DoesNotExist at /rest-auth/password/reset/
Site matching query does not exist.
Request Method: POST
Request URL: http://.../rest-auth/password/reset/
Django Version: 1.9.5
Exception Type: DoesNotExist
Exception Value: Site matching query does not exist.
Exception Location: /home/.../.local/lib/python2.7/site-packages/django/db/models/query.py in get, line 387
Python Executable: /usr/bin/python
Python Version: 2.7.10
What could be causing this?
django-allauth (used internally by DRA) looks for the domain name by searching for Site object.
Please follow these steps to set up sites framework:
https://docs.djangoproject.com/en/1.9/ref/contrib/sites/#enabling-the-sites-framework
Am trying to access the django cmcs frontend editor and after input the login details, i get the following error.
AttributeError at /en/
'NoneType' object has no attribute 'has_change_permission'
Request Method: GET
Request URL: http://*.*.*.*:8000/en/
Django Version: 1.6.5
Exception Type: AttributeError
Exception Value:
'NoneType' object has no attribute 'has_change_permission'
Exception Location: /home/bg/workspace/my-site/env/local/lib/python2.7/site-packages/cms/templatetags/cms_tags.py in get_processors, line 352
Python Executable: /home/bg/workspace/my-site/env/bin/python
Python Version: 2.7.3
Python Path:
['/home/bg/workspace/my-site',
'/home/bg/workspace/my-site/env/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg',
'/home/bg/workspace/my-site/env/lib/python2.7',
'/home/bg/workspace/my-site/env/lib/python2.7/plat-linux2',
'/home/bg/workspace/my-site/env/lib/python2.7/lib-tk',
'/home/bg/workspace/my-site/env/lib/python2.7/lib-old',
'/home/bg/workspace/my-site/env/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/home/bg/workspace/my-site/env/local/lib/python2.7/site-packages']
How can i fix it?
I faced a similar issue with django-cms 3.0.4 / Python 3.4, it may be related to the djangocms-column plugin (version 1.4).
This problem appeared when editing a page; either with djangocms-installer default pages, as well as when creating a new page at trying to add the multi-columns plugin into it.
For a bit more details, the error is encountered when interpreting {% render_plugin plugin %}, in multi_column.html (line #4):
In template /dvlpt/venv/my_project/lib/python3.4/site-packages/djangocms_column/templates/cms/plugins/multi_column.html, error at line 4
'NoneType' object has no attribute 'has_change_permission'
More exactly, the AttributeError exception is raised by line #352 of cms/templatetags/cms_tags.py, in get_processors():
if toolbar and toolbar.edit_mode and placeholder.has_change_permission(request) and getattr(placeholder, 'is_editable', True):
...
I've posted a comment at djangocms-colum github : https://github.com/divio/djangocms-column/issues/14
Sorry, I cannot bring a more useful help yet, as I'm very new to django-cms at this time...
Cheers
I am trying to use django-debug-toolbar with my django application and it worked for django v1.5. However, I am trying to migrate the system to django v1.6 and it is generating the following error when I try to load any page.
python manage.py runserver
Validating models...
0 errors found
December 21, 2013 - 22:53:18
Django version 1.6.1, using settings 'MySite.settings'
Starting development server at http://XXX.XXX.XXX.XXX:XXXX/
Quit the server with CONTROL-C.
Internal Server Error: /
Traceback (most recent call last):
File "/home/user/django-env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 90, in get_response
response = middleware_method(request)
File "/home/user/django-env/local/lib/python2.7/site-packages/debug_toolbar/middleware.py", line 45, in process_request
mod_path, func_name = func_path.rsplit('.', 1)
AttributeError: 'function' object has no attribute 'rsplit'
[21/Dec/2013 22:53:21] "GET / HTTP/1.1" 500 58172
The source has this note, but I'm not sure what they mean precisely (import_by_path):
def process_request(self, request):
# Decide whether the toolbar is active for this request.
func_path = dt_settings.CONFIG['SHOW_TOOLBAR_CALLBACK']
# Replace this with import_by_path in Django >= 1.6.
mod_path, func_name = func_path.rsplit('.', 1)
show_toolbar = getattr(import_module(mod_path), func_name)
if not show_toolbar(request):
return
Also, while we're at it. Any idea what this message means as well?
/home/user/django-env/local/lib/python2.7/site-packages/debug_toolbar/settings.py:68: DeprecationWarning: SHOW_TOOLBAR_CALLBACK is now a dotted path. Update your DEBUG_TOOLBAR_CONFIG setting.
"DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)
My settings.py:
def custom_show_toolbar(request):
return True # Always show toolbar, for example purposes only.
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'SHOW_TOOLBAR_CALLBACK': custom_show_toolbar,
'INSERT_BEFORE': 'div',
'ENABLE_STACKTRACES' : True,
}
The problem is described by the message you get (which should not be a deprecation warning, rather it should be a TypeError, that's probably a bug in debug_toolbar):
SHOW_TOOLBAR_CALLBACK is now a dotted path. Update your DEBUG_TOOLBAR_CONFIG setting
The SHOW_TOOLBAR_CALLBACK setting used to be a callable, but now it is a dotted path to a callable: a string. The code you quoted tries to rsplit the value of SHOW_TOOLBAR_CALLBACK, but because you can't rsplit a function object, you get an error.
To solve this, put your callback into another python file, for example your_site/toolbar_stuff.py, and adjust the setting to 'SHOW_TOOLBAR_CALLBACK': 'your_site.toolbar_stuff.custom_show_toolbar'. You can test if this works beforehand by trying in the shell:
from your_site.toolbar_stuff import custom_show_toolbar
If that works, your new setting should work, too.