Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django URL tag not working with JS file, weird bug
Hobbyist here. Can't seem to figure out how to use the {% url %} static template with dynamic javascript. For example, I am creating a list of days for a calendar where each day when clicked on should pull data from the database based on its date. The day is being created dynamically in a loop, where the href attribute is being set for the URL. My <a href> in the JS code looks like this currently for setting the URL: aLink.setAttribute('href', currentYear + '-' + (currentMonth + 1) + '-' +dayCounter) The problem with this method is this - Take a quick look at my URLS.py urlpatterns = [ path('<int:tutor_id>', views.tutorHomeOverviewPage, name='tutorHomeOverviewPage'), #homepage for when tutor/customer signs in path('<int:tutor_id>/<slug:selected_date>', views.tutorSelectedDay, name='tutorSelectedDay') ] If I start off on a page which matches path 1 like so: http://127.0.0.1:8000/tutorhomepage/7` The code for the list item looks like this and doesn't point to a matching path because it removes the /7 from the URL: <a href="2022-10-17" id="day17">17</a> Path: http://127.0.0.1:8000/tutorhomepage/2022-10-14 Giving me the obvious error when I click on it: Using the URLconf defined in sass_language_tutor_app.urls, Django tried these URL patterns, in this order: tutorhomepage/ <int:tutor_id> [name='tutorHomeOverviewPage'] tutorhomepage/ <int:tutor_id>/<slug:selected_date> [name='tutorSelectedDay'] admin/ The current path, … -
Porque a la hora de instalar la dependencia jazzmin me da un error
enter image description here Me dices que no encuentra el modulo ModuleNotFoundError: No module named 'jazzmin' -
How display the django q monitor output in a django view/template
I would like to show the status of Django Q in real time in a django app view/template, so accessible via browser, just like the result of the cli command python manage.py qmonitor. In particular, I would like to have displayed the currently running tasks (while the admin module of Django Q only displays the completed ones). -
ERROR: Could not find a version that satisfies the requirement rest-framework (unavailable) (from versions: none)
I'm a beginner and I'm getting this error, can someone with more experience help me? ERROR: Could not find a version that satisfies the requirement rest-framework (unavailable) (from versions: none) ERROR: No matching distribution found for rest-framework (unavailable) ERROR: Service 'web' failed to build : Build failed I've tried using the commands below but it didn't solve the problem. pip install djangorestframework-jsonapi pip3 install djangorestframework-jsonapi pip install -r requirements.txt --proxy address:port python -m pip install --upgrade pip python3 --version Python 3.10.6 print(django.get_version()) 3.2.12 cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.1 LTS" -
Send id from one table to another automatically in form with ForeignKey in Django
#HELP in python (DJANGO 4) I send this message here because I have not been able to find an answer elsewhere. Currently I’m on a project where I have to create a booking form. The goal is that when the user submit the Reservation form, I send the data in BDD, and I retrieve the user's id by a relation (ForeignKey). And my difficulty is in this point precisely, when I send my form in BDD I recover the information, except the id of the user… I did a Foreignkey relationship between my 2 tables and I see the relationship in BDD but I don’t receive the id of the User table, but null in the place…. Does anyone of you know how to help me please? Thank you all. --My model.py -- class Reservation(models.Model): fullName = models.CharField('Nom Complet', max_length=250, null=True) adress = models.CharField('Adresse', max_length=100, null=True) zip_code = models.IntegerField('Code Postal', null=True) city = models.CharField('Vile', max_length=100, null=True) email = models.EmailField('Email', max_length=250, null=True) phone = models.CharField('Telephone', max_length=20, null=False) date = models.CharField('Date', max_length=20, null=True, blank=True) hour = models.CharField('Heure', max_length=20, null=True, blank=True) message = models.TextField('Message', null=True) accepted = models.BooleanField('Valide', null=True) created_at = models.DateTimeField('Date Creation', auto_now_add=True, null=True) modified_at = models.DateTimeField('Date Mise Jour', auto_now=True, null=True) user … -
Calculate a field django and save it in the database
I am just starting with Django and web development , so please be nice with me. i am trying to build an app that generates a new number to reports created by our inspectors (our company is an inspection company). each inspector chooses the type of reports, the inspection date and the client and the app saves the data and creates a report number . the report number is generated depending on the type of the report and the date. for example if i have 3 reports of type "visual inspection" done in 2022, the new "visual inspection" report will have the number 4/2022. here is the code I used to attempt this but unfortunately it is not working: Views.py from modulefinder import ReplacePackage from django.shortcuts import render from report.models import Report from django.http import HttpResponse from django.db.models.aggregates import Count from django.db import transaction from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response from .serializers import ReportSerializer @api_view(['GET','POST']) def Report_add_view(request): if request.method =='GET': queryset = Report.objects.select_related('type').all() serializer = ReportSerializer(queryset,many=True) return Response(serializer.data,status=status.HTTP_200_OK) elif request.method =='POST': serializer = ReportSerializer(data=request.data) serializer.is_valid(raise_exception=True) serializer.save() return Response(serializer.data,status=status.HTTP_201_CREATED) # Create your views here. models.py from django.db import models # Create your models here. class … -
How to show error messages during registration?
How to show error messages during registration? I tried to make an error message when filling out a field of registration. But it does not work. that is, when I enter the wrong data, the error message does not appear . what could be the problem? and how to fix it?? forms.py class UserRegistrationForm(forms.ModelForm): class Meta: model = User fields = ("username", "email", "password", ) def clean_username(self): username = self.cleaned_data.get('username') model = self.Meta.model user = model.objects.filter(username__iexact=username) if user.exists(): raise forms.ValidationError("A user with that name already exists") return self.cleaned_data.get('username') def clean_email(self): email = self.cleaned_data.get('email') model = self.Meta.model user = model.objects.filter(email__iexact=email) if user.exists(): raise forms.ValidationError("A user with that email already exists") return self.cleaned_data.get('email') def clean_password(self): password = self.cleaned_data.get('password') confim_password = self.data.get('confirm_password') if password != confim_password: raise forms.ValidationError("Passwords do not match") return self.cleaned_data.get('password') views.py def register_user(request): form = UserRegistrationForm() if request.method == "POST": form = UserRegistrationForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.set_password(form.cleaned_data.get('password')) user.save() messages.success(request, "Registration sucessful") return redirect('login') context = { "form": form } return render(request, 'registration.html') registration.html <fieldset> <input name="username" type="text" id="username_id" placeholder="Your username" > <p class="py-1 text-danger errors">{{form.username.errors}}</p> </fieldset> </div> <div class="col-md-12 col-sm-12"> <fieldset> <input name="email" type="email" id="email_id" placeholder="Your email" > <p class="py-1 text-danger errors">{{form.email.errors}}</p> </fieldset> </div> <div class="col-md-12 col-sm-12"> <fieldset> … -
Django static JS File not loading
When i am clicking button , js file is not loading internally..the static tag is not working inside home.html ... Its been a very long time since I had to use Django templates but I am having some trouble loading static js files. nav.html <!doctype html> <html lang="en"> <head> {% load static %} <link rel="stylesheet" href="{% static 'css/home.css' %}"> <script src='/crudapp/static/home.js'></script> <script src="https://code.jquery.com/jquery-3.6.1.js" integrity="sha256-3zlB5s2uwoUzrXK3BT7AX3FyvojsraNFxCc2vC/7pNI=" crossorigin="anonymous"></script> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Bootstrap w/ Parcel</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.rtl.min.css" integrity="sha384-7mQhpDl5nRA5nY9lr8F1st2NbIly/8WqhjTp+0oFxEA/QUuvlbF6M1KXezGBh3Nb" crossorigin="anonymous"> <style> body{ background-color: rgb(54, 60, 58); } #dd{ color:blanchedalmond; } .table{ background-color: white; width:500px; margin-left: 500px; } .card{ margin-top: 100px; margin-left:500px; width:500px; } .card-body{ margin-left:100px; } .navbar-brand{ color:rgb(79, 200, 237); } </style> <link> <script src="/crudapp/static/home.js"></script> </head> <body> <nav class="navbar navbar-expand-lg bg-light"> <div class="container-fluid"> <a class="navbar-brand" href="{%url 'index' %}">CRUD</a> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav"> <li class="nav-item"> <a class="navbar-brand" href="{%url 'data' %}">DATA</a> </li> </ul> </div> </div> </nav> </body> </html> home.html {% load static %} <!doctype html> <script type="text/javascript" src="{% static 'js/home.js' %}"></script> <script src="https://code.jquery.com/jquery-3.6.1.js" integrity="sha256-3zlB5s2uwoUzrXK3BT7AX3FyvojsraNFxCc2vC/7pNI=" crossorigin="anonymous"></script> <body> {%include 'nav.html'%} <div class="card"> <div class="card-body"> <form action="" method="POST"> {% csrf_token %} {{form.as_p}} <button type="submit" id="btnn" class="btn btn-primary">SUBMIT</button> </form> </div> </div> </body> </html> settings file STATIC_URL = 'static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') directory -static -css … -
(django) Foreign key does not get recorded and receives Integrity Error
I'm trying create a python with django project to record the username (active session), quizid, questionid, studentanswer to mysql database but receives the integrity error > "Column 'username_id' cannot be null" models.py class Quiz(models.Model): questionid = models.IntegerField(null=False) quizid = models.AutoField(primary_key=True) subjectname = models.CharField(max_length=50) question = models.CharField(max_length=50) correctanswer = models.CharField(max_length=50) eqpoints = models.IntegerField() student = models.ManyToManyField("self", through="StudentAnswer") teacher = models.ManyToManyField(Teacher) class StudentAnswer(models.Model): username = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) questionid = models.ForeignKey(Quiz, on_delete=models.CASCADE, related_name='quiz_question') quizid = models.ForeignKey(Quiz, on_delete=models.CASCADE, related_name='quiz_id') studentanswer = models.CharField(max_length=50) forms.py class StudentAnswerForm(ModelForm): questionid = forms.ModelChoiceField(widget=forms.Select(), queryset=Quiz.objects.only('questionid')) studentanswer = forms.CharField(widget=forms.TextInput()) quizid = forms.ModelChoiceField(widget=forms.Select(), queryset=Quiz.objects.only('quizid')) class Meta: model = StudentAnswer fields = ['quizid','questionid','studentanswer'] views.py class AnswerQuiz(View): template = 'ansQuiz.html' def get(self, request): form = StudentAnswerForm() request.session['visits'] = int(request.session.get('visits', 0)) + 1 quiz = Quiz.objects.all() #get data from all objects on Quiz model return render(request, self.template,{'quiz':quiz, 'form':form}) def post(self,request): if request.method == 'POST': form = StudentAnswerForm(request.POST) if form.is_valid(): form.instance.user = request.user form.save() return render(request, self.template, {'form':form}) -
Aggregate Sum shows total for all members
When i add aggregate function on my get_context_data it shows the total for all members and not according to there ID. Thank You ItemListView class ItemListView(ListView): model = HBTYItem template_name = "accounts/modals/nomodal/todo_list.html" paginate_by = 2 ordering = ['id'] def get_queryset(self): return HBTYItem.objects.filter(hbty_cust_id=self.kwargs["list_id"]) def get_context_data(self): context = super().get_context_data() context['t_sum'] = HBTYItem.objects.aggregate(Sum('price')) context["hbty_list"] = HBTYList.objects.get(id=self.kwargs["list_id"]) return context -
Django query based on through table
I have a 5 models which are Contents, Filters,ContentFilter , Users. a user can view contents. a content can be restricted using Filters so users can't see it. here are the models. class Content(models.Model): title = models.CharField(max_length=120) text = models.TextField() filters = models.ManyToManyField(to="Filter", verbose_name=_('filter'), blank=True, related_name="filtered_content",through='ContentFilter') class Filter(models.Model): name = models.CharField(max_length=255, verbose_name=_('name'), unique=True) added_user = models.ManyToManyField(to=User, related_name="added_user", blank=True) ignored_user = models.ManyToManyField(to=User, related_name="ignored_user", blank=True) charge_status = models.BooleanField(blank=True, verbose_name=_('charge status')) class ContentFilter(models.Model): content = models.ForeignKey(Content, on_delete=models.CASCADE) filter = models.ForeignKey(Filter, on_delete=models.CASCADE) manual_order = models.IntegerField(verbose_name=_('manual order'), default=0,rst')) access = models.BooleanField(_('has access')) What it means is that 5 contents exist(1,2,3,4,5). 2 users exist. x,y A filter can be created with ignored user of (x). Contents of 1,2,3 have a relation with filter x. so now X sees 4,5 and Y sees 1,2,3,4,5 what I'm doing now is that based on which user has requested find which filters are related to them. then query the through table(ContentFilter) to find what contents a user can't see and then exclude them from all of the contents.(this helps with large joins) filters = Filter.objects.filter(Q(added_user=user)|(Q(ignored_user=user)) excluded_contents = list(ContentFilter.objects.filter(filter__in=filters).values_list('id',flat=True)) contents = Contents.objects.exclude(id__in=excluded_contents) Problem I want a way so that Filters can have an order and filter a queryset based on top … -
How to create models depending on different users in Django?
I'm going to create a model called student. But the model might be a little different due to different users: trial and expert users. Expert users might have an additional field to store comments. class Student(models.Model): id = models.CharField( max_length=7,primary_key=True) name = models.CharField(_('name'),max_length=8, default=""); address = models.CharField(_('address'),max_length=30,blank=True,default="") # comments field is not available for trial users # and for expert users the max_length should also a variable # rather than a constant # the switch if(settings.version !="trial"): comments = models.CharField(_("comments"),max_length=30); My idea is to store an attribute to store the user's versions. And when it comes to initialize the model, the switch will determine if the field will be applied or not. But Where should I store the attibute? Is it appropriate to be inside settings.py? Or it should be an attribute of a customer? If it's not appropriate. Should I create different models for different versions? Do the tables should be created for different models with only one or two fields different? -
How to retrieve value in Dropdown list on edit button in Django
I have a form (edit_city.html) where I want to edit my record, there is also one dropdown field in which data is retrieving from another model name Country. How can I get the exact value in dropdown field, when I click on edit. class Country(models.Model): CountryID = models.AutoField(primary_key=True) CountryName = models.CharField(max_length=125, verbose_name="Country Name") def __str__(self): return self.CountryName class City(models.Model): CityID = models.AutoField(primary_key=True) CityName = models.CharField(max_length=125, verbose_name='City Name') Country = models.ForeignKey(Country, verbose_name='Country Name', on_delete=models.CASCADE) def __str__(self): return self.CityName views.py def Edit_City(request, id): city = City.objects.get(CityID=id) country = Country.objects.all() context = { 'city':city, 'country':country, } return render(request, 'City/edit_city.html', context) edit_city.html <form method="post" action="{% url 'update_city' %}"> {% csrf_token %} <div class="row"> <div class="col-12"> <h5 class="form-title"><span>Edit City</span></h5> </div> {% include 'includes/messages.html' %} <div class="col-12 col-sm-6"> <div class="form-group"> <label for="">Country</label> <select class="form-control" name="country_id" required> <option>Select Country</option> {% for con in country %} <option value="{{con.CountryID}}">{{con.CountryName}}</option> {% endfor %} </select> </div> </div> <div class="col-12 col-sm-6"> <div class="form-group"> <label>City Name</label> <input type="text" class="form-control" name="city_name" value="{{city.CityName}}" required> <input type="text" class="form-control" name="city_id" value="{{city.CityID}}" required hidden> </div> </div> <div class="col-12"> <button type="submit" class="btn btn-primary">Update City</button> </div> </div> </form> -
Fetch API key from Django to React app in a secure way
I am building an app at the moment and security is a priority so I want to ensure I'm implementing API fetches correctly. I currently have stored an API key in a .env file in Django. I want to use this key to perform requests through the frontend. django-app/.env API_KEY = key settings.py import os from dotenv import load_dotenv, find_dotenv load_dotenv(find_dotenv()) SECRET_KEY = os.environ['API_KEY'] I'm only just getting into backend development so I'm unsure of how to produce a view that would allow the frontend to use this key safely. Any tips or pointers will be much appreciated, thank you -
Django get_next_in_order and get_previous_in_order return incorrect data when objects are stored in non-default database
When using get_next_in_order and/or get_previous_in_order with a database other than the default, I get the following error: models.Car.DoesNotExist: Car matching query does not exist. Django Framework version is 4.1.1 Python version 3.8 models.py: from django.db import models class Person(models.Model): name = models.CharField(max_length=100, unique=True) class Car(models.Model): name = models.CharField(max_length=100) owner = models.ForeignKey(Person, models.CASCADE) class Meta: order_with_respect_to = "owner" In settings.py under DATABASES the following is used: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', }, 'other': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db_other.sqlite3', } } This can be tested in the Django Shell using the following command python manage.py shell: >>> from models import Person, Car >>> carowner = Person.objects.using("other").create(name="carowner") >>> porsche = Car.objects.using("other").create(name="porsche", owner=carowner) >>> ferrari = Car.objects.using("other").create(name="ferrari", owner=carowner) >>> lamborghini = Car.objects.using("other").create(name="lamborghini", owner=carowner) >>> carowner.set_car_order([lamborghini.pk, ferrari.pk, porsche.pk], "other") >>> gnio = porsche.get_next_in_order() >>> gnio.name # Should print ferrari >>> gpio = porsche.get_previous_in_order() >>> gpio.name # Should print lamborghini -
how to handle line breaks with django and js
I store in my db.sqlite3 of django some patterns which can contain a line break (\n). On the /admin page you can still see them. But when I load the content now into the frontend, this is written in a line. But if I output the sentence in the console, I get the line break The following record is stored in the Django database as follows: Hello\nWorld <div id=response_1> </div> document.getElementById('response_1').innerHTML = responses[0] //Hello World console.log(responses[0]) // Hello World -
Django models with self create properties
Let's pretend that you're creating web application. You have users in your app and these users have collections of pictures, books and other. They can add to their collections items (accordingly books, pictures e.g.). Example of book fields: _author _title _desription But what if they want add another information about this book like preview picture, pages quantity, link and other information. How can i implement it with django models?? -
Forbidden (CSRF cookie not set.) but it is set by Axios in React (DRF)
Firstly, I'm getting csrf cookie by calling /auth/session/ endpoint then I'm setting header for csrf cookie, actual error occurs when I'm trying to login Request import axios from 'axios'; import Cookies from "universal-cookie"; const cookies = new Cookies(); const Login = () => { axios .get('http://localhost:8000/auth/session/') .then(({ data }) => { console.log(data) }) .catch((error) => { console.log(error); }); axios.defaults.xsrfHeaderName = 'X-CSRFToken' axios.defaults.xsrfCookieName = 'csrftoken' axios.defaults.headers.common['X-CSRFToken'] = cookies.get('csrftoken'); const onSubmit = object => { axios.post( 'http://localhost:8000/auth/login/', object, ) .then(res => { if (res.status === 201) alert('Successfully authorized') else Promise.reject() }) .catch(err => alert(err)) } actual request headers image Response Forbidden (CSRF cookie not set.): /auth/login/ news-board-web-1 | [16/Oct/2022 15:40:58] "POST /auth/login/ HTTP/1.1" 403 2870 response image Settings CSRF_TRUSTED_ORIGINS = [ 'http://localhost:3000', 'http://localhost:3001', ] CORS_ALLOW_ALL_ORIGINS = True CORS_ALLOW_HEADERS = list(default_headers) + [ 'X-CSRFToken' ] CORS_EXPOSE_HEADERS = ["Content-Type", "X-CSRFToken"] CSRF_COOKIE_HTTPONLY = False CORS_ALLOW_CREDENTIALS = True For login I'm using standard rest framework login that works fine with Postman, but I can't find out the reason why it doesn't work with axios path('auth/', include('rest_framework.urls')), -
Django: id_field of model in url not working
I have the following problem: I have an app in which I want a view vocab/1 as a detail page for an entry. WHenever I browse to http://127.0.0.1:8000/vocab/ (displays all word entries (really ugly nothing yet :-D ) this works. Whenever I go for http://127.0.0.1:8000/vocab/1 I get TypeError at /vocab/1/ my vocab.views.py from django.http import HttpResponse from .models import Word # Create your views here. def index(request): return HttpResponse('Hi from landing page') def vocab(request): words = Word.objects.order_by('id') output = ([word for word in words]) return HttpResponse(output) def detail_vocab(request, word_id): return HttpResponse("You're looking at the word with id" % word_id) the vocab.urls.py from django.urls import path from . import views urlpatterns = [ #index path('', views.index, name='index'), #vocab path('vocab/',views.vocab, name='vocab'), #details ex: vocab/1 path('vocab/<int:word_id>/', views.detail_vocab, name='detail'), ] the site/urls.py from django.contrib import admin from django.urls import include,path urlpatterns = [ path('', include('vocab.urls')), path('admin/', admin.site.urls), ] my vocab.models.py: from django.db import models # Create your models here. class Word(models.Model): def __str__(self): return self.word_en word_en = models.CharField(max_length=50) word_indo = models.CharField(max_length=50) word_dt = models.CharField(max_length=50) word_id = models.IntegerField(default=0) Am I missing something? all the best, K -
Using both aria-hidden="true" and aria-labelledby attributes in the same field
I understand the functionality of both aria-hidden="true" attributes and aria-labelledby in the sense that the prior attribute hides the contents of an element and its child-elements from screen-readers (supposedly including aria-labelledby and aria-labelled), and that the latter attribute gives an element its accessible name based on another element's aria-label. However, I am faced by a contradiction in a Django course I am completing. https://youtube.com/clip/UgkxN1rhn70sw6fPvRdhpAFZv0KnPBz7J5-y (I have also attached a snippet of the uncompleted code below.) Here, the creator of the course includes both aria-hidden="true" attributes and aria-labelledby attributes simultaneously. According to what I understood, the inclusion of aria-labelledby makes no difference. So what is the point of including it? TLDR: Does the data of aria-labelledby still appear in screen readers when aria-hidden="true" or did the course creator make a mistake? <div class="modal" id="#myModal{{student.id}}" tabindex="-1" aria-labelledby=""> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Modal title</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"> <span aria-hidden="true"></span> </button> </div> <div class="modal-body"> <p>Modal body text goes here.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary">Save changes</button> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> </div> </div> </div> </div> -
How to fetch GitHub repo contributions using python and more specifically celery
I was wondering how I can fetch the list of contributors using python and more specifically using celery. -
Django Rest Framework: Should I use renderer for JPEG?
I am currently building an api where I have to create api for image uploading. Stumbled upon different tutorials, I've found that some of them have used the JPEG Renderer while the others haven't. My question is when I should use a renderer. What may I miss if I don't use one? -
Icons from DigitalOcean spaces can't load with my Django settings
I am using Django summernote, but icons aren't showing, this is the structure of my digitalocean spaces : When it comes to Django settings, I pointed to the res folder with AWS_LOCATION, but am not sure if the path I provided is correct, I used : AWS_LOCATION = 'res/' I also enabled CORS in the DigitalOCean spaces section, but I am still getting this error : DevTools failed to load source map: Could not load content for https://fra1.digitaloceanspaces.com/guio_space/res/vendor/adminlte/css/adminlte.min.css.map: HTTP error: status code 403, net::ERR_HTTP_RESPONSE_CODE_FAILURE DevTools failed to load source map: Could not load content for https://fra1.digitaloceanspaces.com/guio_space/res/vendor/adminlte/js/adminlte.min.js.map: HTTP error: status code 403, net::ERR_HTTP_RESPONSE_CODE_FAILURE DevTools failed to load source map: Could not load content for https://fra1.digitaloceanspaces.com/guio_space/res/vendor/bootstrap/js/bootstrap.min.js.map: HTTP error: status code 403, net::ERR_HTTP_RESPONSE_CODE_FAILURE all.min.css:1 GET https://fra1.digitaloceanspaces.com/guio_space/res/vendor/fontawesome-free/webfonts/fa-solid-900.woff2 net::ERR_ABORTED 403 all.min.css:1 GET https://fra1.digitaloceanspaces.com/guio_space/res/vendor/fontawesome-free/webfonts/fa-regular-400.woff2 net::ERR_ABORTED 403 all.min.css:1 GET https://fra1.digitaloceanspaces.com/guio_space/res/vendor/fontawesome-free/webfonts/fa-solid-900.woff net::ERR_ABORTED 403 all.min.css:1 GET https://fra1.digitaloceanspaces.com/guio_space/res/vendor/fontawesome-free/webfonts/fa-regular-400.woff net::ERR_ABORTED 403 all.min.css:1 GET https://fra1.digitaloceanspaces.com/guio_space/res/vendor/fontawesome-free/webfonts/fa-solid-900.ttf net::ERR_ABORTED 403 all.min.css:1 GET https://fra1.digitaloceanspaces.com/guio_space/res/vendor/fontawesome-free/webfonts/fa-regular-400.ttf net::ERR_ABORTED 403 logo.png:1 -
how to Customize error message when Schema format is not matching with django Ninja?
``` @router.post("/addUser", response={200: responseStdr, 404: responseStdr,422: responseStdr}) def addUser(request, user: userRegister): try: return 200, {"status": 200, "isError": "True", "data": user, "msg": "user crée avec succès", "method": "POST"} except : return {"status": 201, "isError": "True", "data": "erreur format", "msg": "erreur", "method": "POST"} ``` I'm getting this error : ``` { "detail": [ { "loc": [ "body", "user", "last_name" ], "msg": "field required", "type": "value_error.missing" } ] } ``` How to send a custom message instead of this error when a field is not matching with the expected format ? -
HTML doesn't load all CSS properties
I am making a website using django and I need to edit some things on frontend using CSS but I don't know why CSS doesn't load all things I added. It loads some of the tags but rest just doesn't show at all here is the code. index.html: {% extends 'gym_app/base.html' %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Home</title> <script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script> {%load static%}{%block content%} <link rel="stylesheet" type="text/css" href="{% static 'css/index.css' %}" /> <link rel="script" href="{% static 'javascript/index.js' %}"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.css" /> </head> <body class="body"> <div class="container"> <div class="text-center"> <h1>Supreme</h1> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum, debitis!</p> </div> <!--Image slideshow--> <div class="container-slide"> <div class="swiper"> <!-- Additional required wrapper --> <div class="swiper-wrapper"> <!-- Slides --> <div class="swiper-slide"><img src="{% static 'images/gym_1.jpg' %}" alt=""></div> <div class="swiper-slide"><img src="{% static 'images/gym_1.jpg' %}" alt=""></div> <div class="swiper-slide"><img src="{% static 'images/gym_1.jpg' %}" alt=""></div> </div> <!-- If we need pagination --> <div class="swiper-pagination"></div> <!-- If we need navigation buttons --> <div class="swiper-button-prev"></div> <div class="swiper-button-next"></div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/swiper@8/swiper-bundle.min.js"></script> <script src="{% static 'javascript/index.js' %}"></script> <!--Ends--> <!--About section--> <div class="container"> <p class="h1 text-center">About us</p> <section class="row mb-5"> <img src="{% static 'images/gym_1.jpg' %}" alt="" class="col-7" style="height: 350px;"> <div class="col-5"> <p>Lorem ipsum …