Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Rest Framework - React application although using CSRF token, POST, PUT, and DELETE HTTP requests return 403 error
I am using Django rest framework as my API backend and React as my frontend. What I'd like to do is secure my backend so only the frontend can make "unsafe" requests to it such as post, put, delete, etc. My app is related to the blockchain so I use the user's MetaMask wallet as a means of authentication. As such, each user doesn't have a username or password so I am not equipped to use JWT. Instead, my hope was to pass a CSRF token to the frontend to enable the frontend to make those "unsafe" http requests. I set up an endpoint on my backend to return a CSRF token to the frontend when it is requested. That token is passed fine. When I include that token in the "unsafe" request's headers (i.e. "X-CSRFToken"), however, my backend returns 403 forbidden error. The Django documentation indicates that a 403 error could be the result of not passing the correct CSRF token or that permissions are wrong. In response, I set permissions to "AllowAny" as shown in my settings.py file below. Is this an issue with passing the CSRF token incorrectly, or setting up permission incorrectly (or neither)? My understanding … -
What is the correct way to configure asgi application & channels in djnago?
I've just started to learn about channels and asgi in django .... and in few tutorials that i've seen they do this to configure the asgi apllication asgi.py import os from django.core.asgi import get_asgi_application from channels.routing import ProtocolTypeRouter, URLRouter os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mywebsite.settings') application = ProtocolTypeRouter({ 'http':get_asgi_application(), }) settings.py INSTALLED_APPS = [ 'channels', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'chat' ] ASGI_APPLICATION = 'mywebsite.asgi.application' to check when i run my server it was supposed to be running on asgi/channel server like this Starting ASGI/Channels version development server at http://127.0.0.1:8000/ but mine is still running on the default one Starting development server at http://127.0.0.1:8000/ when i use daphne and put inside installed apps instead of channels 'daphne', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'chat' ] it works fine Starting ASGI/Daphne version 4.0.0 development server at http://127.0.0.1:8000/ can someone tell me what is going on here?and how exactly django works with asgi? -
Problem with Detection in real time using - Yolov5 & Django & React
I am trying to get the detection that displays on the video that I am Streaming to the client and display on a table for every moment and in the same second that detection happening, but for now I get only small parts of the data and it’s happening after a few seconds I using Django to stream a video with detection using yolov5 , I get the video in the client side and display it,now my problem is that I create a function in server that get the detection for the object when it's show in the video and I wanna use it ,the video is displaying in the client and i have also a table beside the video that including the need to include the detection. i need that in every time and in the moment that it's heppning I’ll display it in the table,but now it’s not work for me, it’s only send the data and display it for one/two times , I’m sure that have some problem with detection() function and maybe with the detection_percentage function views.py def stream(): cap = cv2.VideoCapture(source) model.iou=0.5 model.conf=0.15 while (cap.isOpened()): ret, frame = cap.read() if not ret: print("Error: failed to … -
Why is Django saying my template doesn't exist even though it does?
I'm a beginner following this Django tutorial (https://www.w3schools.com/django/django_templates.php) and I'm getting the error bellow after making the html template and modifying the views.py file (name erased for privacy): Internal Server Error: /members Traceback (most recent call last): File "C:\Users\\myproject\lib\site-packages\django\core\handlers\exception.py", line 55, in inner response = get_response(request) File "C:\Users\\myproject\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\\myproject\myworld\members\views.py", line 5, in index template = loader.get_template('myfirst.html') File "C:\Users\\myproject\lib\site-packages\django\template\loader.py", line 19, in get_template raise TemplateDoesNotExist(template_name, chain=chain) django.template.exceptions.TemplateDoesNotExist: myfirst.html [26/Oct/2022 16:51:01] "GET /members HTTP/1.1" 500 64964 Tried this: from django.http import HttpResponse from django.shortcuts import loader def index(request): template = loader.get_template('myfirst.html') return HttpResponse(template.render()) Expecting this: <!DOCTYPE html> <html> <body><h1>Hello World!</h1> <p>Welcome to my first Django project!</p> </body> </html> -
How to return respons with redirect in Django views?
I made an api request, took the token, put it into cookie, and to make it work I need return reponse, like is in the end: def reg(request): form = CreateUserForm() if "register-btn" in request.POST: form = CreateUserForm(request.POST) if form.is_valid(): new_user = form.save() login(request, new_user) usr = request.POST.get('username') pss = request.POST.get('password1') url = "http://localhost:8000/api/api-token-auth/" data = {'username': usr, 'password': pss } headers = {'Content-type': 'application/json'} response = requests.post(url, json=data, headers=headers) data = json.loads(response.text) token_ = data.get('token') print(token_) respons = HttpResponse("Cookie Set") respons.set_cookie('token', token_) return respons I need instead of return respons, to make redirect, but if I do so, it doesn't work. Somehow I need to make this code from below work. ... respons = HttpResponse("Cookie Set") respons.set_cookie('token', token_) return redirect('account/') How to make return respons in order to set cookie and redirect to url? -
Multiple dropdown filters on HTML table with javascript
I'm trying to have some dropdowns that will help narrow rows on an html table. I'm new to this so I'm struggling to see how the javascript isn't working. I feel like its close and actually if I change the "!= -1" to "== -1" .... it almost looks like its doing the opposite of what I want. but its still showing odd results. If I had to guess, this is something to do with looping through and I may be missing an IF statement or another conditional somewhere. Also, when I attempt to switch back to No values, it doesn't revert back to the original list Any guidance would be appreciated. var $filterableRows = $('#validtargets').find('tr'), $inputs = $('.filter'); console.log($filterableRows); $inputs.on('change', function() { $filterableRows.hide().filter(function() { return $(this).find('td').filter(function() { console.log(this); // console.log($(this).text().toLowerCase()); // console.log($('#' + $(this).data('input')).val().toLowerCase()); var tdText = $(this).text().toLowerCase(), inputValue = $('#' + $(this).data('input')).val().toLowerCase(); return tdText.indexOf(inputValue) != -1; }).length == $(this).find('td').length; }).show(); }); {% extends 'tf_iac/base/base.html' %} {% load static %} {% block site_css %} <link rel="stylesheet" href="{% static 'tf_iac/styles/run_powershell.css' %}"> {% endblock %} {% block header %} {{ display_r_e }}: Remote Powershell Execution {% endblock %} {% block info %} <select id="project" class="filter"> <option value=" ">No value</option> <option value="TV">TV</option> … -
Django - Custom Form Template cannot find Template
Error: Internal Server Error: /clients/service/edit_equipment/133 Traceback (most recent call last): File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/backends/django.py", line 34, in get_template return Template(self.engine.get_template(template_name), self) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/engine.py", line 175, in get_template template, origin = self.find_template(template_name) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/engine.py", line 161, in find_template raise TemplateDoesNotExist(name, tried=tried) django.template.exceptions.TemplateDoesNotExist: form_as_div.html The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/backends/django.py", line 62, in render return self.template.render(context) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/base.py", line 175, in render return self._render(context) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/base.py", line 167, in _render return self.nodelist.render(context) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/base.py", line 1005, in render return SafeString("".join([node.render_annotated(context) for node in self])) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/base.py", line 1005, in <listcomp> return SafeString("".join([node.render_annotated(context) for node in self])) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/base.py", line 966, in render_annotated return self.render(context) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/defaulttags.py", line 238, in render nodelist.append(node.render_annotated(context)) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/base.py", line 966, in render_annotated return self.render(context) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/base.py", line 1064, in render output = self.filter_expression.resolve(context) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/base.py", line 715, in resolve obj = self.var.resolve(context) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/base.py", line 847, in resolve value = self._resolve_lookup(context) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/base.py", line 914, in _resolve_lookup current = current() File "/home/wcadev/.local/lib/python3.8/site-packages/django/forms/utils.py", line 96, in as_div return self.render(self.template_name_div) File "/home/wcadev/.local/lib/python3.8/site-packages/django/forms/utils.py", line 75, in render return mark_safe(renderer.render(template, context)) File "/home/wcadev/.local/lib/python3.8/site-packages/django/forms/renderers.py", line 28, in render template = self.get_template(template_name) File "/home/wcadev/.local/lib/python3.8/site-packages/django/forms/renderers.py", line 34, in get_template return self.engine.get_template(template_name) File "/home/wcadev/.local/lib/python3.8/site-packages/django/template/backends/django.py", line … -
Django-admin-tools-action how to add actions inside another
is there a way to put a dropdown inside another dorpdown in the django action? I wish I could use a selection inside another to select options from it this way I tried to call an action function inside another but it doesn't match -
pk reference in Django related models
I am learning Django and doing some project where I have three models with following relationships: #models.py class Model1(models.Model): status = models.CharField(max_length = ....) class Model2(models.Model): model1 = models.ForeignKey(Model1, ....) name = models.CharField(max_length = ....) class Model3(models.Model): model2 = models.ForeignKey(Model2, ....) name = models.CharField(max_length = ....) I want to update status field in my Model1 based on the logic which happens in my views.py on Model3 instance i.e. views.py def model3_view(request, pk): model1 = get_object_or_404(Model1, pk=pk) model3 = Model3.objects.filter(model1_id=model1.pk) my logic goes here.... if <my logic outcome> == True: model1_status = Model1.objects.update_or_create(status='closed', pk=model1.pk) However, I am getting error UNIQUE constraint failed: model1_model1.id. I tried to reference my model2 instance pk and it does work fine i.e. model1_status = Model1.objects.update_or_create(status='closed', pk=model2.pk) but could not figure out how I can do this for 1 level up i.e. for model1 pk... -
How to set cookie in views.py in Django?
I want after registration to set token cookie, in views.py. After registration I am sending to rest-framework request in order to take token, I am taking and printing it in cmd successfully, but I tried implemented in Django set.cookie and questions from stackoverflow and it doesn't work in my case. Here is my code: def reg(request): form = CreateUserForm() if "register-btn" in request.POST: form = CreateUserForm(request.POST) if form.is_valid(): new_user = form.save() login(request, new_user) usrnm = request.POST.get('username') pswd = request.POST.get('password1') url = "http://localhost:8000/api/api-token-auth/" data = {'username': usrnm, 'password': pswd } headers = {'Content-type': 'application/json'} response = requests.post(url, json=data, headers=headers) data = json.loads(response.text) token_ = data.get('token') print(token_) #Here code doesn't work respons = HttpResponse("Cookie Set") respons.set_cookie('token', token_) return redirect('account/deposit/') -
Django type hint for model object (single)
I'm looking for type hint on an model object instance class: >>> Device.objects.get(pk=31) <Device: Device object (31)> >>> device = Device.objects.get(pk=31) >>> type(device) <class 'inventory.models.Device'> I'll be passing above into a function which will be performing some action but i can't figure out what to use for the device object in the function where type hinting will take place? def do_something(device: ???) -> bool: if device.id: some_logic return True -
Building a location based app with python, Django
Am building an like Uber eat, am getting the location of customer and the driver through their Ip address. my challenge here is how to track the location of the driver in map is real time, to know if he is moving or not. Just like Uber -
While using Cache In DRF after using POST request new data is not being displayed on client side
I have implemented cache for my articles views, and have set cache page. Currently the issue that i am facing is when i try to POST request data to create new article, the page remains the same. What i want to do is be able to POST article while i am still in cache page time, and display the new data while being in the cache page time. following is the cache page code ... articles views class ArticleViewSet(viewsets.ModelViewSet): serializer_class=ArticleSerializer permission_classes=[permissions.IsAuthenticated] authentication_classes = [authentication.TokenAuthentication] @method_decorator(cache_page(300)) @method_decorator(vary_on_headers("Authorization",)) def dispatch(self, *args, **kwargs): return super(ArticleViewSet, self).dispatch(*args, **kwargs) Someone can guide how can i achieve this ... -
Hidden, required fields in form not focusable
I am having an issue with submitting a form which only contains hidden, requried fields. I am getting the following error messages: "An invalid form control with name='lat0' is not focusable." "An invalid form control with name='lng0' is not focusable." The fields in question are given values in a js script which allows the user to place a pin on a map and then copies the co-ordinates from the pin into them. The thing is I need to submit these co-ordinates, unchanged to the backend, so they need to be 'hidden' and 'required', if I remove 'required' the fields are empty when they are submitted. I understand that a form is the only way to submit the variables, if there is an alternative, I would be happy to use it. My code is below, the variables in question are inserted into the div with id "coords-container" : <form id="locationForm" method="post"> {% csrf_token %} <!-- Here we create a form with hidden variables to capture the addresses and co-ordinates to pass to backend --> <div id="coords-container" hidden class="dynamic"></div> <input type="submit" id="locationsubmit" value="Submit" class="report-buttons"> </form> I would appreciate any suggestions. Thanks. -
Can I use Django in a way that I can change CSS variables?
I am creating a personal website and I have a progress bar that has been done in css and html. in order to control the progress bars all I need to do is change a variable(width). This is the code for one bar: .bar-inner1 { width: 559px; height: 35px; line-height: 35px; background: #db3a34; border-radius: 5px 0 0 5px; } This is the corresponding html that is affected by this css: <div class="container"> <h2 class="my-skills">My Skills</h2> <div class="bar-1"> <div class="title">HTML5</div> <div class="bar" data-width="65%"> <div class="bar-inner1"> </div> <div class="bar-percent">65%</div> </div> </div> How would I use Django to change the variable width? I have looked through documentation and tutorials but I cannot seem to work it out. -
django POST Method in Singup returning Internal Server 500 error
I have this error when I want to signup in django the user will be create in database but it gives me this error and the response will not return can someone help me I want to get help and I want my quetion to be useful for others -
Django Form to PDF
I've completed all the code needed for the form to work, its just missing the styling. The post has been done but when I try to get the form to write to pdf doesn't write through ReportLab, I followed a tutorial on how to do this and didn't encounter the error. Plus I'm still not sure if the submit button saves the file per profile. views.py def home2_pdf(request): buf = io.BytesIO() c = canvas.Canvas(buf, pagesize=letter, bottomup=0) textob= c.beginText() textob.setTextOrigin(inch,inch) textob.setFont("Helvetica", 14) Info = InfoPersonal.objects.all() lines=[] for i in Info: lines.append(InfoPersonal.fecha) for line in lines: textob.textLine(line) c.drawText(textob) c.showPage() c.save() buf.seek(0) return FileResponse(buf, as_attachment=True, filename="formulario.pdf") forms.py class QuestionsInfoPersonal(forms.ModelForm): #personal fecha = forms.DateField(required=True, widget=forms.TextInput(attrs={'class':'form-control'})) cargo_actual = forms.CharField(max_length=200, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) Nombres_y_Apellidos_completos = forms.CharField(max_length=200,required=True,widget=forms.TextInput(attrs={'class':'form-control'})) Lugar_y_Fecha_de_Nacimiento = forms.CharField(max_length=200, required=True,widget=forms.TextInput(attrs={'class':'form-control'})) Discapacidad = forms.CheckboxInput() if Discapacidad.check_test==True: grado= forms.CharField(max_length=200, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) Edad = forms.IntegerField(required=True, widget=forms.TextInput(attrs={'class':'form-control'})) Tipo_de_Sangre = forms.CharField(max_length=200, required=True,widget=forms.TextInput(attrs={'class':'form-control'})) Estatura = forms.DecimalField(max_digits=3, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) Direccion_Domicilio_actual = forms.CharField(max_length=200, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) Manzana = forms.CharField(max_length=200, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) Villa = forms.CharField(max_length=200, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) Parroquia = forms.CharField(max_length=200, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) Telefono_Domicilio = forms.IntegerField(required=False,widget=forms.TextInput(attrs={'class':'form-control'})) Telefono_Celular = forms.IntegerField(required=True,widget=forms.TextInput(attrs={'class':'form-control'})) Telefono_Familiar= forms.IntegerField(required=True, widget=forms.TextInput(attrs={'class':'forms-control'})) Cedula= forms.IntegerField(required=True, widget=forms.TextInput(attrs={"class":"control"})) estado_civil = forms.CheckboxInput() #conyuge verif = forms.CheckboxInput() if verif.check_test==True: Nombre_completo_del_conyuge= forms.CharField(max_length=200, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) Direccion_Domiciliaria= forms.CharField(max_length=200, required=True, widget=forms.TextInput(attrs={'class':'form-control'})) Telefono = forms.IntegerField(required=True,widget=forms.TextInput(attrs={'class':'form-content'})) Cedula_de_Identidad = forms.IntegerField(required=True,widget=forms.TextInput(attrs={"class": … -
Django not connecting to remote MySQL db: MySQLdb.OperationalError: (2005, "Unknown MySQL server host ' db5010610948.hosting-data.io ' (8)")
I am trying to connect my django project to a mysql db hosted remotely, I have gotten mysql installed and have configured the settings.py file correctly as far as I can tell even tried adding the wildcard to allowed hosts just to get this to work. but i keep getting: MySQLdb.OperationalError: (2005, "Unknown MySQL server host ' db5010610948.hosting-data.io ' (8)") when i try to run python3 manage.py runserver not sure where to go from here, I have triple checked to make sure all the info is correct ALLOWED_HOSTS = ['*'] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'holidaytourney', 'USER': 'definitelymycorrectusername', 'PASSWORD': 'definitelymycorrectpassword', 'HOST': 'db5010610948.hosting-data.io', 'PORT': '3306', } } I have tried resetting the db and running the runserver command from a new terminal with no success -
Django REST API: How to respond to POST request?
I want send POST request with axios(VueJS) and when Django server got a POST request then I want to get back that request message. I tried make functions when got an POST request in Django server and then return JsonResponse({"response": "got post request"), safe=False) JS function sendMessage() { axios({ method: "POST", url: url, data: this.message }) .then(response => { this.receive = response; }) .catch(response => { alert('Failed to POST.' + response); }) } } views.py from chat.serializer import chatSerializer from chat.models import * from rest_framework.routers import DefaultRouter from rest_framework import viewsets from django.http import JsonResponse from django.views.generic import View # Create your views here. class get_post(View): def post(self, request): if request.method == 'POST': JsonResponse({"response": 'got post request'}, safe=False) but error says like that in django Internal Server Error: /api/chat/ Traceback (most recent call last): File "/usr/lib/python3/dist-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 188, in _get_response self.check_response(response, callback) File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 309, in check_response raise ValueError( ValueError: The view chat.views.views.get_post didn't return an HttpResponse object. It returned None instead. [26/Oct/2022 17:06:51] "POST /api/chat/ HTTP/1.1" 500 60946 I think POST request is working properly, but Django code is something wrong. Therefore, my question is.. How to fix and … -
How to make specific background task in Django?
I have a mission to make a background task in Django, I tried with celery but I didn't have success. What I have to do? I need after the person wrote the number in input and pressed submit button, for example 100, the 1% of it will be added every second to his previous number during the 1 day. He wrote in input 100 In database this is stored, and in during a day, every second is adding 1%. How concretely it looks, 100+1=101, 101+1=102, 102+1.... every second adding 1% Can you help me draw the code what it looks like? With celery, django-background-task or others doesn't matter, the main importance that it needs to be certain number of tasks simultaneously, for every user his background task -
Issues with Importing python files within a Django Project
I'm having problems with importing python files within my project. I've clearly set up a file named testing.py within a folder called api, which is the same directory where my views.py file. When I import testing within views.py, I keep getting an error: "ModuleNotFoundError: No module named 'testing'". I'm not sure if I need to create an init.py file here for the module, but it should be importing without any error regardless. Can anyone help me figure out this issue? views.py file within api: import http from django.shortcuts import render from django.shortcuts import HttpResponse import testing # Create your views here. def test(request) : return HttpResponse(testing.testFunction()) testing.py file within api: def testFunction(): return "This is a test" -
Form Create with multiple foreign keys and model instances
i have 3 models, Training, Participant and Material. i have to create a form that allows me to create the training, N instances of Participants and Materials. Models.py class Training(models.Model): name = models.CharField(max_length=99, null=True, blank=True) description = models.CharField(max_length=500, null=True, blank=True) start_date = models.DateTimeField(default=timezone.now, null=True, blank=True) end_date = models.DateTimeField(default=timezone.now, null=True, blank=True) class Participant(models.Model): training = models.ForeignKey('Training', on_delete=models.CASCADE, null=True, blank=True) person = models.ForeignKey('User', on_delete=models.CASCADE, null=True, blank=True) role = models.CharField(max_length=90, null=True, blank=True) class Material(models.Model): name = models.CharField(max_length=99, null=True, blank=True) description = models.CharField(max_length=500, null=True, blank=True) quantity = models.IntegerField( null=True, blank=True) training = models.ForeignKey('Training', on_delete=models.CASCADE, null=True, blank=True) by example would be something like this: But i didnt really know how i could use multiple ModelForms, and Multiple Instances of the same form in the same template. is possible to do this without Django rest framework? or at least create N instances of the same form in one template for create multiple materiales, or multiple Participants, each ModelForm on a different template?. -
Except my admin page, I am not getting any style while running by Django website
I am a beginner and was following a youtube tutorial to learn Django and encounter following problem, while re-using bootstarp code for navbar, my site has no style but in settings.py my debug is set to true and my admin page works just fine. As per the youtube tutorial my site should look like I have tried what was mentioned in this Why does my Django admin site not have styles / CSS loading? but still it's not working. -
What is this javascript syntax in python syntax? [closed]
I am currently using Django and bootstrap to make my personal website.I am not the stage where i need to create a animated progress bar for my skill section. I located some code on the internet which is here https://codepen.io/Chazza/pen/vRBeRr. The javascript in the link above is what I need to be translated to python. The hdml and css code works fine but am assuming that I need to change the javascript into python code. Could someone please help me translate this so I can more onto the next task with trying to workout how to implement the python code to make it work lol. I have worked my through some documentation and videos online but because I am using Django and bootstrap I have no idea where to start on javascript as I have no knowledge what so ever at this point. -
Django/Wagtail Deployment on Digital Ocean destroys admin session when navigating
Experienced with other cloud hosting providers I tried Digital Ocean the first time to set up a Wagtail app (should be a staging/production environment with pipeline in the future). Following this tutorial (but just deploying a SQLite database not a solid one), everything works fine. The app will be understand as a Python app when cloning it from GitHub and the default build process (by Python Buildpack) followed by running with Gunicorn server will be executed like expacted – there is no Dockerfile provided. Afterwards the frontend works as expected when first opening it. The admin panel allows to enter but when navigating to page editing it destroys the session and I´m faced with the login panel – probably auto logout, since expired session. The django-admin reacts the same way. The tutorial uses get_random_secret_key. Maybe this is not accepted by Digital Ocean? Another maybe important information is that the set-cookie header first contains a expiry date in one year (like it is set). But after the session was destroyed it´s set to 1970 (probably something like a null value). Actually this is just the indicator for the forced ended session I guess. Since it´s not so easy to find out, …