Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django allauth:email comfirmation link can be accessed even after confirmation?
I'm using django-allauth to manage signin and signup in my Django app. When a user sign up, an email contains a confirmation link sent to the registered email. In allauth settings, I set ACCOUNT_CONFIRM_EMAIL_ON_GET=False so a user have to click a button to confirm the email address. But the link is still accessible even after user clicked the button. (by click the link in the email or press go back) Can I redirect the user to a specific url (e.g. home) if the user go to the confirmation link after confirmation? -
Sending bulk email from User email account
I have a web-app in Django, an user should be able to send marketing emails to a selected list of recipients but the emails should be sent from the user's personal email. This of course requires communication between my web-app and the user's email provider (for auth and managing emails). Leaving opinions aside, could anyone point to me libraries or tools used to achieve this functionality? Thanks -
Find all occurences of maximum value from a list of tuple?
I have a list of tuple such as: list1=[(1,1),(2,1),(3,1),(4,0),(5,0)] I have found the maximun element using: max_value = max(list1, key=itemgetter(1)) this outputs (1, 1) I want some thing like [(1,1),(2,1),(3,1)] -
Django python sehll from app.models import Modelclass not working
redcube/models.py from django.db import models from django.contrib.auth.models import User class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) level = models.IntegerField(blank=True) def __str__(self): return self.user.username class Images(models.Model): redcube = models.ForeignKey(Redcube, on_delete=models.CASCADE, null=True) image = models.ImageField(upload_to='images/', blank=True, null=True) def __str__(self): return self.redcube.name from the python shell >>> from redcube.models import Profile Traceback (most recent call last): File "<console>", line 1, in <module> ImportError: cannot import name 'Profile' from 'redcube.models' (/Users/macos/basic/btp/btp/redcube/models.py) >>> from redcube.models import Images >>> Images.objects.all() <QuerySet [<Images: Hawaii>, <Images: City view hotel>, <Images: Cottage>, <Images: Redcube>, <Images: Phone>, <Images: Flower>, <Images: Miho>]> When I try to import and test the models in the python shell Other model class is working right. but the Profile class is not working! I've tried the from .models import Profile, but not working. Thanks for the help :) -
TypeError at /book/2 string indices must be integers
I'm new to Django, I have encountered this error TypeError at /book/1 string indices must be integers I have a JSON file called book.json (seen below) { "books":[ { "id": 1, "title": "Unlocking Android", "isbn": "1933988673", "status": "PUBLISH", }, ..... I'm trying to get single book using id in the view def show(request, id): with open('bookstore/books.json') as file: books = json.load(file) book = [book for book in books if book['id'] == id] return render(request, 'books/show.html', book) The show.html template has this code <a href="/book/{{book.id}}"> for book links -
Finding the middleware that interrupted a Django request
I was debugging yesterday a Django view that returned a 403 without entering the view code. It turns out it was because I provided a Content-Type: multipart/form-data header without specifying the delimiter. This was "silently" rejected by some Django request parsing logic or middleware, which returned a 403. This makes sense, but the debugging experience wasn't great. Is there a way to make these middlewares (request parsing, auth, CSRF...) print some logs when they interrupt a request? -
Multiple Serializer within the same view.list call
I have a simple model that can contain some sensitive information class Organization(Model): name = CharField() is_private = BooleanField() # the following information is sensitive code = CharField() employee_count = IntegerField() # other confidential fields... I am using regular ModelViewSet and ModelSerializer for this model. when calling the list action of the viewset (GET organizations/) I would like to have my organizations serialized differently depending on whether they are private: show all the fields if the organization is not private only name if it is What I already tried: overriding get_serializer() of viewset => this doesn't fit as the same serializer applies for all objects of the list using serializers.MethodField() => not efficient because I have many fields that I'd need to handle -
I want to make location based app in django
Basically when user will put location name then a map showing that location should get displayed and I want to make it by google api like geocoding So can anyone help me? -
post django form data via iframe
I have a django form that I want to display on another website via iframe. The form displays ok but whenever I try to submit the form that is displayed in the iframe, I get a "server refused to connect" error message. Is it possible to make a django form work with iframe or is there a better way to do it? The views code for the form: from django.views.decorators.clickjacking import xframe_options_exempt @xframe_options_exempt def booking_create_view(request): form=BookingForm submitted = False if request.method=='POST': form = BookingForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/?submitted=True') else: form = BookingForm if 'submitted' in request.GET: submitted = True return render(request, "booking_form.html",{'form':form, 'submitted': submitted}) HTML for the form: <form class="" action="" method= POST> <div class="form-group"> {% csrf_token %} {{ form.as_p }} <input type="Submit" value="Submit" class = "btn btn-secondary"> </form> {% endif %} The iframe: <h1>The iframe element</h1> <iframe src="http://127.0.0.1:8000/" title="test"> </iframe> Note: I have also tried using a live server (pythonanywhere) that had the same result -
extract data from sting by keys and values in python
i have a text field in which i have the following data how can i retrieve values from these keys can anyone help me out '{'wsgi.errors': '<gunicorn.http.wsgi.WSGIErrorsWrapper object at 0x7f00a70eb668>', 'wsgi.version': '(1, 0)', 'wsgi.multithread': 'False', 'wsgi.multipr ocess': 'True', 'wsgi.run_once': 'False', 'wsgi.file_wrapper': "<class 'gunicorn.http.wsgi.FileWrapper'>", 'wsgi.input_terminated': 'True', 'SERVER_S OFTWARE': 'gunicorn/20.0.4', 'wsgi.input': '<gunicorn.http.body.Body object at 0x7f00a70ebe10>', 'gunicorn.socket': '<socket.socket fd=4, family=AddressFam ily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, laddr=/home/ubuntu/oto_directory/oto_project/otocore.sock>', 'REQUEST_METHOD': 'POST', 'QUERY_STRING': '' , 'RAW_URI': '/api/v1/otp/create/', 'SERVER_PROTOCOL': 'HTTP/1.0', 'HTTP_X_FORWARDED_FOR': '157.37.221.189, 172.31.27.255', 'HTTP_HOST': 'abc.in', 'HTTP_CONNECTION': 'close', 'CONTENT_LENGTH': '31', 'HTTP_X_FORWARDED_PROTO': 'https', 'HTTP_X_FORWARDED_PORT': '443', 'HTTP_X_AMZN_TRAC E_ID': 'Root=1-60c98a8f-6308e3da7d3e4eef7c86e0c2', 'HTTP_SEC_CH_UA': '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"', 'HTTP_ACCEPT': 'ap plication/json, text/plain, /', 'HTTP_X_ID_KEY': 'f48abf167aa67669e592933b9114e07f', 'HTTP_SEC_CH_UA_MOBILE': '?1', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Li nux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Mobile Safari/537.36', 'CONTENT_TYPE': 'application/json', 'HTTP_ORIGIN': 'https://abcl.in', 'HTTP_SEC_FETCH_SITE': 'same-site', 'HTTP_SEC_FETCH_MODE': 'cors', 'HTTP_SEC_FETCH_DEST': 'e mpty', 'HTTP_REFERER': 'https://abc.in/', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate, br', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.9 ', 'HTTP_COOKIE': '_gcl_au=1.1.1633381306.1622530786; _ga=GA1.2.638419829.1622530787; _fbp=fb.1.1622530787694.1900095648; _hjid=cfa0329f-ffdd-439e-95a9-4f396ed001 ed; WZRK_G=5dc2f416c2394d4ba88bb7dd0bb9259d; session_id=bad4f39e-5b56-42f3-817d-9e14ac16d83e; csrftoken=2yVyosyb8eAewJ9bR7I9SX8bQPfsFcv5; _gid=GA1.2.607509864.162382 0852; _hjTLDTest=1; _hjAbsoluteSessionInProgress=0; WZRK_S_TEST-RKW-65Z-6Z6Z=%7B%22p%22%3A1%2C%22s%22%3A1623820853%2C%22t%22%3A1623820917%7D', 'wsgi.url_scheme': 'https', 'REMOTE_ADDR': '', 'SERVER_NAME': 'abc.in', 'SERVER_PORT': '443', 'PATH_INFO': '/api/v1/otp/create/', 'SCRIPT_NAME': ''} ' -
How to make clearable fileinput in django in an updateview
In my django app I have a person model with a filefield 'identification_image_front'. I also defined a ModelForm using the Fileinput widget for that field. For the template I am using the jasny-bootstrap plugin for representing the fileinput with 'Select file', 'Remove' and 'change' options Using the following code is is posible to save the file when creating a new working in the CreateView. But when updating an existing worker using the UpdateView the fileinput is allways empty. Is not posible to see if the worker has a file atached to it, nor remove the file from and existing Worker. Is there any way to load the file inside the fileinput and enabling the 'remove' option, so I can remove or change the file of an existing worker? Maybe there is another way to do that using other plugins or HTML code. I am open to suggestions This is my code class WorkerModel(BaseModel): name = models.CharField(verbose_name=_("Nombre "), max_length=50, blank=False, null=False) surname1 = models.CharField(verbose_name=_("Primer apellido"), max_length=50, blank=False, null=False) surname2 = models.CharField(verbose_name=_("Segundo apellido"), max_length=50, blank=False, null=False) identification_image_front = models.FileField(verbose_name=_("Foto carnet frontal"), upload_to="app_person_identification_image_front", null=True, blank=True) class WorkerForm(forms.ModelForm): class Meta: model = WorkerModel exclude = ("id",) widgets = { 'name':forms.TextInput(attrs={'class': 'form-control'}), 'surname1' : forms.TextInput(attrs={'class': … -
Upload and manipulate xml and image file in django
This code return a TypeError as expected str, bytes or os.PathLike object, not InMemoryUploadedFile I don't know how to pass user data in the form of file and image to my code.py file for making changes to the original. views.py def home(request): new_image = None file = None form = ScanForm() if request.method == 'POST': form = ScanForm(request.POST, request.FILES) if form.is_valid(): image = request.FILES['image'] xml_file = request.FILES['xml_file'] new_image = code.create(image, code.search( xml_file)[0], code.search(xml_file)[1]) form.save() return render(request, 'app/home.html', {'form': form, 'new_image': new_image}) else: form = ScanForm() return render(request, 'app/home.html', {'form': form, 'new_image': new_image}) printing image and xml_file successfully prints out their names forms.py class ScanForm(forms.ModelForm): class Meta: model = Scan fields = '__all__' models.py class Scan(models.Model): image = models.ImageField(upload_to='images') xml_file = models.FileField(upload_to='files') processed_at = models.DateTimeField(auto_now_add=True) description = models.CharField(max_length=500, null=True) class Meta: ordering = ['-processed_at'] def __str__(self): return self.description Here is the code for manipulation of image according to the data in the xml code.py def search(path): new = [] object_names = [] object_values = [] txt = Path(path).read_text() txt.strip() names = et.fromstring(txt).findall('object') for i in names: object_names.append(i[0].text) values = et.fromstring(txt).findall('object/bndbox') for i in values: for j in i: object_values.append(int(j.text)) return object_names, object_values def create(image, object_names, object_values): img = cv.imread(image) on = … -
How to display latest 5 orders by using for loop in jinja (django)
The code below will display all the orders but now I want to display only 5 latest orders in my template. Can anyone explain to me how can I iterate only 5 latest orders through jinja? code <div class="card card-body"> <table class="table table-sm"> <tr> <th>Product</th> <th>Date Orderd</th> <th>Status</th> <th>Update</th> <th>Remove</th> </tr> {% for i in orders %} <tr> <td>{{i.product}}</td> <td>{{i.date_created}}</td> <td>{{i.status}}</td> <td><a class="btn btn-sm btn-info" href="{% url 'update_order' i.id %}">Update</a></td> <td><a class="btn btn-sm btn-danger" href="{% url 'delete_order' i.id %}">Delete</a></td> </tr> {% endfor %} </table> </div> -
problems with authentication on the client
I am starting with a project with graphql I use django graphene for the backend and apollo with react but I have problems with authentication I am using django-graphene-auth for this but I don't know how to implement it on the client if I have to save it in a local storage or in a cookie in addition to how do I retrieve the necessary data, for example the profile if the only thing that returns the token is the username, I do not know if you can help me with some books, videos or any type of information where they explain this -
django csrf token not setting in cookie in production
I am using django and react js for my application and when i am passing csrf token in loclhost it ia working fine but in production csrftoken is missing.`axios.defaults.xsrfCookieName = "csrftoken"; axios.defaults.xsrfHeaderName = "X-CSRFTOKEN"; class LoginService extends Component { loginUser(formData) { const config = { headers: { 'content-type': 'application/json'}, "X-CSRFToken": Cookies.get('csrftoken'), withCredentials: true } return axios.post(${API_BASE_URL}api/user/v1/account/login_session/,formData,config); }` -
Get Django object attributes from url to use as context
I filtered a list and sent a link from the chosen record to my view. I want to use the attributes of that object as context to filter some models. I tried this code: def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) entity = self.entity context["entity"] = entity This raises the error: 'EffectivenessProcessOwner' object has no attribute 'entity' The local variables reflected are: Variable Value __class__ <class 'internalcontrol.views.EffectivenessProcessOwner'> context {'pk': 1, 'view': <internalcontrol.views.EffectivenessProcessOwner object at 0x00000284A5672040>} kwargs {'pk': 1} self <internalcontrol.views.EffectivenessProcessOwner object at 0x00000284A5672040> How do I get the entity attribute (and others) from the object? -
Tring to deploy django api on aws getting error
CloudFormation stack missing, re-deploy to enable updates ERROR:Could not get API ID. Traceback (most recent call last): File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\zappa\core.py", line 2585, in get_api_id response = self.cf_client.describe_stack_resource( File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\botocore\client.py", line 386, in _api_call return self._make_api_call(operation_name, kwargs) File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\botocore\client.py", line 705, in _make_api_call raise error_class(parsed_response, operation_name) botocore.exceptions.ClientError: An error occurred (ValidationError) when calling the DescribeStackResource operation: Stack 'django-react-fa-dev' does not exist Oh no! An error occurred! :( ============== Traceback (most recent call last): File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\zappa\cli.py", line 3422, in handle sys.exit(cli.handle()) File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\zappa\cli.py", line 588, in handle self.dispatch_command(self.command, stage) File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\zappa\cli.py", line 641, in dispatch_command self.update( File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\zappa\cli.py", line 1208, in update self.zappa.add_binary_support(api_id=api_id, cors=self.cors) File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\zappa\core.py", line 2082, in add_binary_support response = self.apigateway_client.get_rest_api(restApiId=api_id) File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\botocore\client.py", line 386, in _api_call return self._make_api_call(operation_name, kwargs) File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\botocore\client.py", line 677, in _make_api_call request_dict = self._convert_to_request_dict( File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\botocore\client.py", line 725, in _convert_to_request_dict request_dict = self._serializer.serialize_to_request( File "c:\users\tusha.virtualenvs\django_react_faceapp-osxjngpa\lib\site-packages\botocore\validate.py", line 319, in serialize_to_request raise ParamValidationError(report=report.generate_report()) botocore.exceptions.ParamValidationError: Parameter validation failed: Invalid type for parameter restApiId, value: None, type: <class 'NoneType'>, valid types: <class 'str'> -
Django custom view "You don't have permission error"
I have created my own view for Django admin. Here, I want to add a link to order to view order without disturbing change_form like this. I added following code to admin.py. def get_urls(self): urls = super(OrderAdmin, self).get_urls() custom_urls = [ path('order/<int:order_id>/view', self.view_order, name="view_order") ] print(urls) return urls + custom_urls def view_order(self, request, order_id): order = Order.objects.get(pk=order_id) return render(request, 'shop/order.html', {'order':order}) Now when I click the link following screen appears. What's the problem ? How can I get the original dashboard retaining what I have done ? -
Django Full Text Search match based on priority fields
I have a Django model which I will use for search. I am implementing a search algorithm to return search results on certain conditions matching priority class Freelancer(models.Model): user = models.OneToOneField( User, on_delete=models.CASCADE, ) skills = models.ManyToManyField( 'skill.Skills', ) gigs = models.ManyToManyField( 'gig.gigs', ) I am implementing a search API so that it results in the following conditions user first name = 30% skills = 90 % gigs = 50% My search should match/rank with the above condition I perform a search. This is my rest api view: class FreelancerSearchAPIView(generics.ListAPIView): filter_backends = [filters.SearchFilter] serializer_class = FreelanerSearchSerializer queryset = Freelancer.objects.all() search_fields = [ 'user__username', 'skills', 'gigs' ] Currently, it's working away which I don't want. Like I just want to type 'python` in search fields, it should search the table with matching based on priority in all fields. and the result should be based on the priority match Can anyone please tell me how can I achieve this? I have read this doc: https://docs.djangoproject.com/en/3.2/ref/contrib/postgres/search/#weighting-queries but still not sure what is the best possible way to do it -
Is there a way I can make users to pay first before making a post on a Django website?
This is my model from django.db import models from django.contrib.auth.models import User from django.conf import settings from django.urls import reverse class Escort(models.Model): name = models.CharField(max_length=40) author = models.ForeignKey(User, on_delete=models.CASCADE) bio = models.TextField() phone = models.CharField(max_length=14) ethnicity = models.CharField(max_length=20) orientation = models.CharField(max_length=20) location = models.CharField(max_length=40) area = models.TextField() skin_color = models.CharField(max_length=40) hair_color = models.CharField(max_length=40) services = models.CharField(max_length=255) paid = models.BooleanField(default=False) def __str__(self): return self.name + '~' + str(self.author) def get_absolute_url(self): return reverse('escort-details', args=(str(self.id))) These are my views from django.shortcuts import render from django.views.generic import ListView, DetailView, CreateView from .models import Escort #def home(request): #return render(request, 'home.html',{}) class HomeView(ListView): model = Escort template_name = 'home.html' class EscortDetailView(DetailView): model = Escort template_name = 'escort_details.html' class AddEscortView(CreateView): model = Escort template_name = 'add_escort.html' fields = '__all__' These are my urls from django.urls import path from . import views from .views import HomeView, EscortDetailView, AddEscortView urlpatterns = [ #path('', views.home, name="home"), path('', HomeView.as_view(), name="home"), path('escort/<int:pk>', EscortDetailView.as_view(), name="escort-details"), path('postad/', AddEscortView.as_view(), name="add-escort"), ] I also have four templates for the four views What I am basically doing is to create a website to advertise escort services. I want a user to sign up/sign in and click on the link "PostAd" and be redirected to a page with … -
Django - How to group forms.CheckboxSelectMultiple items by unique parent field value?
My category models: class Category(models.Model): name = models.CharField(max_length=50, unique=True) description = models.CharField(max_length=255, default='') def __str__(self): return "%s" % (self.name) class SubCategory(models.Model): name = models.CharField(max_length=50, unique=True) description = models.CharField(max_length=255, default='') category = models.ForeignKey(Category, on_delete=models.CASCADE) def __str__(self): return self.name class Meta: ordering = ['name'] Here's my Job class: class Job(models.Model): ... skill_set = models.ManyToManyField(SubCategory) my forms.py: class CustomSelectMultiple(ModelMultipleChoiceField): def label_from_instance(self, obj): return "%s - %s" %(obj.category, obj.name) # return "%s" %(obj.name) class NewJobForm(forms.ModelForm): skill_set = CustomSelectMultiple(widget=forms.CheckboxSelectMultiple, queryset=SubCategory.objects.all()) class Meta: model = Job fields = ['skill_set'] In my template file I have a standard: {{ form|crispy }} In my context: form = NewJobForm() So as expected in my form I see: But I would like my checkboxes to be display as such: How can I achieve that? -
how to build a model on top of the other on django
I have two models Job Position: It's the first object I create and represent a position in a company. ` Job offer: It is related to Job Position through a foreign key and represent a job offer sent out for a specific Job Position Each job position can have multiple job offers associated as you can send multiple job offers out. Now, the Job Position model has some data such as "Salary" that I would like each Job Offer instance to inherit automatically BUT I would also like to be able to change at the Job Offer level (after negotiations). For example: A jobposition is open with salary=50k 10 joboffers are sent out, each with salary 50k After some negotiations, some joboffers are changed to salary 80k Should joboffers have a salary field that I simply set equal to the salary jobposition when I create the object, or should I find a way to tie it initially within the model definition through some sort of foreign key but then make it flexibile? class JobPosition(models.Model): .. salary=models.Integer() class JobOffer(models.Model): position=models.ForeignKey(JobPosition, on_delete=models.CASCADE) ... -
Bulk Delete objects in Django using sqlite
When I use django with sqlite3 and try to delete many objects, FilmPage.objects.all().delete(), I will sometimes run into an error which says django.db.utils.OperationalError: Expression tree is too large (maximum depth 1000) When I tried to limit the number of objects FilmPage.objects.all()[:999].delete(), I will get an error AssertionError: Cannot reorder a query once a slice has been taken. Any suggestions? -
How to use Google One Tap login with django-allauth?
Google One Tap login doesn't use an OAuth flow. My question is how to integrate it into a django app that uses allauth for authentication? I found a tutorial through which you can get the basic details like email, name from the one tap login https://developers.onelogin.com/quickstart/google-ontap-with-onelogin How does one integrate it to complete the login? -
Direct assignment to the reverse side of a related set is prohibited. Use time_interval.set() instead
I have 3 models: Order, orderTimelocation and timeInterval. Order has a relation one to many with orderTimelocation and this has a relation one to many with timeInterval: class Order(models.Model): customer = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='customer') retailer = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='retailer') date_publish = models.DateField() date_available = models.DateField() weight = models.DecimalField(decimal_places=2, max_digits=5) class orderTimelocation(models.Model): longitude = models.DecimalField(decimal_places=8, max_digits=12) latitude = models.DecimalField(decimal_places=8, max_digits=12) order = models.ForeignKey(Order, on_delete=models.CASCADE, related_name='ordertimelocation', null=True) class timeInterval(models.Model): start = models.DateTimeField() end = models.DateTimeField() order_timelocation = models.ForeignKey(orderTimelocation, related_name='time_interval', on_delete=models.CASCADE) I am using Writable nested serializers as the documentation suggests. class OrderSerializer(serializers.ModelSerializer): ordertimelocation = orderTimelocationSerializer(many=True) class Meta: model = Order fields = ['customer', 'retailer', 'date_publish', 'date_available', 'weight', 'ordertimelocation'] def create(self, validated_data): timelocations_data = validated_data.pop('ordertimelocation') order = Order.objects.create(**validated_data) for timelocation_data in timelocations_data: orderTimelocation.objects.create(order=order, **timelocation_data) return order class orderTimelocationSerializer(serializers.ModelSerializer): time_interval = timeIntervalSerializer(many= True) class Meta: model = orderTimelocation fields = ('longitude', 'latitude', 'time_interval') def create(self, validated_data): time_intervals_data = validated_data.pop('time_interval') ordertimelocation = orderTimelocation.objects.create(**validated_data) for time_interval_data in time_intervals_data: orderTimelocation.objects.create(ordertimelocation=ordertimelocation, **time_interval_data) return ordertimelocation class timeIntervalSerializer(serializers.ModelSerializer): class Meta: model = timeInterval fields = ['start', 'end'] The error is the following: Traceback (most recent call last): File "/home/miguel/workspace/projeto-final/backend/env/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/home/miguel/workspace/projeto-final/backend/env/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/miguel/workspace/projeto-final/backend/env/lib/python3.8/site-packages/sentry_sdk/integrations/django/views.py", line …