Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to return correct model fields in serializer?
I am implementing a search bar that returns the users and the posts. I am able to return the data but when i clear the search bar i get the error returned: AttributeError: Got AttributeError when attempting to get a value for field username on serializer SearchUserSerializer. The serializer field might be named incorrectly and not match any attribute or key on the Post instance. Original exception text was: 'Post' object has no attribute 'username'. My Models: class User(AbstractUser): avi_pic = models.ImageField( max_length=400, null=True, blank=True, upload_to='images') name = models.CharField(max_length=50, blank=True, null=True) username = models.CharField(max_length=30, unique=True) class Playlist(models.Model): user = models.ForeignKey( User, on_delete=models.CASCADE, default=None ) cover = models.CharField(max_length=300, default='', blank=True) title = models.CharField(max_length=300, default='', blank=True) date = models.DateTimeField(editable=False, auto_now_add=True) My Serializers: class SearchPostSerializer(serializers.ModelSerializer): username = serializers.SerializerMethodField() class Meta: model = Post fields = ('id', title', 'user', 'username', 'cover') def get_username(self, post): return post.user.username class SearchUserSerializer(serializers.ModelSerializer): class Meta: model = User fields = ('id', 'name', 'username', 'avi_pic') and my Views.py: class SearchView(generics.ListAPIView): def get_serializer_class(self): queryset = self.get_queryset() if len(queryset) == 0: return None if isinstance(queryset[0], User): return SearchUserSerializer elif isinstance(queryset[0], Post): return SearchPostSerializer else: return None def get_queryset(self): query = self.request.query_params.get('q', None) if query is not None: queryset_users = User.objects.filter( Q(name__icontains=query) | … -
How to avoid excessive logging by autoreload in django rest framework?
currently I am using logging from django rest framework.But I am getting excessive logging by autoreload. I want to avoid excessive logging of autoreload. -
Django application running on top of Serverless + Lambda + API Gateway HTTP API is rewriting links to be prefixed with default
My Django Application (Largely REST Framework based) is currently producing URLs on the admin page that don't resolve. The expected result is that the Django Admin's login prompt submits the form with a POST to /admin/login. The resultant URL passed by as the form submission URL by Django is /$default/admin/login and that returns a 404 with the even more obtuse /$default/$default/admin/login/. I'm presuming I have some sort of misconfiguration in either my Django configuration or serverless.yml. As per the following serverless.yml I'm using API Gateway V2, Django through WSGI, and Lambda functions. service: api app: api org: myapp frameworkVersion: '3' provider: name: aws runtime: python3.8 functions: serve: handler: wsgi_handler.handler timeout: 20 environment: DB_NAME: ${param:db_name} DB_PASSWORD: ${param:db_password} DB_USER: ${param:db_user} DB_PORT: ${param:db_port} DB_HOST: ${param:db_host} events: - httpApi: "*" migration: handler: migrate.handler timeout: 60 environment: DB_NAME: ${param:db_name} DB_PASSWORD: ${param:db_password} DB_USER: ${param:db_user} DB_PORT: ${param:db_port} DB_HOST: ${param:db_host} custom: wsgi: app: myapp.wsgi.application plugins: - serverless-python-requirements - serverless-wsgi My URLs are pretty standard: from django.contrib import admin from django.urls import path, include from rest_framework.schemas import get_schema_view schema_view = get_schema_view( title="MyApp", description="MyApp Universal API", version="1.0.0", ) urlpatterns = [ path("admin/", admin.site.urls), path("user/", include("myapp.core.urls"), name="user"), path("openapi", schema_view, name="openapi-schema"), ] My configuration is even more standard: import os from pathlib … -
How to upload react build folder to my remote server?
I'm trying to deploy my react build folder to my server. I'm using index.html and static that configured in my settings.py file to do that. (https://create-react-app.dev/docs/deployment/) Since my backend is running on Ubuntu, I can't just copy from my Windows side and paste it. For now, I uploaded my build folder to my Google Drive and I download it on Ubuntu. But I still can't just copy and paste it on my PyCharm IDE, I can only copy the content in each file and then create a new file ony my server and paste the content to the file. This is just so time-consuming. Is there any better way to do this? Thank you. -
How do I handle sending iOS push notifications if my iOS app back end is in python?
I had a question which I have done a lot of googling on but still couldn't find a suitable answer. I am building my iOS app's back end using django rest framework and what I wanted to know since I am new to iOS is how would notifications show on a user's iphone when lets say a model is changed or something or for example if I make a simple GET request then how does a notification get put out on my iOS app? regards and thanks in advance! Tried googling Tried googling and tried googling -
IntegrityError Django ForeignKey sets to none
I've been having an issue with setting the ForeignKey in one of my model fields for the author variable. See below: class BugTracker(models.Model): project_number= models.IntegerField(primary_key=True) assignee= models.ForeignKey(Developer, on_delete=models.CASCADE) priority = models.CharField(max_length=10, choices=priority_choices) summary=models.TextField() status= models.CharField(max_length=20, choices=progress) author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) created_at=models.DateTimeField(default=timezone.now) updated_at=models.DateTimeField(auto_now=True) def __str__(self): return self.summary def get_absolute_url(self): return reverse("bug_list") "IntegrityError at /projects/create/ NOT NULL constraint failed: core_bugtracker.author_id Request Method: POST Request URL: http://127.0.0.1:8000/projects/create/ Django Version: 4.1.5 Exception Type: IntegrityError Exception Value: NOT NULL constraint failed: core_bugtracker.author_id" As soon as I add "null=True" to the ForeignKey Field, it works and I don't get an error, but the template shows my variable ({bug.author}} equal to "None" regardless of who I'm signed in as. I tried deleting my database and migration files multiple times, but it still doesn't work. Any help would be appreciated here -
How to get request value in another class in django?
It's an example that's as similar as possible, and it's not exactly the same as the actual code. But I believe it's easy to understand. class Fruits: ... def get_sample_data(self, df): ... data = { 'put_file_attachment': >here<, } ... class DataInputForm(forms.Form): attachment = forms.FileField() class MyView(FormView): template_name = 'view.html' form_class = DataInputForm def get_success_url(self): return str( reverse_lazy("milk") ) def post(self, request, *args, **kwargs): get_file = request.FILES.get('attachment') ... k = Fruits() k.load_data() return self.render_to_response(context) I would like to bring the attachment(In fact, get_file) that the user attached to the web class Fruits's >here< In other words, I would like to save the file(get_file) in DB column (put_file_attachment) by the user's attachment. How can I get a value passed to a request from another class to another class? I tried to get 'get_file' by creating a MyView object in the Fruit class, but it doesn't work. Is that possible in this structure or Am I not understanding the concept of request?? -
Trying to configure HTTPS on a AWS Beanstalk Single Instance, getting refused to connect
I'm trying to get HTTPS working on a AWS Beanstalk Python/Django Single instance environment. I've worked through several issues but now I'm stuck, the build deploys and the site works on HTTP, but on HTTPS I get ERR_CONNECTION_REFUSED and nothing appears in the logs that I can see. Started with the directions here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/https-singleinstance-python.html The first issue I ran into was a deployment error Unhandled exception during build: Yum does not have mod24_ssl available for installation and based on this post, I modified it to mod_ssl and that fixed it. The second issue I ran into was another deployment error Command 01killhttpd failed , so I removed those commands based on this post. This was successful in getting the environment to deploy and it works with HTTP, but with HTTPS I just get a refused connection and I can't figure out why. I've poured through the logs several times and see nothing. Here are the full logs. Any help is greatly appreciated. Here are the two files I have created under .ebextensions folder: https-instance.config packages: yum: mod_ssl : [] files: /etc/httpd/conf.d/ssl.conf: mode: "000644" owner: root group: root content: | LoadModule wsgi_module modules/mod_wsgi.so WSGIPythonHome /opt/python/run/baselinenv WSGISocketPrefix run/wsgi WSGIRestrictEmbedded On Listen 443 … -
Django doesn't set cookie
I have a problem setting cookies in Django. Basically I have 3 different cookie I wanna set: Session ID Access token Refresh token For some reason Access and Refresh tokens are set, but the Session ID (SSID) doesn't set. If I change key of "SSID" to for example "TEST_COOKIE" it passes and I can see it in dev tools. However I need SSID and for some magical reason it doesn't work. Here's example of my code: class AuthResponse(SuccessResponse): def __init__(self, data={}, ssid='', access_token: str = '', refresh_token: str = '', **kwargs): super().__init__(data, **kwargs) self.set_cookie(key=settings.SESSION_COOKIE_NAME, value=ssid,) if access_token: self.set_cookie(key=settings.ACCESS_KEY_COOKIE_NAME, value=access_token,) if refresh_token: self.set_cookie(key=settings.REFRESH_KEY_COOKIE_NAME, value=refresh_token,) AuthResponse inherits from SuccessResponse which is based on DjangoJsonResponse, and DjangoJsonResponse eventually inherits from HttpResponse. So the question is - what could cause of getting rid of "SSID" cookie? I tried to look around and find if all the data appears in init function and apprently eveyrthing is fine. All data, ssid, access_token and refresh_token come through, but only "SSID" doesn't get set. As well I tried to use "httponly" and "secure" while setting cookies, but it didn't help. There was an idea that might be middleware affects somehow on this, however I don't know who to … -
How to buffer exception objects with its traceback to be inspected later
I have a user submitted data validation interface for a scientific site in django, and I want the user to be able to submit files of scientific data that will aid them in resolving simple problems with their data before they're allowed to make a formal submission (to reduce workload on the curators who actually load the data into our database). The validation interface re-uses the loading code, which is good for code re-use. It has a "validate mode" that doesn't change the database. Everything is in an atomic transaction block and it gets rolled back in any case when it runs in validate mode. I'm in the middle of a refactor to alleviate a problem. The problem is that the user has to submit the files multiple times, each time, getting the next error. So I've been refining the code to be able to "buffer" the exceptions in an array and only really stop if any error makes further processing impossible. So far, it's working great. Since unexpected errors are expected in this interface (because the data is complex and lab users are continually finding new ways to screw up the data), I am catching and buffering any exception … -
ERR_CONNECTION_TIMED_OUT error is returned in the site after deploing a Django application to Heroku
I just re-deployed an application in the new Eco Dyno and provisioning a new PostgreSQL datbase, however after deploying successfully, when I try to open the application, this HTTP error is returned ERR_CONNECTION_TIMED_OUT and the application never opens. I also updated the stack from heroku-20 to heroku-22 and it is not working on both. Is there any additional configuration that I need to complete? This is the log from the latest deploy 2023-01-30T22:13:55.000000+00:00 app[api]: Build started by user farmacia@aselsi.org 2023-01-30T22:14:32.846408+00:00 app[api]: Deploy c6f350bc by user farmacia@aselsi.org 2023-01-30T22:14:32.846408+00:00 app[api]: Release v23 created by user farmacia@aselsi.org 2023-01-30T22:14:33.126404+00:00 heroku[web.1]: Restarting 2023-01-30T22:14:33.141734+00:00 heroku[web.1]: State changed from up to starting 2023-01-30T22:14:34.066230+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2023-01-30T22:14:34.109732+00:00 app[web.1]: [2023-01-30 22:14:34 +0000] [4] [INFO] Handling signal: term 2023-01-30T22:14:34.109979+00:00 app[web.1]: [2023-01-30 22:14:34 +0000] [9] [INFO] Worker exiting (pid: 9) 2023-01-30T22:14:34.110205+00:00 app[web.1]: [2023-01-30 22:14:34 +0000] [10] [INFO] Worker exiting (pid: 10) 2023-01-30T22:14:34.310286+00:00 app[web.1]: [2023-01-30 22:14:34 +0000] [4] [INFO] Shutting down: Master 2023-01-30T22:14:34.461478+00:00 heroku[web.1]: Process exited with status 0 2023-01-30T22:14:35.372879+00:00 heroku[web.1]: Starting process with command `gunicorn aselsi.wsgi` 2023-01-30T22:14:36.441571+00:00 app[web.1]: [2023-01-30 22:14:36 +0000] [4] [INFO] Starting gunicorn 20.1.0 2023-01-30T22:14:36.441910+00:00 app[web.1]: [2023-01-30 22:14:36 +0000] [4] [INFO] Listening at: http://0.0.0.0:54892 (4) 2023-01-30T22:14:36.441956+00:00 app[web.1]: [2023-01-30 22:14:36 +0000] [4] [INFO] Using worker: sync … -
Django rest framework unsupported media type with image upload
this is my first time trying to upload image to django rest framework, i am using svelte for my front end and using the fetch api for requests. i am have an error that i cannot solve. all requests containing images return an unsupported media type error. Back End i have added these line to my settings.py # Actual directory user files go to MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'mediafiles') # URL used to access the media MEDIA_URL = '/media/' my simplified views.py @api_view(['GET', 'POST']) @permission_classes([IsAuthenticated]) @parser_classes([FormParser, MultiPartParser]) def products(request): if request.method == 'POST' and isPermitted(request.user, 'allow_edit_inventory'): serializer = ProductSerializer(data=request.data) serializer.initial_data['user'] = request.user.pk if serializer.is_valid(): serializer.save() return Response({'message': "product added"}, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) my urls.py from django.contrib import admin from django.urls import path, include from rest_framework.authtoken import views from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('api/', include("API.urls")) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) and finally my models.py def product_images_upload_to(instance, filename): return 'images/{filename}'.format(filename=filename) class Product(models.Model): name = models.CharField(max_length=200) image_url = models.ImageField(upload_to=product_images_upload_to, blank=True, null=True) Front End my file upload component in svelte, the exported image variable is what get used in the request in the following code. export let avatar, fileinput, image; const onFileSelected = (e) => { image … -
Django Admin: search_fields with an optional null value
I have a Django Admin model as such. class ImportedItemAdmin(admin.ModelAdmin): autocomplete_fields = ["author"] search_fields = ("author__username",) The problem here is that the Author might be nil which causes a 'NoneType' object has no attribute 'username' error. Is there a way to support both nil authors and still search by username? -
File upload using Django framework
I need insights on how to upload a file on click of a save button.I have to upload a file and also capture user selections and save them(user selections) in a file when I click on "save". And then once the file uploaded successfully run button should get enabled and when I click on run button , uploaded file should get processed as per the user inputs. I have created a simple form and a view to upload a file on click of a submit button,but I dont know how to have a save button before submit. My View: def projects_upload(request): print(settings.MEDIA_ROOT) if request.method=='POST': upload_request=UploadFile() upload_request.file=request.FILES['file_upload'] upload_request.save() Form: <form action="uploadProject" method="post" enctype="multipart/form-data"> {% csrf_token%} <input type="file" name="file_upload" id="choose_upload_file" value="" accept=".zip,.rar,.7z,.gz,"></br> <input type="submit" class="btn btn-secondary btn-block" value="upload" id="file_upload1"> </form> -
Django - Postgres connection
I am super beginner, but want to learn super fast building web application. I am right now developing an Income-Expense web app on Django Framework (Python, js and Ajax). I am now stuck with the server and get different errors. Anyone can support me ? ERROR "django.db.utils.OperationalError: connection to server on socket "/tmp/.s.PGSQL.5432" failed: fe_sendauth: no password supplied" I think I shut down everything not properly and when a came back my virtual environment was not working. Thank You Don't know what to try more -
Django CustomUser
I extended default User model as follow: class CustomUser(AbstractUser): email = models.EmailField(_('email address'), unique=True) first_name = models.CharField(max_length = 100, blank = False) last_name = models.CharField(max_length = 100, blank = False) ... USERNAME_FIELD = 'email' EMAIL_FIELD = 'email' REQUIRED_FIELDS = ['first_name', 'last_name', 'username','password'] Now when creating a new superuser the prompt for password is not hidden $ python manage.py createsuperuser Email address: user1@coolapp.com First name: John Last name: Smith Username: cool_username Password: fancy_p4$$w0rd Superuser created successfully. Is there any way it can be hidden? -
Create model for schema of csv file
I need to create model for schema which consists of name and columns. Users can build the data schema with any number of columns of any type. Each column also has its own name (which will be a column header in the CSV file), type and order (just a number to manage column order). The problem is that I have to create schema at one time with columns, but I don't know how to do this. My current models: SCHEMA_TYPE_CHOICE = ( ('Full Name', 'Full Name'), ('Job', 'Job'), ('Email', 'Email'), ('Company', 'Company'), ('Phone Number', 'Phone Number'), ('Address', 'Address'), ('Date', 'Date'), ) class Schema(models.Model): title = models.CharField(max_length=100, unique=True) updated_at = models.DateTimeField(auto_now=True) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.title class Column(models.Model): name = models.CharField(max_length=100) type = models.CharField(max_length=100, choices=SCHEMA_TYPE_CHOICE, default='Full Name') order = models.PositiveIntegerField(default=1) schema = models.ForeignKey(Schema, on_delete=models.CASCADE, related_name='column_schema') def __str__(self): return self.name Form that I have to realize: enter image description here -
Best backend language for full stack development
What should I use - Node.js(Javascript) Or Django(Python) , If I want to become a full stack Developer? I'm a beginner in this. So please give suggestion regarding this. -
Django prefilled Admin Tabular Inline
My goal is that the first column of my tabular inline sheet is filled with data from another table. I've attached a screenshot where you can see that for tablename=game I want to insert the game number (eg. 1), the metric (e.g time), the player_names and the values (-> scores) per player. Number and metric applies to the hole game. Each game within Table=Game shall contain number metric player_1:name and score player_2:name and score ... and so on. The player names are stored in a table called players. Is there a way to pre-fill the first row of my tabular inline with my player_names. Otherwise i have to write it down for each game. Django admin panel_tabularInline I've created several models in models.py: class Game(models.Model): player_name = models.CharField(max_length=30) class Game (models.Model): NUMBER = ( (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)) METRIC = ( ('Kills', 'Kills'), ('Time', 'Time'), ('Deaths', 'Deaths') ) number = models.BigIntegerField(default=1, choices=NUMBER) metric = models.CharField(max_length=30, choices=METRIC) class GameItem (models.Model): value = models.CharField(max_length=30) game = models.ForeignKey(Game, on_delete=models.CASCADE) def __str__(self): This is my admin.py file: from django.contrib import admin from .models import * class GameItemInline(admin.TabularInline): model = GameItem extra = 6 #I've got 6 … -
Get jwt token to pass it to unit test
I'm trying to retreive jwt access token to pass it to unit test but everytime I try to get it I receive 'not authorized' error. User is created in database with factory #factories.py class UserFactory(factory.django.DjangoModelFactory): class Meta: model = User username = "test_user" password = "test123" date_of_birth = "2000-01-22" email = "tests@test.ru" role = "moderator" class AdFactory(factory.django.DjangoModelFactory): class Meta: model = Ad name = "test" author_id = factory.SubFactory(UserFactory) price = 100 description = "None" is_published = "FALSE" category = factory.SubFactory(CategoryFactory) image = None And I', trying to get jwt access token in fixtures.py # fixtures.py import pytest @pytest.fixture @pytest.mark.django_db def user_token_jwt(client): username = "test_user" password = "test123" response = client.post( "/user/token/", {"username": username, "password": password}, format="json" ) print(response.data) return response.data["access"] Finally, the test function itself. Please help me to understand how to retrieve a jwt access token in Django with such project architecture? @pytest.mark.django_db def test_create_ad(client, ad, user_token_jwt): # user_token_jwt = client.post( # "/user/token/", # {"username": "test_user", "password": "test123"}, # content_type="application/json" # ) expected_response = { 'id': ad.pk, 'name': 'test', 'author_id': ad.author_id_id, 'author': ad.username, 'price': 100, 'description': 'None', 'is_published': 'FALSE', 'category_id': ad.category_id, 'image': None } data = { "name": "test", "price": 100, "description": "None", "author_id": ad.author_id, "category": ad.category_id, } response … -
How to show value of Count Function on my template. Django
I would like to show the total number of employees registered in my database. Using the count function. My views.py: def home(request): return render(request, 'dashboard.html') def return_total_employees(request): return_total = Employees.objects.aggregate(total=Count('EmployeeCard'))[ 'total' ] return render(request, 'dashboard.html', {'return': return}) My template: <h1> {{ view.return_total_employees }} </h1> -
check for exact presence in a queryset django, jinja 2
in my case, I have a question to check if the exact string name of a model does exist in a query set. here is my code: views.py: if Despiking.objects.filter(user=request.user).exists(): filtered_projects = Despiking.objects.filter(user=request.user) context.update({ 'filtered_projects': filtered_projects.__str__(), }) template.html: {% if info.project_name in filtered_projects %} <!-- some HTML elements --> {% else %} <!-- other HTML elements --> {% endif %} in my code, there is no difference between "my project" and "project" as info.project_name model. because of that the "project" word exists in the query set when I have only the "my project" in it. so using {% if info.project_name in filtered_projects %} works the same (the condition of if will be True) because that "project" word exists in the query set because of the "my project". what can I do to check the exact string in it? -
Django context isn't passing information to template
I try to pass information to an html template from a view function. Every time I try to call the variable from the html template it doesn't show anything. Here is my configure_peplink.html: {% extends "base_generic.html" %} {% block content %} <h1>Configure Peplink</h1> <p>Configure a Peplink router from the web. This was designed by <em>Valorence LLC</em></p> {% if peplink %} <p>Serial Number: {{ peplink.serial_number }}</p> <p>IP Address: {{ peplink.ip_address }}</p> <p>Mac Address: {{ peplink.mac_address }}</p> <p>Name: {{ peplink.name }}</p> {% else %} <p>No Data Found Off Device</p> {% endif %} {% endblock %} Here is the view function configure_peplink: def configure_peplink(request, peplink): selected_peplink = PeplinkDevice.objects.get(serial_number=peplink) print(selected_peplink.ip_address) print(selected_peplink.serial_number) print(selected_peplink.mac_address) context = { 'peplink': selected_peplink } return render(request, 'configure_peplink.html', context=context) Here is the url line to call the view: re_path(r'^configurepeplink/(?P<peplink>.*)/$', views.configure_peplink, name='configurepeplink') I've tested to make sure that the context has data in it (as seen with the print statements). Even though the context variable has data and is getting past the if statement in the html template it still doesn't display any data. I have tried clearing my cache on the browser and restarting all my services (django, celery, redis-server). Here is a picture of the webpage: -
Django-widget-tweaks Email address can't be entered error
I'm using Django-widget-tweaks. I am getting an error that prevents me from entering my Email address. What is the solution? html {% extends 'app/base.html' %} {% load widget_tweaks %} {% block content %} <div class="card card-auto my-5 mx-auto"> <div class="card-body"> <h5 class="card-title tex-center">ログイン</h5> <form method="post" class="form-auth"> {% csrf_token %} <div class="form-label-group"> {% render_field form.login class='form-control' placeholder='Email' %} </div> <div class="form-label-group"> {% render_field form.password class='form-control' placeholder='Password' %} </div> <div class="buttton mx-auto"> <button class="btn btn-lg btn-primary btn-block mx-auto" type="submit">Login</button> </div> </form> </div> </div> {% endblock %} I can't enter my email address. -
django - overriding save method with super returns unique contraint error when creating object
Overriding save method with super returns unique contraint error when creating object. How to solve it? def save(self, *args, **kwargs): if self.pk is None: super(IntoDocumentProduct, self).save(*args, **kwargs) # some logic # more logic super(IntoDocumentProduct, self).save(*args, **kwargs) self.full_clean() Below is the error that appears in the console. It directs specifically to the save() method in the model. I don't know what is wrong with it. After all, I can't use self.save(), because there will be a recursive loop. Traceback (most recent call last): File "W:\projects\foodgast\venv\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner response = get_response(request) ^^^^^^^^^^^^^^^^^^^^^ File "W:\projects\foodgast\venv\Lib\site-packages\django\core\handlers\base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "W:\projects\foodgast\venv\Lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "W:\projects\foodgast\venv\Lib\site-packages\django\views\generic\base.py", line 103, in view return self.dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\views.py", line 509, in dispatch response = self.handle_exception(exc) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception raise exc File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\views.py", line 506, in dispatch response = handler(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 81, in inner return func(*args, **kwds) ^^^^^^^^^^^^^^^^^^^ File "W:\projects\foodgast\src\wms\api\views.py", line 183, in post serializer.save() File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\serializers.py", line 212, in save self.instance = self.create(validated_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\serializers.py", line 962, in create instance = ModelClass._default_manager.create(**validated_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File …