State of affairs
- I’ve constructed Django 3.Zero mission with a few functions.
- I’ve created the accounts app based mostly on following course and it is github
- Than I’ve created an software fro authentication
- All this has been accomplished in an SQLite database
- Beforehand I’ve tried out a PostgreSQL database for the early software that was working fantastic
- however now after I change of within the settings.py file the SQLite to PostgreSQL I get an error i I attempt to log in
- If I change again the settings.py to SQLite all the pieces works completely (ex.: authentication, logging in with consumer, consumer doing issues on the web site with it is personal settings)
- I take advantage of decorators.py to maintain logged in customers visiting the login and signup pages and that provides error after I change to postgresql. I solely use right here
HttpResponsethat the error message accommodates
from django.http import HttpResponse from django.shortcuts import redirect def unauthenticated_user(view_func): def wrapper_func(request, *args, **kwargs): if request.consumer.is_authenticated: return redirect('house') else: return view_func(request, *args, **kwargs) return wrapper_func def allowed_users(allowed_roles=): def decorator(view_func): def wrapper_func(request, *args, **kwargs): group = None if request.consumer.teams.exists(): group = request.consumer.teams.all().title if group in allowed_roles: return view_func(request, *args, **kwargs) else: return HttpResponse('Licensed') return wrapper_func return decorator
If I log in whereas settings.py makes use of PostgreSQL. If I log off all the pieces works out fantastic once more. If I take advantage of SQL lite I can log in and all the pieces works completely
ValueError at / The view accounts.decorators.wrapper_function did not return an HttpResponse object. It returned None as an alternative. Request Methodology: GET Request URL: http://localhost... Django Model: 3.0 Exception Kind: ValueError Exception Worth: The view accounts.decorators.wrapper_function did not return an HttpResponse object. It returned None as an alternative. Exception Location: /Customers/.../python3.7/site-packages/django/core/handlers/base.py in _get_response, line 126 Python Executable: /Customers/.../bin/python3 Python Model: 3.7.3 ..... Request info USER MYUSERNAME GET No GET information POST No POST information FILES No FILES information COOKIES ... ...
Drained to Remedy
- The information that I observe created consumer teams that I’ve accomplished as nicely in my migrated postgreSQL database, however I’ve nonetheless obtained the identical error as USER1 within the remark part.
- This was the advice within the backside part of the video
- “USER1 i discover it, i forgot to alter the consumer’s group!
- –> USER2 go to admin panel and in you consumer part add buyer within the chosen group part”.
- I’ve accomplished precisely that and it didn’t labored the one distinction is that I’ve used a migrated postgresql they usually used the unique SQLight that if I take advantage of than the wole factor works for me as nicely, however I wish to make it work with PostgreSQL.
- I’ve information, tables in each database however PostgreSQL for some outdated employees and SQLite for all the pieces.
- I’ve tried emigrate the SQLite to PostgreSQL with this information.
- I’ve efficiently created a replica of the SQLite database
- however after I modified the settings to postgres and I attempt to
python handle.py migrateit says
Working migrations: No migrations to use.
python handle.py loaddata db.json
- The customers are migrated (I can log in with them and get error identical to with the one SQlite customers, if I mistype the consumer or the password it doesn’t lets me in) from SQLite however I do not see any of the information tables in Postgresql if I look it up with an IDE
- I’ve talked to different folks on boards abut this many stated that it’s the decorator file that’s problematic however It precisely happens solely at information base switching.
- I’ve created a brand new postgresql database and I’ve tried emigrate all the pieces (the migration didn’t migrate all the pieces already). Than I’ve tried to enroll with a brand new account an it gave me the next error message after filling out the shape an urgent submit
DoesNotExist at /register/ Group matching question doesn't exist.
- I’ve additionally created an AWS Bucket postgreSQL information base just like the course chief, migrated and linked it with the server and within the settings butI nonetheless received the identical error.