Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Wagtail, can't add settings
I'm trying to add custom settings to wagtail (version 4.0.4). Following the guide from the docs, I added wagtail.contrib.settings to INSTALLED_APPS and added this to models.py: from wagtail.contrib.settings.models import register_setting, BaseGenericSetting from django.db import models @register_setting class Authors(BaseGenericSetting): facebook = models.URLField() Then made makemigrations/migrate. But nothing appeared in Wagtail settings. Then I tried to register model in admin. In wagtail_admin.py from wagtail.contrib.modeladmin.options import ( ModelAdmin, modeladmin_register, ) from .models import Authors @modeladmin_register class AuthorsAdmin(ModelAdmin): model = Authors list_display = ("facebook",) add_to_settings_menu = True menu_label = "Authors" But still the same result. What do I miss? Some extra config or ...? Only after removing add_to_settings_menu = True, Authors appears in the side-menu (but, of course, not in the settings). With this line - nothing. -
How to fix coverage report error in github actions with django?
I am finding the solution for this issue, its getting error on coverage report dependencies installing section without any reason Requirement already satisfied: coverage in /opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages (7.3.4) Collecting run Downloading run-0.2.tar.gz (3.2 kB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'error' error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [17 lines of output] Traceback (most recent call last): File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module> main() File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel return hook(config_settings) File "/tmp/pip-build-env-nni0_rb_/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=['wheel']) File "/tmp/pip-build-env-nni0_rb_/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires self.run_setup() File "/tmp/pip-build-env-nni0_rb_/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 480, in run_setup super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script) File "/tmp/pip-build-env-nni0_rb_/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 311, in run_setup exec(code, locals()) File "<string>", line 12, in <module> NameError: name 'file' is not defined [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and … -
Get the latest input from the model
I wanna the last input to bid_price to be received in the Bid_info model and attributed to bid_max, however it gives this error earliest() and latest() require either fields as positional arguments or 'get_latest_by' in the model's Meta. views: @login_required def page_product(request, productid): bid_max = Bid_info.objects.filter(pk=productid).latest() context={ 'bid_max' : bid_max } return render(request, 'auctions/page_product.html', context) html: <p> final price = {{bid_max}} </p> models: class Bid_info(models.Model): product = models.ForeignKey(Product, on_delete=models.CASCADE) seller = models.ForeignKey(User, on_delete=models.CASCADE, related_name="seller") bid_price = models.DecimalField(max_digits=10, decimal_places=2) checkclose = models.BooleanField(default=False) winner = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) -
Error integrating Django run server on windows 10
TypeError: translation() got an expected keyword argument 'codeset' First it started as python not found. I went ahead installing python from MS store. Most of the modules are raising translation errors like: _boostrap._gcd_import(name[level:], package, level) Self.remote_field.through = create_many_to_many_intermediary_model(self, cls) -
Getting code coverage 0% despite getting print statements in Django development server
I have a django project running on local development server. It has different remote DB server. I am trying run API integration tests. Tests are running and giving expected output. Also print statements are generated in console for APIs I am running tests for. But still code coverage is shown 0% for file which was executed after API hit. This is my sample test function class Test_Login_User_FR_and_Dispatcher: BASE_URL = http://passcodev.localhost:8000 FR_LOGIN_ENDPOINT = '/api/user/login/' # TESTCASE FOR SUCCESSFULL LOGIN OF USER def test_successfull_login_user(self, success_login): successfull_login = requests.post(f'{self.BASE_URL}{self.FR_LOGIN_ENDPOINT}',json=success_login) assert successfull_login.status_code == 200 I am using coverage.py for code coverage report generation. I tried coverage.py, pytest cov. But still I am unable to find any leads to troubleshoot this problem. -
AddEventListener is executed twice
I am working with Django and Js, and I am trying to get the code to switch the checked attribute of an element so that it changes the category during the creation of an entry in the form, but when clicking on the element, addEventListener is executed twice and, thus, first adds the checked attribute to the element but then immediately removes it Code: form <div class="new-post-header"> <div class="new-post-functions"> <button type="submit" class="save"><ion-icon name="checkmark-outline"></ion-icon></button> <div class="categories"> <div class="first-category">{{ form.category.0 }}</div> <div class="second-category">{{ form.category.1 }}</div> </div> </div> </div> <div class="new-post-content"> <div class="new-title">{{ form.title }}</div> <div class="new-description">{{ form.description }}</div> </div> js secondInput.hasAttribute('checked') ? localStorage.setItem('secondInput', true) : localStorage.setItem('secondInput', false) secondLabel.addEventListener('click', function() { let secondInputItem = localStorage.getItem('secondInput') if (secondInputItem === 'false') { firstLabel.innerHTML = `<input type="radio" name="category" value="1" required="" id="id_category_0"><ion-icon name="bookmark-outline"></ion-icon>` secondLabel.innerHTML = `<input type="radio" name="category" value="2" required="" id="id_category_1" checked="checked"><ion-icon name="archive-outline"></ion-icon>` localStorage.setItem('secondInput', true) console.log(true) } else { firstLabel.innerHTML = `<input type="radio" name="category" value="1" required="" id="id_category_0" checked="checked"><ion-icon name="bookmark-outline"></ion-icon>` secondLabel.innerHTML = `<input type="radio" name="category" value="2" required="" id="id_category_1"><ion-icon name="archive-outline"></ion-icon>` localStorage.setItem('secondInput', false) console.log(false) } }) -
I have a problem with django in python, i just installed in couple of days and it gave an error when every time i run it
/usr/bin/env : The term '/usr/bin/env' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 /usr/bin/env python "d:\Documents\Python\ecommerce\manage.py" + CategoryInfo : ObjectNotFound: (/usr/bin/env:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException how can i fix this? -
Create super user using Railway CLI
I'm trying to create super user for my django project using Railway CLI. I've install Railway CLI and tried 1-step railway login Successfully logged in 2-step railway link Linked my project 3-step railway run python manage.py createsuperuser But unexpectedly I've got this error : No such file or directory (os error 2) My django project is working awesome on railway, but can't do this task -
Django + Celery + SQS - Messages not received by celery worker?
I'm trying to implement background tasks on my Django web app using Celery and AWS SQS as the message broker. I have a view which calls a task, which is sent to SQS successfully. However, the actual task never gets executed (i.e. the print statements I have added in the task never get printed), even though I can see the number of in flight requests going up on SQS. I have configured Celery in my settings.py - CELERY_ACCEPT_CONTENT = ['application/json'] CELERY_TASK_SERIALIZER = 'json' CELERY_TASK_DEFAULT_QUEUE = 'tk-test-queue' CELERY_BROKER_URL = "sqs://%s:%s@" % (quote(os.environ.get('AWS_ACCESS_KEY_ID'), safe=''), quote(os.environ.get('AWS_SECRET_ACCESS_KEY'), safe='')) CELERY_BROKER_TRANSPORT_OPTIONS = { 'region': 'ap-south-1', 'visibility-timeout': 60 * 30, 'polling_interval': 1 } CELERY_RESULT_BACKEND = None My celery.py looks like this - import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_project.settings') app = Celery('my_project') app.config_from_object('django.conf:settings', namespace="CELERY") app.autodiscover_tasks() I have defined a task in my_app/tasks.py - from time import sleep, ctime from celery import shared_task @shared_task def celery_task(): print(f'Starting task at {ctime()}') sleep(25) print(f'Task finished at {ctime()}') Which I am using in my my_app/views.py - class TestCeleryView(View): def get(self, request): print('In view') celery_task.delay() return HttpResponse('Success') I am starting the celery worker by running - celery -A my_project worker -l INFO Every time I visit the URL for my view … -
Django Refresh Token Rotation and User Page Refresh
I'm using Django simple JWT to implement user authentication, I have done few adjustments so the access token and refresh token are sent as http-only cookies and everything works well On the frontend I have implemented Persistent Login that would keep the user logged in when they refresh the page or close the browser etc. But since I have enabled these settings: "ROTATE_REFRESH_TOKENS": True, "BLACKLIST_AFTER_ROTATION": True, If the user keeps refreshing the page multiple times in a very short time, it might occur that a token is blacklisted before the user receives the new refresh token is there a way to fix that? One possible fix yet I'm not sure of its reliability is disabling the automatic blacklisting and waiting for the frontend to send a request upon receiving the new refresh token, the request containing the old refresh token in its body like this @api_view(['POST']) def blacklist_token(request): refreshToken = request.data.get("refresh") print(refreshToken) if refreshToken: token = tokens.RefreshToken(refreshToken) token.blacklist() return Response(status=status.HTTP_200_OK) PS: Using React.js on the frontend -
How to update Django model fields after filtering by id?
I want to write a function that, when executing a "GET" request, will change fields such as: "inaction" and "lastAction" to 2 and the datetime.now(). But when I wrote my code for the first time, I encountered an error: TypeError: cannot unpack non-iterable int object. This code: def update(self, res_id: str): user, updated = User.objects.filter(id=res_id).update(inaction="2", lastAction=datetime.now()) code_status = HTTPStatus.ACCEPTED if updated else HTTPStatus.OK.value return user, code_status For this reason, I rewrote my code to the following and that started works: def update(self, res_id: str): updated_rows = User.objects.filter(id=res_id).update(inaction="2", lastAction=datetime.now()) user = User.objects.filter(id=res_id).first() code_status = HTTPStatus.ACCEPTED if updated_rows else HTTPStatus.OK.value return user, code_status But in this code, I'm worried about duplicates of the form: User.objects.filter(id=res_id). How can I avoid them? -
Display only certain values of foreignkey in django admin
I have three models in my django project. I want only those products to show up in django admin in product field of variation_price model for which variations already exist. How can I achieve that? In models.py: class VariationManager(models.Manager): def color(self): return super(VariationManager,self).filter(variation_category='color', is_active=True) def sizes(self): return super(VariationManager, self).filter(variation_category='size', is_active=True) variation_category_choice = ( ('color', 'color'), ('size', 'size'), ) class Variation(models.Model): product = models.ForeignKey(Product, on_delete=models.CASCADE) variation_category = models.CharField(max_length=100, choices=variation_category_choice) variation_value = models.CharField(max_length=100) objects = VariationManager() class variation_price(models.Model): price = models.IntegerField() product = models.ForeignKey(Product, on_delete=models.CASCADE) variations = models.ManyToManyField(Variation, blank=True) is_active = models.BooleanField(default=True) Thanks -
RawQueryset isn't working. ProgrammingError-"Error binding parameter 1: type 'builtin_function_or_method' is not supported"
views.py - if product.variant != "None": variants = Variants.objects.filter(product_id=product.id) colors = Variants.objects.filter(product_id=product.id, size_id=variants[0].size_id) sizes = Variants.objects.raw("SELECT * FROM core_variants WHERE product_id=%s GROUP BY size_id",[id]) variant = Variants.objects.get(id=variants[0].id) context = {'sizes': sizes, 'colors': colors, 'variant': variant, } return render(request, 'core/product-details.html', context) product-details.html - <select name="size" id="size" class="form-control"> {% for rs in sizes %} <option {% if variant.size_id == rs.size_id %}selected{% endif %} value="{{rs.size_id}}">{{rs.size_id.title}}</option> {% endfor %} </select> The error i'm getting is "Error binding parameter 1: type 'builtin_function_or_method' is not supported" The line i'm getting error is "{% for rs in sizes %}" I just want to show all the options from the queryset -
who will serve ASGI and WSGI when i add daphne?
when i add daphne in INSTALLED_APPS how will it work ? does it work itself to serve WSGI and ASGI ? or Does it work alone to serve ASGI only ? and Gunicorn still working to serve WSGI ? if daphne works alone to serve ASGI only, and Gunicorn works alone to serve WSGI only... that means i am running two servers in the same time . right ? i have read the document of Channels and ASGI ... but i did not find any thing talks about this thing .. and how will it act >> or if does it take everything and serve them all. if thet so, then i have to deploy my project on a server and run daphne only right? channels document. ASGI document. -
Deploying Django project in an Amazon EC2 Ubuntu instance
I have developed a Django website and hosted the application in an Amazon EC2 instance. AMI name: ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20231207 Instance type: t2.micro I run the project following these steps: SSH into the EC2 instance from my terminal. I locate into the proper django project folder. I run this command: python3 manage.py runserver 0.0.0.0:8000 Now, following these steps, I'm able to run the project and it works fine. But when I close the cmd opened in my local PC that I used to SSH into the EC2 instance and to run the application, then the application doesn't work anymore. My aim would be to simply run the django project from my cmd once (of course after having SSH to the EC2) and then close my laptop and having the application still alive. Do you know how can I do this? -
How can i make notifications in django?
i have Movie model like This: class Movie(models.Model): title = models.CharField(max_length=50) imdb = models.FloatField(validators=[MaxValueValidator(10), MinValueValidator(0)]) age = models.IntegerField() description = models.TextField() starring = models.TextField() Genres = models.ForeignKey( Category, related_name="category", on_delete=models.CASCADE ) tag = models.ManyToManyField(Category, related_name="tags") file = models.FileField(upload_to="media/movie") trailer = models.FileField(upload_to="media/movie/trailer") poster = models.ImageField(upload_to="media/poster", default="media/hero.png") no_likes = models.IntegerField(default=0) def __str__(self) -> str: return self.title @property def time(self): video = VideoFileClip(self.file.path) duration = video.duration hours = int(duration // 3600) min = int((duration % 3600) // 60) if min == 0: return f"{hours} h" elif hours == 0: return f"{min} min" else: return f"{hours} h {min} min" @property def star(self): return round(self.imdb / 2, 0) and i have a Notifications Model like this: class Notifications(models.Model): user = models.Foreignkey(User,on_delete=models.CASCADE) movie = models.Foreignkey(Movie,on_delete=models.CASCADE) I want to create an object from the notifications model when an object is created from the movie model What should I do? i try use signals but signals not work -
How to connect xhtml2pdf - pisa with the Cyrillic alphabet?
How to connect xhtml2pdf - pisa with the Cyrillic alphabet? I have a code that generates a PDF document, but if the form fields contain Cyrillic, then black squares are displayed in the PDF document. I read a lot of information on the Internet on how to make friends with the Cyrillic alphabet, but not a single answer saved my situation. I placed a font that supports Cyrillic in the static folder, static/fonts/(font name).ttf. I registered this absolute path according to the instructions. I used call_back, but that didn't help either. Perhaps I'm doing something wrong. Please help! Below is my code, if anyone knows how to fix this situation, please make changes to my code and tell me where my mistake is. I will be very grateful. Thank you in advance! `def convert_to_pdf(template_name, **context): template = get_template(template_name) html = template.render(context) result = BytesIO() pdf = pisa.pisaDocument(BytesIO(html.encode("UTF-8")), result, encoding="UTF-8") result.seek(0) response = HttpResponse(result.getvalue(), content_type="application/pdf; charset=utf-8") response["Content-Disposition"] = 'inline; filename="output.pdf"' return response` The example shows my initial code that generates a PDF document. -
Django Test: how to simulate LookupError for django_app.get_model()
I need help to implement a test for my Django app. This is a snippet code from my serializer, that I want to test: try: app_config = django_apps.get_app_config(BcConfig.name) app_model = django_apps.get_model(app_label=app_config.name, model_name=type_model_name) recording = app_model.objects.create(**recording) except LookupError: recording = None as mentioned in Django docs, Raises LookupError if no such application or model exists. How to simulate the LookupError programmatically? I have tried to remove the listed model using ContentType, but django_apps.get_model() was still working. I have tried to remove the model using SchemaEditor, but not working properly for testing in SQLite. I still can not find how to delete the model or disable the Django app programmatically. I appreciate the help. Thank you. -
i'm getting SQL Injection error through Django
`I'm getting this error - ProgrammingError at /databases You can only execute one statement at a time. Request Method: POST Request URL: http://127.0.0.1:7099/databases Django Version: 5.0 Exception Type: ProgrammingError Exception Value: You can only execute one statement at a time. Exception Location: C:\Users\falcon\Desktop\Meity\hawk_v\okii\Lib\site-packages\django\db\backends\sqlite3\base.py, line 324, in execute Raised during: app.views.databases when i give the field, designation as '); DELETE FROM app_databases; --. it should delete the whole database but it says, multiple commands executed. please help me out` -
Data Fetch Failure from Django REST API using useFetch in Nuxt.js: Different Behaviors on Reload and Code Editing
I'm developing with Nuxt.js and attempting to fetch data from a Django REST API. I'm encountering several issues with the following code: <template> <div> {{ posts }} </div> </template> <script setup lang="ts"> const { data: posts, pending, error, refresh } = await useFetch('https://localhost:8000/api/posts/') console.log(posts, error) </script> Here are the problems I'm facing: When using useFetch to retrieve data from the Django REST API, an error occurs. Specifically, the following log is output: Proxy(Object) {mountains: Error: [GET] "https://localhost:8000/api/posts/": <no response> fetch failed at createError (…} If I edit and save the Vue code while the page is displayed, the data loads correctly, and I can see the requests in the server logs. However, when I reload the page, the data does not load. There is no record of the request in the server logs. If I change the URL to https://fakestoreapi.com/products, the data is fetched correctly even on page reload. Could you advise on why the data doesn't load upon page reload and how I might resolve this? Also, if you have any insights into why the problem doesn't occur with a different URL, that would be very helpful. -
Why age field is not rendering in signup page? I have included it in fields in CustomUserCreationForm and Models
` #Code For Custom Forms from django.contrib.auth.forms import UserCreationForm, UserChangeForm from .models import CustomUser class CustomUserCreationForm(UserCreationForm): class Meta: model = CustomUser fields = UserCreationForm.Meta.fields + ("age", ) class CustomUserChangeForm(UserChangeForm): class Meta: model = CustomUser fields = UserChangeForm.Meta.fields #Code For CustomUser Model from django.db import models from django.contrib.auth.models import AbstractUser class CustomUser(AbstractUser): age = models.PositiveBigIntegerField(null=True, blank=True) #Code For SignUpView from django.urls import reverse_lazy from .forms import UserCreationForm from django.views.generic import CreateView class SignUpView(CreateView): form_class = UserCreationForm template_name = 'registration/signup.html' success_url = reverse_lazy('login') #Code Of Signup.html {%extends 'base.html'%} {%block title%}Sign Up{%endblock title%} {%block content%} <h2>Sign Up</h2> <form method="post">{%csrf_token%} {{form.as_p}} <button type="submit">Sign Up</button> </form> {%endblock content%} enter image description here You Can see in the image that age field is not showing up for input. things are working completely fine in admin page.The age is showing on the page but not the input for age is showing in signup page. -
Django login authentication redirect to userlogin
i having problem to login user . if i enterd a valid login username and password it keep redirecting me to the login page instead of index.html page for authenticated user from django.shortcuts import render, redirect from django.http import HttpResponse from django.urls import reverse from django.db import models from django.contrib import messages from django.contrib.auth.models import User from finance.models import User from django.contrib.auth import authenticate, login # Create your views here. def userlogin(request): return render(request,'userlogin.html') def Checklogin(request): if request.method == 'POST': usernmame = request.POST['username'] password = request.POST['password'] user = authenticate(username=usernmame,password=password) if user is not None: login(request, user) return redirect(request,'index.html') else: return render(request,'userlogin.html') -
Not implemented alter command for SQL ALTER TABLE "shops_order" ALTER COLUMN "status" TYPE string
I'm trying to use MongoDB with Django. I did everything according to its official docs. I installed pymongo (v3.12.1)* and djongo (v1.3.6). I tried running python manage.py migrate command. It successfully did some migrations but failed at one of them. here's the whole traceback: Running migrations: Applying shops.0020_alter_product_options_alter_order_status...Not implemented alter command for SQL ALTER TABLE "shops_order" ALTER COLUMN "status" TYPE string Traceback (most recent call last): File "G:\Fusion\fusionVenv\Lib\site-packages\djongo\cursor.py", line 51, in execute self.result = Query( ^^^^^^ File "G:\Fusion\fusionVenv\Lib\site-packages\djongo\sql2mongo\query.py", line 784, in __init__ self._query = self.parse() ^^^^^^^^^^^^ File "G:\Fusion\fusionVenv\Lib\site-packages\djongo\sql2mongo\query.py", line 876, in parse raise e File "G:\Fusion\fusionVenv\Lib\site-packages\djongo\sql2mongo\query.py", line 857, in parse return handler(self, statement) ^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\Fusion\fusionVenv\Lib\site-packages\djongo\sql2mongo\query.py", line 889, in _alter query = AlterQuery(self.db, self.connection_properties, sm, self._params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "G:\Fusion\fusionVenv\Lib\site-packages\djongo\sql2mongo\query.py", line 425, in __init__ super().__init__(*args) File "G:\Fusion\fusionVenv\Lib\site-packages\djongo\sql2mongo\query.py", line 84, in __init__ super().__init__(*args) File "G:\Fusion\fusionVenv\Lib\site-packages\djongo\sql2mongo\query.py", line 62, in __init__ self.parse() File "G:\Fusion\fusionVenv\Lib\site-packages\djongo\sql2mongo\query.py", line 441, in parse self._alter(statement) File "G:\Fusion\fusionVenv\Lib\site-packages\djongo\sql2mongo\query.py", line 500, in _alter raise SQLDecodeError(f'Unknown token: {tok}') djongo.exceptions.SQLDecodeError: Keyword: Unknown token: TYPE Sub SQL: None FAILED SQL: ('ALTER TABLE "shops_order" ALTER COLUMN "status" TYPE string',) Params: ([],) Version: 1.3.6 The above exception was the direct cause of the following exception: Traceback (most recent call last): File "G:\Fusion\fusionVenv\Lib\site-packages\django\db\backends\utils.py", line 89, in _execute return … -
Auth0 - How to get userID ? StatusCode400 Error
Happy Sundays everyone. Note: Setup is Django-Rest. So I was trying to get user ID because I am going to check the user's roles in the login, and decide whether let them in or not. So currently I can get some information as id_token = token.get('id_token') jwk_set = oauth.auth0.fetch_jwk_set() user_info = jwt.decode(id_token, jwk_set) print(user_info) However, this information has 'nickname, name, picture, email' and so on. Therefore I tried, def get_user_id(): import http.client conn = http.client.HTTPSConnection("cageda.eu.auth0.com") headers = { 'authorization': "Bearer {settings.SOCIAL_MANAGEMENT_TOKEN}" } conn.request("GET", "/api/v2/users/USER_ID", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))``` However, this is returning as: {"statusCode":400,"error":"Bad Request","message":"Bad HTTP authentication header format","errorCode":"Bearer"} I am totally stucked. A help would be a lifesaver. -
django web app accessed by multiple users
I'm trying to implement a web based quiz application I'm currently using django and html / JavaScript – only running on localhost so far (python manage.py runserver) For one single user, the quiz is working fine, but multiple users are not able to play individually atm. How do i handle concurrent access to the quiz? I considered using the request.session data structure but storing the complete quiz in there somehow feels wrong. And different users might play a totally different set of questions … Somehow I'd like to start a new thread each time a user access the webpage and starts the quiz (like I'd do it in some offline application), but im not sure if this is the right approach for web dev. I also read that this is maybe done by the real webserver, e.g. apache? Should I try to put the django app on apache? Also considered docker and started a small tutorial this morning. I can post some code ofc, or provide more implementation details if necessary but at the moment I need to get a basic understanding of web development best practices ;-) Scenario: User A starts quiz and answers the first 5 questions. User …