Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Enable CORS in a Django Apache Project
I have an Django project that runs on Apache. With Javascript and Python i make request on diffrent sites. I always get following error: Access to XMLHttpRequest at 'site' from origin 'site2' has been blocked I already tried diffrent things. I installed django-cors-headers and edited my files: Settings.py: 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # 'webpack_loader', 'corsheaders', 'projects', 'viewer', 'api_manager', ] MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.RemoteUserMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] In my HTML i added following to the form: <form class="d-flex flex-column" id="loginForm"> {% csrf_token %} </form> With the following method i was able to get a CSRF Token: static getCookie(name) { let cookieValue = null; if (document.cookie && document.cookie !== '') { let cookies = document.cookie.split(';'); for (let i = 0; i < cookies.length; i++) { let cookie = cookies[i].trim(); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) === (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } And the call which needs CORS i already tried to add the correct Headers: xhr.addEventListener('readystatechange', function () { if (this.readyState === 4) { if (this.status != 200) { console.log("Error", this.statusText); } } … -
I need help using django_cron
I am currently working with HDFS, Apache Livy and Django, the goal of this is to send a request to get some code running which is stored in HDFS and which calls Livy to create Batches. For now, everything is working, I have a basic wordcount stored in HDFS, with a .txt file, and on a htlm page I just have a simple button to click on to launch the whole process. I succeed in creating the wordcount result, and my next step is to get informations from Livy, for instance the ID of the sessions (or batches) currently starting/running/dead/success some sort of callback, but I need the it to self actualize so i can know what states are every sessions in. To do so, I thought I could use Django-cron, therefore I can't manage to set it correctly. I have no errors but nothing more is happening. Could anybody help me to understand what I'm missing ? Currently working on Centos7 but I'm using a conda environment in python 3.6, with django latest release, so are livy and HDFS (latest release) Here are my current files : livy.html {% load static %} <html> <body> <div id="div1"> {{result.sessions}} </div> <form … -
How do i add this feature to my Django project?
I'm creating a social media platform with Django, and so far i have it that users can sign up and sign in, however i want to make it so that when a user is online, it will pop up to all other users that this user is online. Does anyone have any tips on how i'd go about this? Thanks. -
Django bulk update with data two tables over
I want to bulk update a table with data two tables over. A solution has been given for the simpler case mentioned in the documentation of: Entry.objects.update(headline=F('blog__name')) For that solution, see https://stackoverflow.com/a/50561753/1092940 Expanding from the example, imagine that Entry has a Foreign Key reference to Blog via a field named blog, and that Blog has a Foreign Key reference to User via a field named author. I want the equivalent of: Entry.objects.update(author_name=F('blog__author__username')) As in the prior solution, the solution is expected to employ SubQuery and OuterRef. The reason I ask here is because I lack confidence where this problem starts to employ multiple OuterRefs, and confusion arises about which outer ref it refers to. -
Creating an installable Django app with a 3rd party dependency
I am in the process of creating an installable Django app on pypi which can be added to INSTALLED_APPS. The app works correctly up to this point. The problem now is that I wish to use Django Rest Framework within my app. Does this mean that users will have to add my app as well as Django Rest Framework to their INSTALLED_APPS when installing my app? Is there a way to simply add my app to INSTALLED_APPS without the user being aware of or needing to worry about anything else. They don't need to know that I use Django Rest Framework under the hood? Django Rest Framework will have been installed when the user pip installs my package. -
stuck on : "System check identified 1 issue (0 silenced)." django app with mysql DB
setup a django opensource project fromhere as a docker container with sql db and everything build fine. until the final stage,the server won't go up. Dockerfile: # Preparation RUN apt-get update # Install server dependencies RUN apt-get install -y curl git git-core python-virtualenv gcc python-pip python-dev libjpeg-turbo8 libjpeg-turbo8-dev zlib1g-dev libldap2-dev libsasl2-dev swig libxslt-dev automake autoconf libtool libffi-dev libcairo2-dev libssl-dev RUN pip install virtualenv --upgrade #RUN apt install libjpeg8-dev zlib1g-dev -y libcairo2 RUN pip install pillow # Install database Run apt-get install -y libmariadbclient-dev zlib1g-dev libssl-dev # Install main dependencies Run apt-get install -y libffi-dev libxslt-dev libsasl2-dev libldap2-dev Run apt-get install -y libmariadbclient-dev zlib1g-dev python-dev libssl-dev python-virtualenv # Install other useful tools RUN apt-get install -y git vim sudo curl unzip RUN apt-get install -y sqlite3 # Cleaning RUN apt-get clean RUN apt-get purge ADD settings_local.py /root/settings_local.py # Install the backend RUN mkdir ~/badgr \ && cd ~/badgr \ && git clone https://github.com/concentricsky/badgr-server.git code \ && cd code \ && pip install -r requirements.txt \ && cp /root/settings_local.py apps/mainsite/ EXPOSE 8000 docker-compose.yml: version: '3' services: db: image: mysql:5.7 environment: - MYSQL_DATABASE=libraries - MYSQL_ROOT_PASSWORD=root - MYSQL_PASSWORD=root ports: - '3306:3306' volumes: - /var/lib/mysql webapp: build: . volumes: - .:/code links: - db ports: … -
how to separate between cards using bootstrap4
i have a template that display list of data stored from the database as a cards using bootstrap 4. the problem is that it display cards stacked above each other this is the problem list.html {% block body %} <div class="container"> <div class="row"> {% for obj in object_list %} <div class="col-md-4 p-2"> <div class="card bg-light text-right"> <div class="card-header"> <h2>hdhdh: {{ obj.suspect_name}} </h2> </div> <div class="card-body"> <h4 class="card-title"> fna :{{obj.suspect_father_name}}</h4> <h6 class="card-subtitle mb-2">mna :{{obj.suspect_mother_name}}</h6> <p class="card-text">{{obj.summary}}</p> <a href={{obj.get_absolute_url}} class="btn btn-danger">details</a> <a href="{% url 'update' obj.pk %}" class="btn btn-danger">edit</a> {%include 'blog/delete.html' %} <a href="{% url 'delete' obj.pk %}" class=" btn btn-danger confirm-delete" title="Delete" data-toggle="modal" data-target="#confirmDeleteModal" id="deleteButton{{obj.id}}">delete</a> </div> </div> </div> {% endfor %} </div> -
Left Join on multiple columns Django model ORM foreign key
I am trying to understand the Django ORM. I have 3 models that I am trying to join. class User(models.Model): id = models.IntegerField(primary_key=True) gender = models.CharField(max_length=25) class Movie(models.Model): id = models.IntegerField(primary_key=True) title = models.CharField(max_length=300) genre = models.CharField(max_length=300) class Recommendation(models.Model): id = models.IntegerField(primary_key=True) user = models.OneToOneField(User, on_delete=models.CASCADE) rec1 = models.IntegerField() rec2 = models.IntegerField() Now in my Recommendation I have 2 fields that are recommendations (rec1 and rec2) and correspond to Movie.id. I want to join these models to be able to show the movie.title and movie.genre for each recommendation (for each user, with their user information). I tried using two Foreign Keys, but am wondering if I fully understand that concept. In SQL I would use a LEFT JOIN on rec1 = Movie.id and rec2 = Movie.id, but I don't understand how to implement this in the Django ORM. Expected outcome User 1, gender 'F': recommendations 'Lion King', 'Batman' -
How to update ModelAdmin variable on every page refresh?
I have to fetch some data from external API and display it as columns in django admin page. I tried running code as assigning to a class-level variable but it only fetched data at the start of django server and it doesn't work as a function-level call, because somehow requests library freezes django here. So both of these examples won't work for me: class NewModelAdmin(admin.ModelAdmin): variable = requests.get(...) # it's executing only once class NewModelAdmin(admin.ModelAdmin): def some_column(self, obj): variable = requests.get(...) # it's freezing the app ... some_column.short_description = 'Some Column' some_column.admin_order_field = 'some_column' -
Custom admin to filter user transactions
How to create user report for multiple users in the Django Admin? I have an app which filters the transactions from the user itself. But as the administrator, I also want to see the transactions for all of my users. How can I do that in the Django-admin? Do I need to custom the admin.py file? or make another custom views for the admin itself? The flow will look like this: +-----------------+ +-----------------+ | User 1 +--------->+ List trx user 1 | +-----------------+ +-----------------+ | User 2 +--------->+ List trx user 2 | +-----------------+ +-----------------+ | User 3 +--------->+ List trx user 3 | +-----------------+ +-----------------+ How can I achieve it? here's my views.py @login_required() def ReportView(request): if request.is_ajax(): endDate = None startDate = request.GET.get('startDate') if request.GET.get('endDate') == '' or request.GET.get('endDate') is None : endDateConverter = datetime.today() else: endDate = request.GET.get('endDate') endDateConverter = datetime.strptime(endDate, "%Y-%m-%d").date() startDateConverter = datetime.strptime(startDate, "%Y-%m-%d").date() from_user = DaftarTransaksi.objects.filter(user_id=request.user.id, created__date__gte=startDateConverter, created__date__lte = endDateConverter) daftar_barang = ListProductTransaksi.objects.filter(transaksi_id__in=from_user) return render(request, 'report_details.html', {'daftar_barang': daftar_barang, 'num': startDateConverter}) from_user = DaftarTransaksi.objects.filter(user_id=request.user.id) daftar_barang = ListProductTransaksi.objects.filter(transaksi_id__in=from_user) context = { 'daftar_barang': daftar_barang, 'from_user': from_user, } return render(request, 'report.html', context) And this is my admin.py from django.contrib import admin from home.models import DaftarBarang, DaftarTransaksi, ListProductTransaksi admin.site.site_header … -
Auto insert the logged user in a Foreign Key
I'm creating an API for something like 9gag project that I'm doing, and upon uploading a post the logged user to be auto inserted in the created_by field that I have in my Post model I've tried ton of things, from the Django doc's -- https://docs.djangoproject.com/en/2.2/topics/class-based-views/generic-editing/#models-and-request-user , tried overriding the save_model method in the admin.py but nothing seems to work. models.py class Post(models.Model): created_by = models.ForeignKey(User, on_delete=models.CASCADE, editable=False, blank=True) title = models.CharField(max_length=200) tag = models.CharField(max_length=20, choices=TAGS) uploaded = models.DateTimeField(auto_now=True) likes = models.IntegerField(default=0, unique=False, blank=True, editable=False) image = models.ImageField(upload_to='images', blank=False) views.py class PostCreated(LoginRequiredMixin, CreateView): model = Post fields = ['id'] def form_valid(self, form): form.created_by = self.request.user.pk return super().form_valid(form) and when I upload something i always get "created_by": null -
Use ManyToMany field in add object raise needs to have a value for field "id" before this many-to-many relationship can be used
I have two models : Exam and Question. Each question has point that automatically calculate in each exam. So this is my files: #Models.py class Exam(models.Model): questions = models.ManyToManyField(Question) title = models.CharField() class Question(models.Model): title = models.CharField() answer = models.TextField() points = models.PositiveSmallIntegerField() #Forms.py class ExamForm(ModelForm): class Meta: model = Exam fields = '__all__' #Views.py if form.is_valid(): new_exam = form.save(commit=False) # Some modify goes here. new_exam.save() form.save_m2m() return redirect('view_exam') I did customize save() method of Exam model to this: def save(self, *args, **kwargs): self.point = 0 for question in self.questions: self.point += question.point super(Exam, self).save(*args, **kwargs) But I got this error: "<Exam: NewObject>" needs to have a value for field "id" before this many-to-many relationship can be used. How can I do this without raising any error? -
Communicate back and forth between python, pyside2 desktop app and django app
I currently have a desktop app written in Python 3 using pyside2 and a web app written in Django. The Django app is currently deployed using Apache server. I want to be able to send data back and fort between these apps. For example I have a button which now loads a file withe JSON objects. Instead of loading a file I would like to load this information from my django app. The objects in the JSON file is the same as the attributes to the models in the Django app. When there is changes made to these objects I would like to load the data back to the Django app and update the database with the new values. Can this be achieved using Websockets, or should I connect both projects to the same database? I know that apache don't support websockets. Is the best choice to go for Daphne if websockets is the way to go? I fairly new to Python and Django and my previous coding has always been ether web or desktop. Never tried to combine the two so I don't really know where to start or what to look for. Any suggestions is much appreciated! -
Django appends to host instead of website name
I'm trying to use the @user_passes_test(function, login_url) decorator on a production server, but it seems login_url is not getting appended as host/mysitename/login_url but only as host/login_url. Everything works correctly from a local machine, though. The problem only appears when I'm trying to run it on the server. I have already set LOGIN_URL in the settings.pyfile, but the problem is that I need to send the user to a different login page, since they need to be authenticated via LDAP. Changing login_url to /mysitename/login_url works, but isn't there a better, more elegant solution to this? -
How to Clear Up Lost Websocket Connections When Using Django Channels + NginX
I am using Django channels for websocket connections. When websocket is properly closed from client-side, consumers' disconnect() is called and the connection is cleared up. However, when it is not, disconnect() is never called and the connection remains on the server side. I thought of three ways to solve this issue. 1) Application level: I could make a Django model that tracks each session(websocket connection)'s online status and call it from disconnect(). async def disconnect(self): Online.objects.filter(channel_name=self.channel_name).delete() Since not all connections would be properly closed with disconnect() I should set up a celery task and run it every 60 seconds to see if there are outdated connections in the Online model. The cons of this approach is I have to hit the db quite often to maintain the Online list of channel names. NginX server level: I was not successful to find a solution of this approach. I am currently using just a Django deployment server, so I have not tried out, but I looked up Stackoverflow to prepare the setting. If there is a auto-closing-connection setting for keepalive, I will not need to implement the application-level solution. But I could not find a good answer. What I have found so … -
Adding record of page views and details of change to django_admin_log
We are using LogEntry/django_admin_log and recording additions, changes and deletions made from Django Admin. However we have two issues we need to address: 1.) Changes record only the field that changed. Not the old and new values. We would like to add the specific details of all changes. 2.) We would like to record an action in this log every time a page is viewed on the Django Admin panel. How would it be best to proceed? We are happy to do some work to extend the existing functionality of this, or we are happy to move to a completely new 3rd part module if necessary, or write our own. But would like some guidance from some experts? -
Local django server - login fails with new safari version
I've updated my MacBook to the latest Mojave 10.14.6 version. Since that update I'm not able to login into my locally installed django webserver using Safari anymore. I always get the error message "Invalid CSRF token". With Chrome it's working. -
'User' object has no attribute 'invitations_recived'
I am trying to show the invitations in a web tictactoe game on the player home page. What I get is following error: AttributeError at /player/home/ 'User' object has no attribute 'invitations_recived' Request Method: GET Request URL: http://127.0.0.1:8000/player/home/ Django Version: 2.2.3 Exception Type: AttributeError Exception Value: 'User' object has no attribute 'invitations_recived' Exception Location: E:\PycharmProjects\django-fundamentals\venv\lib\site-packages\django\utils\functional.py in inner, line 257 Python Executable: E:\PycharmProjects\django-fundamentals\venv\Scripts\python.exe Python Version: 3.7.1 Python Path: ['E:\\PycharmProjects\\django-fundamentals\\ticktactoe', 'E:\\PycharmProjects\\django-fundamentals\\venv\\Scripts\\python37.zip', 'C:\\Users\\ja\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs', 'C:\\Users\\ja\\AppData\\Local\\Programs\\Python\\Python37-32\\lib', 'C:\\Users\\ja\\AppData\\Local\\Programs\\Python\\Python37-32', 'E:\\PycharmProjects\\django-fundamentals\\venv', 'E:\\PycharmProjects\\django-fundamentals\\venv\\lib\\site-packages', 'E:\\PycharmProjects\\django-fundamentals\\venv\\lib\\site-packages\\setuptools-39.1.0-py3.7.egg'] I tried double checking the syntax, names and the similiar titled posts: django 'User' object has no attribute 'user' Why am I getting AttributeError: Object has no attribute AttributeError: 'module' object has no attribute 'tests' views.py from django.shortcuts import render, redirect, get_object_or_404 from django.contrib.auth.decorators import login_required from gameplay.models import Game from .models import Invitation from .forms import InvitationForm @login_required def home(request): my_games = Game.obejcts.games_for_user(request.user) active_games = my_games.active() invitations = request.user.invitations_recived.all() return render(request, 'player/home.html', {'games': active_games, 'invitations': invitations}) home.html {% if invitations %} <div class="list-group"> {% for inv in invitations %} <a class="list-group-item" href="{% url 'player_accept_invitation' id=inv.id %}"> {{ inv.from_user.username }} hast invited you to a game </a> {% endfor%} </div> {% else %} <p>You have no invitations</p> {% endif %} I expect to see the … -
Ajax Django file preview
I want to upload a xlsx file through a simple html form and pass some values for a Django function to process. Since I have no knowledge of Ajax or any idea to do the following I am seeking your help. I want to upload the file and pass some values. After I submit the file/values I want a page to load which would have a set of output values as a preview of sorts. I've heard that Ajax is the way but I have no idea. Please help me either write it or give me a step by step guide for it. p.s I have no JS knowledge. <center> <form method="post" enctype="multipart/form-data" action ='File/'> {% csrf_token %}<br><br> Select a file: <input type="file" name="vendorfile"><br> Start: <input type="text" name="start_value" ><br> Dest: <input type="text" name="dest_col" ><br> Num: <input type="text" name="num_col" ><br> Rate: <input type="text" name="rate_col" ><br> <button type="submit" >Preview</button> </form> </center> <!DOCTYPE html> <html lang='en'> <head> <meta charset='UTF-8'/> <meta name='viewport' content='width=device-width, initial-scale=1.0'/> <meta http-equiv='X-UA-Compatible' content='ie=edge'/> <title>Document</title> </head> <body> {% for k,v in _empty %} {% for x,y in v %} {{ k }}::<br> {{ x }}::<br> {{ y }}:: {% endfor %} {% endfor %} </body> </html> url(r'^(?i)File/$', FileView.as_view(), name='File-Page'), url(r'^(?i)xls/$', views.xlsparser, … -
i want to plot data from database dynamically as it is updating every second, i want that that to be shown every second in front end in chart
my query is what is the best process to build dynamic graph from database in django, as database is updaing every second and data should be fetched every second and plotted dynamically to graph. <html> <head> <title></title> <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> </head> <body> <div id="myDiv"></div> <script> var trace1 = { x: [{% for datas in all_data %}{{datas.current}},{% endfor %}], y: [{% for datas in all_data %}{{datas.voltage}},{% endfor %}], type: 'line', }; var data = [trace1]; Plotly.newPlot('myDiv', data, {}, {showSendToCloud: true}); </script> </body> </html> from django.http import HttpResponse from django.shortcuts import render from .models import EmsDb150 class fetch: def __init__(self): pass def database(self): self.all_data = EmsDb150.objects.all() var = {'all_data' : self.all_data} return var def index(request): return render(request, 'login.html') def test(request): ob = fetch() r = ob.database() return render(request, 'test.html', r) def details(request): ob = fetch() r = ob.database() return render(request,'details.html', r) -
Django: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path
I'm a beginner to django and trying to figure out how to incorporate ckeditor into a blog. I'm stuck at the step of copying ckeditor static files into the static root. No matter what fix I try, when I run python manage.py collectstatic, I get the error: ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path. I've tried numerous online guides for ckeditor, read the django documentation on static files, and searched for an answer to this issue, but have not been able to find any answer which fixes the error. Here is my current settings.py import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates') # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = *** # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', #My apps 'blogger', 'ckeditor', 'ckeditor_uploader', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'blogs.urls' TEMPLATES = [ { … -
Django importing a value of a Class Object to another Class in the same Model
I am new to DJANGO, And i got stuck with a problem in my models. I tried a lot, but couldnt find a way to get the result. name = models.CharField(max_length=100) img = models.ImageField(upload_to='pics') desc = models.TextField() price = models.IntegerField() offer = models.BooleanField(default = False) from this above Model class I want the same value of 'name' field in the below Model class class Destination_individual(models.Model): # name = models.CharField(max_length=100, default = None) name = img = models.ImageField(upload_to='pics_indiavidual') caption = models.CharField(max_length=100) img2 = models.ImageField(upload_to='pics_indiavidual') caption2 = models.CharField(max_length=100) img3 = models.ImageField(upload_to='pics_indiavidual') caption3 = models.CharField(max_length=100) img4 = models.ImageField(upload_to='pics_indiavidual') caption4 = models.CharField(max_length=100) img5 = models.ImageField(upload_to='pics_indiavidual') caption5 = models.CharField(max_length=100) My first Class (Destination) is migrated to the Server, and I want the Name field value from that database(Destination) to be shown in the Name field of Destination_individual database. Please guide me how to do that. Many Thanks. -
django/wagtail makemigrations does not work once apps move to custom folder
I am new to Django/wagtail project, wants to change the project structure by putting all the apps inside custom apps folder and inside the module-specific (projects) folder as I need to merge 3 different applications. enter image description here here common folder contains apps which are common to all 3 projects I am trying to run makemigrations and migrate which is not giving any out put , I also tried putting init.py and models.py inside common and apps folder to treat as package (which I don't want) ,still no results can someone help me out with my new structure ,am I doing anything wrong ? -
Fetch Request to Django Server CORS blocks only one view
I have a react frontend running on localhost port 8080 and a django backend on port 8000. I build an API that I call through javascript fetch requests. The django backend has cors-headers installed and set to CORS_ORIGIN_ALLOW_ALL=True. The fetch does work for all endpoints in the API, except a new endpoint called metrics I just added. Once I call this view on a GET request I recieve the following error: Access to fetch at 'http://localhost:8000/api/v1/metrics/' from origin 'http://localhost:8080' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response. I use the same fetch method to call all API endpoints: return fetch(url, { method: 'GET', mode: 'cors', cache: 'no-cache', credentials: 'same-origin', headers: { 'Authorization': 'Token ' + token }, redirect: 'follow', referrer: 'no-referrer', }) Also the call does work through postman, however not from the React-App. I suppose the error is originated in the preflight OPTIONS response the django server gives, however I fail to see how the response is different from other endpoints. The definition of the view is: class ListMetrics(generics.ListCreateAPIView): '''Lists and creates new Metrics.''' queryset = models.Metric.objects.all() serializer_class = serializers.MetricSerializer (Authorization is enabled in the django settings by default … -
redirect reverse with kwarg; pattern not found, but url works
I try to redirect to a url on some condition and get the following error: Error: Reverse for ... url="/nl/payments/mollie/invoice-payment-success/3248db26-fdce-4590-a5b9-9314fe30019c/" not found. ' ... is not a valid view function or pattern name. However when I test the url in address bar it works fine. Here's my redirect: if obj.status == obj.PAID: return HttpResponseRedirect(reverse('payments:success_invoice_payment', kwargs={'uuid': invoice.uuid})) and urls: path('mollie/invoice-payment-success/<uuid>/', SuccessInvoicePayment.as_view(), name="success_invoice_payment" ) Any tips are much appreciated!