Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to create multiple objects of same model by triggering django post_save signal
I'm trying to create 52 objects of this model, (each corresponding 52 weeks of the year): from django.db.models import OneToOneField, TextField, IntegerField, Model, CASCADE from main_app.models import Master class WeeklyMemo(Model): master = OneToOneField(Master, on_delete=CASCADE) week_of_year = IntegerField(null=True) comments = TextField(null=True) and my signal function is like this (when I do this, I get only one object instead of expected 52; I get only week 1): from django.db.models.signals import post_save from django.dispatch import receiver from main_app.models import Master from memo.models import WeeklyMemo @receiver(post_save, sender=Master) def create_weekly_memo_objects(sender, instance, **kwargs): for week in range(1, 53): WeeklyMemo.objects.create(master=instance, week_of_year=week) and when I put the for loop in outer scope, (I get only one object instead of expected to 52; I get only week 52) for week in range(1, 53): @receiver(post_save, sender=Master) def create_weekly_memo_objects(sender, instance, **kwargs): WeeklyMemo.objects.create(master=instance, week_of_year=week) What can I do to fix this, so that 52 objects of WeeklyMemo class are created? -
Why matplotlib draws me the new graphic superimposing the old one?
I'm working on django project and using the matplotlib library. Theoretically I have created a filter where you can choose the day and and "node" that you want to graph and with this information a pythonscript is executed that together with pandas and matplotlib creates a graph. The values of "node" and "day" arrive correctly to the script, and this generates the graphic well. But the only thing wrong is that instead of overwriting the old image (with the previous graphic), draw the new lines on it. Next I show an image of how it looks. As you can see, each line is equivalent to a different day, because it has been overlapping the different tests I have done. Can anyone tell me where I fail? Below I attach code def bateria2(node, day): csv_path = os.path.join(os.path.dirname(__file__), '..\\data\\csv\\dataframe.csv') df = pd.read_csv(csv_path) mes, anyo = 12, 2019 new_df = df[(df['Dia'] == day) & (df['Mes'] == mes) & (df['Año'] == anyo) & (df['Node name'] == node)] if len(new_df) > 0: #os.remove('static\\img\\bateria2.png') x = new_df['Hora[UTC]'].tolist() y = new_df['Bateria'].tolist() title = 'Carga/Descarga de la batería día '+str(day)+'/'+str(mes)+'/'+str(anyo)+' de '+str(node) plt.title(title) plt.xlabel('Hora [UTC]') plt.ylabel('Batería') #plt.legend((y)(node)) plt.plot(x,y) plt.xticks(x, rotation='vertical') plt.savefig('static\\img\\bateria2.png',transparent=True) return 1 else: return 0 Basically what … -
url routing in django?
I am creating website in django from 2 to 3 pages so the problem is in the html part when linking the pages in html there is two pages now ( index " the main home page for the site - about) so when I run the server it open the index page and when I click on about link the url will be (www.xxxx.com/about/about) and when I click on the index link the url will be( www.xxxx.com/about) not the index page . so the two link direct me to the about page but with different url here is the url in the main project : urlpatterns = [ path('',include('pages.urls')), path('about/',include('pages.urls')), path('admin/', admin.site.urls), ] and the urls.py in pages app: urlpatterns = [ path('',views.index , name='index'), path('about/',views.about , name='about'), ] and the views.py in pages app : def index(reqouest): return render(reqouest,'pages/index.html') def about(reqouest): return render(reqouest ,'pages/about.html') and the about html page : <section id="bc" class="mt-3"> <div class="container"> <nav aria-label="breadcrumb"> <ol class="breadcrumb"> <li class="breadcrumb-item"> <a href="{% url 'index' %}"> <i class="fas fa-home"></i> Home</a> </li> <li class="breadcrumb-item active"> About</li> </ol> </nav> </div> </section> p.s I put the html pages in template/pages folder -
i'm writng regist html ,django + ajax,partial load page,but memory is increased and the page is stuck
django veiews def regist(request): hashkey = CaptchaStore.generate_key() image_url = captcha_image_url(hashkey) captcha = {'image_url': image_url, 'hashkey':hashkey} if request.POST: username = request.POST['username'] password = request.POST['password'] password1 = request.POST['password1'] key = request.POST['hashkey'] capt = request.POST['captcha'] if username != '' and password != '' and password1 != '': if len(password) >= 6: if captchautil.is_valid(capt, key): check_user = User.objects.filter(username=username) if not check_user: if password == password1: user = User.objects.create_user(username=username, password=password) userprofile = UserProfile.objects.create(user=user, name=username, level='Bronze') msg = '注册成功,现在去登录吧' else: msg = '密码不一致,请重新输入' else: msg = '用户名已存在,请重新输入' else: msg = '请输入正确的验证码' else: msg = '密码长度至少6位' else: msg = '请输入用户名与密码' return HttpResponse(msg) return render(request, 'regist.html', locals()) html code <form action="/regist/" method="post" id="myForm"> {% csrf_token %} <input type="text" id='username' name="username"> <input type="password" id='password' name="password"> <input type="password" id='password1' name="password1"> <input id='captcha' name="captcha" required> <input value="{{hashkey}}" type="hidden" name="hashkey" id='hashkey'> <button type="submit" name="click" id='click'>注册</button> script code: $(document).ready(function(){ $.ajax({ type: "POST", url: "{% url 'regist' %}", data: { "username": username, "password": password, "password1": password1, "key": hashkey, "capt": captcha, "csrfmiddlewaretoken": '{{ csrf_token }}', }, dataType: "text", success:function(response){ alert(response); $("#myForm").submit(); }, }); My intention is to load the returned results directly into 'div', without loading all html. But when I submit it, the whole page gets stuck directly, and the browser memory goes up. … -
How to configure uwsgi to work with a specific version of python?
I use Debian 9 uwsgi and nginx as a server for several Django sites. By default, Debian has python 3.5. uwsgi installed globally sudo -H pip3 install uwsgi I've decided to transfer the sites to python 3.7. To do this, I installed a new version of python 3.7 from the source files into the /usr/local/bin/python3.7 folder. I also recreated a virtual environment (with the same name as before) mkvirtualenv -p /usr/local/bin/python3.7 protrack But now I've got an error , uwsgi still uses python 3.5 . ● uwsgi.service - uWSGI Emperor service Loaded: loaded (/etc/systemd/system/uwsgi.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2019-12-13 15:06:55 UTC; 3 days ago Process: 2102 ExecStartPre=/bin/bash -c mkdir -p /run/uwsgi; chown gk:www-data /run/uwsgi (code=exited, status=0/SUCCESS) Main PID: 2106 (uwsgi) Status: "The Emperor is governing 1 vassals" Tasks: 7 (limit: 4915) CGroup: /system.slice/uwsgi.service ├─2106 /usr/local/bin/uwsgi --emperor /etc/uwsgi/sites ├─2110 /usr/local/bin/uwsgi --ini myblog.ini ├─2112 /usr/local/bin/uwsgi --ini myblog.ini ├─2113 /usr/local/bin/uwsgi --ini myblog.ini ├─2114 /usr/local/bin/uwsgi --ini myblog.ini ├─2115 /usr/local/bin/uwsgi --ini myblog.ini └─2116 /usr/local/bin/uwsgi --ini myblog.ini Снж 16 16:21:59 server-1537436012497-s-1vcpu-1gb-fra1-01 uwsgi[2106]: thunder lock: disabled (you can enable it with --thunder-lock) Снж 16 16:21:59 server-1537436012497-s-1vcpu-1gb-fra1-01 uwsgi[2106]: uwsgi socket 0 bound to UNIX address /run/uwsgi/protrack.sock fd 3 Снж 16 16:21:59 server-1537436012497-s-1vcpu-1gb-fra1-01 uwsgi[2106]: … -
Logging javascript exceptions from Django development server
Symptom: JavaScript exception fails silently. JS file is loaded statically into Django html template. When the html page loads, the JS runs until it hits an exception, at which point it quits and the html loads without the rest of the JS file. No message is printed to the console hosting the server. The server was started with python manage.py runserver which will log python exception on start-up (if for example there is a syntax error in admin.py). I added python errors at runtime to test if the console would spit them out which they did. So I know the server will display runtime errors. I also added JS exceptions to the beginning of the static file to see if they would print but they also silently failed. Although I was able to find the bug by adding a catch block and alerting the exception output to the webpage, I would like to know if there is a way to have the JS exceptions print to the console similar to the python exceptions. My logging settings in settings.py: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console': { 'class': 'logging.StreamHandler', }, }, 'loggers': { 'django': { 'handlers': ['console'], 'level': … -
How can I store data in djnago of HTML dynamic form made by js
I have studied about formset and formfactory but I am unable to handle data with javascript below is my html form code and javascript file. basically I want to store the ****Div class= "inventory"**** table as one form and rest of the details as other form. since the inventory table is dynamic by js I dont know how to store data using js **********HTML CODE*******************************************************************8 <html> <head> <meta charset="utf-8"> <title>Invoice</title> <link rel="stylesheet" href="style.css"> <link rel="license" href="https://www.opensource.org/licenses/mit-license/"> <script src="script.js"></script> </head> <body> <header> <h1>Invoice</h1> <address contenteditable> <p>Company name</p> <p>Address</p> <p>GST no.</p> <p>Phone no.</p> <p>Email</p> </address> <span><img alt="Logo here" src="http://www.jonathantneal.com/examples/invoice/logo.png"><input type="file" accept="image/*"></span> </header> <article> <h1>Recipient</h1> <address contenteditable> <p>Recipient Company name</p> <p>Address</p> <p>Phone no.</p> <p>GST no.</p> <p>Email</p> </address> <table class="meta"> <tr> <th><span contenteditable>Invoice #</span></th> <td><span contenteditable>101138</span></td> </tr> <tr> <th><span contenteditable>Date of Issue</span></th> <td><span contenteditable>January 1, 2019</span></td> </tr> <tr> <th><span contenteditable>Due Date</span></th> <td><span contenteditable>December 1, 2019</span></td> </tr> <tr> <th><span contenteditable>Amount Due</span></th> <td><span id="prefix" contenteditable>₹</span><span>600.00</span></td> </tr> </table> <div id="line"><hr style="" /></div> <table class="inventory"> <thead> <tr> <th><span contenteditable>Item</span></th> <th><span contenteditable>HSN code</span></th> <th><span contenteditable>Description</span></th> <th><span contenteditable>Rate</span></th> <th><span contenteditable>Quantity</span></th> <th><span contenteditable>Price</span></th> </tr> </thead> <tbody> <tr> <td><a class="cut">-</a><span contenteditable>Front End Consultation</span></td> <td><span contenteditable>123456</span></td> <td><span contenteditable>Experience Review</span></td> <td><span data-prefix>₹</span><span contenteditable>150.00</span></td> <td><span contenteditable>4</span></td> <td><span data-prefix>₹</span><span>600.00</span></td> </tr> </tbody> </table> <a class="add">+</a> <table class="balance"> … -
How to change timepicker data return?
I have a form that uses a datetimepicker, however, I realized that, most of the time, the user will be submitting only a timestamp, and not really a date, unless an admin creates a record which is from a different page. I changed the datetimepicker to be a timepicker, so that it is less complicated to use. However, we have all the logic set to work with datetime, and timepicker only returns the time. Is there a way I can change the timepicker so that it returns today's date along with the actual time they are submitting, but without modifying the base timepicker? It is used in other pages so I would rather not mess with other parts, but not sure how I can achieve this. -
Python gc.collect taking almost all of the time in django api call
I have an api which processes some data using pandas and then sends back the result however on closer inspection I saw that the Api was taking around 1.5mins. I am using import_module to load a module which then has this gc.collect problem. -
Django Rest Framework - Pagination using the last item in the page
I use Pagination in my Django Rest Framework project. The pagination type I have chosen is LimitOffsetPagination and the output looks like this: { "count": 60, "next": "http://127.0.0.1:8000/groups/getAllGroups/?limit=10&offset=10", "previous": null, "results": [ { "id": 1, "groupName": "MyBestFriends" }, { "id": 2, "groupName": "MySchoolFriends" }, { "id": 3, "groupName": "MyBuddies" }, { "id": 4, "groupName": "Buddies4LIfe" }, { "id": 5, "groupName": "Colleagues" }, { "id": 6, "groupName": "MyColleagues" }, { "id": 7, "groupName": "MyFootballFriends" }, { "id": 8, "groupName": "MyTenniesFriends" }, { "id": 9, "groupName": "MyGirlfriends" }, { "id": 10, "groupName": "MyGolfClub" } ] } This is the result of a query like http://127.0.0.1:8000/groups/getAllGroups/?limit=10. For the page with limit 10, I would type this http://127.0.0.1:8000/groups/getAllGroups/?limit=10&offset=10 and this would give me the elements from 11 to 20. So, my question is: How can I tell Django that the offset should be based on the groupName ? Is that possible ? So, to display the elements from 11 to 20, can I type something like http://127.0.0.1:8000/groups/getAllGroups/?limit=10&groupName=MyGolfClub as URL query (instead of http://127.0.0.1:8000/groups/getAllGroups/?limit=10&offset=10) ? -
tuple' object has no attribute 'get'
And this is the traceback django provides me. ''' ` if getattr(response, 'xframe_options_exempt', False): return response response['X-Frame-Options'] = self.get_xframe_options_value(request, response) return response def get_xframe_options_value(self, request, response): """ Get the value to set for the X_FRAME_OPTIONS header. Use the value from the X_FRAME_OPTIONS setting, or 'DENY' if not set. This method can be overridden if needed, allowing it to vary based on the request or response. """ return getattr(settings, 'X_FRAME_OPTIONS', 'DENY').upper()`''' I have a hard time figuring out why this error occurs. How can i find out where that tuple is in my code? THIS IS ONE VIEW OF ONE APPLICATION from django.shortcuts import render from django.http import HttpResponse from .models import destination Create your views here. def index(request): dests=destination.objects.all() return render(request,'index.html',{'dests':dests}), NOW THIS IS SECOND VIEW from django.http import HttpResponse from django.shortcuts import render def HOMEE(request): return render(request,'HOMEE.html'), -
Django - Using the object list in the admin panel somewhere else
I achieved to list objects of my model class at "/admin/app1/influencer/" and i can sort objects by fields, add new objects, update and delete existing objects; that's cool for me as i'm new to Django. What i want to accomplish is make a page that doesn't require admin privileges (no CRUD operations except adding a new object) and lists the objects, sorts them, filters them etc. That page only should require normal user login. In order to do that i created a class view: class InfluencerList(ListView): model = Influencer Added this line to my apps url.py: path('influencers/', InfluencerList.as_view()), Then i created an html file in my apps templates folder and listed all the objects in table rows with that: {% for influencer in object_list %} I'm not sure that this is the best way to do that. That stuff must be already written somewhere in Django and it will take some time for me to add searching, sorting, filtering. I searched on the web that stuff but only found what i have already done (just listing some data in rows). What approach should i use in this kind of situation? Thanks for any advice and help. -
HOW TO DISPLAY IN DJANGO WEB APP A PANDAS PLOTTING (LIKE BOX PLOT OR SCATTER PLOT) BUILD IN BACKEND
[URGENT FOR MY INTERNSHIP] Hi, I'm new in Django. I've to build an application wich show pandas dataframe plotting (like line plot, scatter plots, box plot, histogram, etc.) in the user's browser when they upload their data (a time serie in such) but I don't know how to serve them to the frontend after generating them in frontend with pandas. Someone can help me please. Thanks. -
Avoid Token validation Django RestFramework
I am using Bearer token in Django. I created a resource that must return some information if user is logged in and if user is not must return another information. This is my Django Configuration REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_simplejwt.authentication.JWTAuthentication', ) } If I send an expired token or an invalid one. It should return some information and 200 OK. But internally, Django returns 401 Unauthorized. How can avoid that internal validation and call it whenever I want? -
How to Update only Time of a DateTimeField
I have a requirement where i only need to update the Time of the DateTimeField. Tried to search on internet but couldn't get much info. Can we do this in Django or its not possible? Thanks -
Django Windows IIS Fastcgi Deploy problem (wfastcgi TypeError: 'module' object is not callable)
Traceback (most recent call last): File "C:\...", linse 847, in main result = handler(record.params, response.start) TypeError: 'module' object is not callable why am i getting this error ? when use runserver everything is fine but with fastcgi not work :/ OS: Windows Server 2012 Django Version: 2.22 Environment Variables FastCGI Application Settings; DJANGO_SETTINGS_MODULE: website.settings PYTHONPATH: ||PROJECT_ROOT_PATH|| WSGI_HANDLER: website.wsgi -
How to access ManyToManyField value from django signal?
I have a following model and function signal_task which just outputs the test_users field objects on signal post_save class Test_Model(models.Model): test_users = models.ManyToManyField(User) def signal_task(self): print(self.test_users.all()) @receiver(post_save,sender=Test_Model) def Test_signal(sender,instance=None,created=False,**kwargs): if created: instance.signal_task() On Creating Test_Model objects, singal_task() executes which should output the User objects assigned to test_users, But it outputs the empty queryset <QuerySet []> -
multivaluedictkeyerror on django
I Want to submit my forms to database in django but i got error on multivaluedictkeyerror in 'user' on addBook 1.views.py : def addBook(request): user1 = request.POST["pengguna"] tanggal =request.POST["tanggal"] lama = request.POST["lama"] lap = request.POST["lap"] booking = Booking(pengguna=user1,tanggal=tanggal,lama=lama,lap=lap) booking.save() print("Submit Sukses") return render(request,'book.htm',args) models.py from django.db import models Create your models here. class Booking(models.Model): pengguna = models.CharField(max_length=2000) tanggal = models.DateTimeField() lama = models.IntegerField() lap = models.CharField(max_length=5) def __str__(self): return self.pengguna book.html(form) only {% csrf_token %} Pemesan Tanggal Lama Booking (jam) Pilih Lama Booking... 1 Jam 2 Jam 3 Jam 4 Jam enter code here Lapanganstrong text Pilih Lapangan Lapangan 1 Lapangan 2 Lapangan 3 Harga : Rp Book ! -
CSS styling of form input fields in Django
I am aware there are already a lot of other answered questions about this. After reading them, I came up with the following code, so that I can style my email input field in my user registration form and in my login form. Focus is on the "widget=forms.EmailField(attrs={'id': 'rmkinput'})", which, as far as I understand from the readings, should give me css accessibility: class UserRegForm(UserCreationForm) : email = forms.EmailField(widget=forms.EmailField(attrs={'id': 'inputfield'}), label='eMail Adresse') Nevertheless, when I "manage.py runserver", I get an error message: super().__init__(strip=True, **kwargs) File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\django\forms\fields.py", line 214, in __init__ super().__init__(**kwargs) TypeError: __init__() got an unexpected keyword argument 'attrs' I kept reading the documentation and the other stakcoverflow questions, but I just can't figure it out. Can anybody help? If more code is required to answer the question, let me know. Thanks! -
How to refresh inline form in Admin panel?
I have model (Category, Item, AttributeCategory,AttributeitemValue), when i add new Item, in item I have AttributeitemValueInline, then i change category in Item, i want get possible Attribute value for Item in which this item includes category. How I can dynamically get attribute from category? whtn creating Item? class AttributeItemValueInline(admin.TabularInline): model = AttributeItemValue class AttributeItemValueAdmin(admin.ModelAdmin): pass admin.site.register(AttributeItemValue, AttributeItemValueAdmin) class ItemAdmin(admin.ModelAdmin): inlines = [ AttributeItemValueInline, ] def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == "category": kwargs["queryset"] = Category.objects.filter(parent__isnull = False) return super().formfield_for_foreignkey(db_field, request, **kwargs) admin.site.register(Item, ItemAdmin) models.py class Category(models.Model): name = models.CharField(max_length = 255) slug = models.SlugField() parent = models.ForeignKey('self',on_delete = models.PROTECT, blank=True, null=True) def __str__(self): return self.name def __unicode__(self): return self.name class Item(models.Model): name = models.CharField(max_length = 255) slug = models.SlugField() description = models.TextField() price = models.DecimalField(max_digits=2,decimal_places=2) category = models.ForeignKey('Category', related_name='categories', on_delete=models.CASCADE) def __str__(self): return self.name def __unicode__(self): return self.name class Attribute(models.Model): name = models.CharField(max_length = 255) def __str__(self): return self.name def __unicode__(self): return self.name class Unit(models.Model): name = models.CharField(max_length = 255) def __str__(self): return self.name def __unicode__(self): return self.name class ImageItem(models.Model): picture = models.ImageField() item = models.ForeignKey('Item',on_delete=models.CASCADE) def __str__(self): return self.item.name + " picture" def __unicode__(self): return self.item.name + " picture" class AttributeCategory(models.Model): attribute = models.ForeignKey("Attribute", on_delete=models.CASCADE) category = models.ForeignKey("Category", … -
Is it possible to automatically create ViewSets and Serializers for each Model?
In our project we have a huge amount of models and some of them are still in the works. I would like to create our REST API using the Django Rest Framework but don't want to create a separate serializer class and ModelViewSet for each Model we have (as most of them should be accessible via API). Currently there is a Serializer like this for each of our models: class ItemSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Item fields = '__all__' Additionally in views.py there is the ModelViewSet: class ItemViewSet(viewsets.ModelViewSet): queryset = Item.objects.all() serializer_class = ItemSerializer Is it possible to somehow reduce the amount of code and make this approach a bit more flexible? I am thinking of something like this: for model in models: ser = createSerializer() createViewSet(ser) Where with each call a separate class is created. Or is there even a class which makes this possible? -
Connect Google Chrome Extension to Django via OAuth2
I'm searching for a way to authenticate Chrome Extension with my Django App and allow users to send authorized POST requests to my server. The flow I'm looking to create looks like this: User clicks a 'Login' button inside Extension pop-up The extension connects with my Django Backend User is now able to send POST data which is saved in his profile (in Django App) Has anybody tried and succeed with something like this? Thanks for spending your time on my question! -
Django admin: postgres DateTimeRangeField not displayed properly
Some of my models have postgres-specific django.contrib.postgres.fields.DateTimeRangeFields, and those fields are exposed in the corresponding admin panels. I expected that the ranges forms would consist of two Django-style datetime pickers, with a separate one for the date part and a separate part for the time part (just like the DateTimeField would). However, I get two text inputs which expect input in a very particular format. Is there anything I am missing or have to configure separately? The relevant code is: from django.contrib.postgres.fields import DateTimeRangeField ... class MyModel(models.Model): time_off = DateTimeRangeField() admin: @register(MyModel) class MyModelAdmin(admin.ModelAdmin): pass -
Serving generated Swagger schema in Django with drf-yasg
I'm using drf-yasg to generate and serve Swagger JSON schema for Django app's API. In settings.py i created SWAGGER_SETTINGS object: SWAGGER_SETTINGS = { 'DEFAULT_INFO': 'CDPtoolsSite.openapi.OPENAPI_INFO' } In openapi module I created openapi.Info importable object: After this I defined few endpoints for displaying schema with UI and without UI: from rest_framework import permissions from drf_yasg.views import get_schema_view from .openapi import OPENAPI_INFO schema_view = get_schema_view( OPENAPI_INFO, public=True, permission_classes=(permissions.AllowAny, ), ) urlpatterns = [ # ... path( 'swagger.json', schema_view.without_ui(cache_timeout=0), name='schema-json' ), path( 'swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui' ), path( 'redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc' ), ] When I go to /swagger.json path server returns scheam file in YAML format, but I need to have schema generated in JSON. Is there some flag to return JSON formatted file instead? I also tried to generate schema file manually (saved in static directory) and serve it on separate endpoint but it didn't work as I expected: urlpatterns = [ #..... path( 'api/schema', RedirectView.as_view(url=static_url('swagger_schema.json')), 'swagger-schema' ), ] Is there any way to make drf-yasg generate served schema in JSON format? -
Django documentation in Kubernetes using Ingress
We have a platform built using microservices architecture, which is deployed using Kubernetes and Ingress. One of the platform's components is a Django Rest API. The yaml for the Ingress is the below (I have changed only the service names & endpoints): apiVersion: extensions/v1beta1 kind: Ingress metadata: name: dare-ingress annotations: kubernetes.io/ingress.provider: nginx nginx.ingress.kubernetes.io/ssl-redirect: "false" nginx.ingress.kubernetes.io/rewrite-target: /$1 certmanager.k8s.io/issuers: "letsencrypt-prod" certmanager.k8s.io/acme-challenge-type: http01 spec: tls: - hosts: - demo-test.com secretName: dare-ingress-tls rules: - host: demo-test.com http: paths: - path: /prov/?(.*) backend: serviceName: prov servicePort: 8082 - path: /(prov-ui/?(.*)) backend: serviceName: prov-ui servicePort: 8080 - path: /flask-api/?(.*) backend: serviceName: flask-api servicePort: 80 - path: /django-rest/?(.*) backend: serviceName: django-rest servicePort: 8000 The django component is the last one. I have a problem with the swagger documentation. While all the Rest calls work fine, when I want to view the documentation the page is not load. This is because it requires login and the redirection to the documentation does not work. I mean that, without Ingress the documentation url is for example: https://demo-test.com/docs but using Ingress, the url should be https://demo-test.com/django-rest/login and then https://demo-test.com/django-rest/docs but the redirection does not work, I get a 404 error. Does anyone have any idea how to fix this in Ingress?