Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Is there any order for inheriting PermissionRequiredMixin in Django?
I encountered this problem while following the Django tutorialDjango tutorial 8. I can redirect to the login page when I put PermissionRequiredMixin class first. class AuthorCreate(PermissionRequiredMixin, CreateView): model = Author fields = '__all__' initial = {'date_of_death': '05/01/2018', } permission_required = 'catalog.add_author' result of First But when I put it in second position it doesn't work and goes directly to the page where the permission doesn't allow it. class AuthorCreate(CreateView, PermissionRequiredMixin): result of Second I want to know is whether I should always put the PermissionRequiredMixin class at the first position. And how about LoginRequiredMixin? or what if I inherit both? -
How to update the quantity of a custom order?
I am trying to update the quantity of a custom order in my bag. In a Django e-commerce application. I am getting an error stating: argument of type 'int' is not iterable, however I am wrapping the custom_order_id in a string. I need the bag to be in the format bag = {[{195,2},{187:3}]} def custom_order_update(request, custom_order_id): """ Updates the quantity of custom orders added to the bag""" bag = request.session.get('bag', {}) quantity = int(request.POST.get('quantity')) custom_orders = bag.get('custom_orders', []) for quantity_dict in custom_orders: if str(custom_order_id) in quantity_dict: quantity_dict[str(custom_order_id)] = quantity break bag['custom_orders'] = custom_orders request.session['bag'] = bag return redirect(reverse('view_bag')) -
How to create hierarchical parent/child relationships with specific permissions in an already build Django (DRF) app
I need to build out a data model in an already existing Django app that uses DRF and I am quite new to Django. The rules are as follows: There are ParentOrganizations and ChildOrganizations that Users can belong to. A ParentOrganization can have many ChildOrganizations An app user can can belong to many ChildOrganizations, but all ChildOrganizations they belong to, must belong to the same parent There is a caveat here that internal super users will have access to all parent and child orgs A app user can have different permissions on each ChildOrganization that they belong to. We will use Django Admin to create users and assign them to their parent and child organizations along with the permissions for each child organization A few questions and some code: This app already exists so it seems that I missed the boat on building out the custom user class without some hacky stuff. Does any of the above warrant extending the auth.User? I'm thinking this isn't necessary. Would the built in Django groups and roles be an okay way to accomplish this? I'm worried about getting locked into things as our use cases become more complex. Assuming I build this out … -
Retrieving Single User Data in Django View Returns Multiple Users
i have encountered an issue with retrieving user data in my view. I have implemented a view to retrieve data for a single user using their ID. However, when I make a request to this view, instead of getting data for just the specified user, I receive data for all users in the system. def test_retrieve_custom_user(self): test_user = CustomUser.objects.create( .... ) test_user_id = test_user.id request = self.factory.get(f"/users/{test_user_id}/") force_authenticate(request, user=self.admin_user) response = self.view(request, pk=test_user_id) print(response.data) print(response.data) The print(response.data) statement outputs data for multiple users, even though I expect to retrieve data for only the user with the specified ID (test_user_id). ...[OrderedDict([('id', 6), ('password', 'pbkdf2_sha256$720000$eUORH8514yvMMuVwQ3m19Q$VId/VYtfaFqVu3fDIxDBXpENptb06tsVtH6qWxpsB0Y='), ('last_login', None), ('is_superuser', True), ('username', 'superuser'), ('first_name', ''), ('last_name', ''), ('email', 'superuser@email.com'), ('is_staff', True), ('is_active', True), ('date_joined', '2024-02-29T22:36:57.909754Z'), ('groups', []), ('user_permissions', []), ('address', None), ('phone_number', None)]), OrderedDict([('id', 7), ('password', 'testpassword'), ('last_login', '2024-02-29T00:00:00Z'), ('is_superuser', False), ('username', 'existinguserew123123'), ('first_name', 'Test'), ('last_name', 'User'), ('email', 'test@example.com'), ('is_staff', False), ('is_active', True), ('date_joined', '2024-02-29T00:00:00Z'), ('groups', []), ('user_permissions', []), ('address', 4), ('phone_number', 4)]), OrderedDict([('id', 8), ('password', 'testpassword'), ('last_login', '2024-02-29T00:00:00Z'), ('is_superuser', False), ('username', 'existinguseresadw123123'), ('first_name', 'Test'), ('last_name', 'User'), ('email', 'test@example.com'), ('is_staff', False), ('is_active', True), ('date_joined', '2024-02-29T00:00:00Z'), ('groups', []), ('user_permissions', []), ('address', 4), ('phone_number', 4)])]``` -
Django app taking around 24 seconds to load webpage after retrieving data from PostgreSQL database
I have a Django application where I'm querying a PostgreSQL database using raw SQL queries in my views.py file. Once I retrieve the data, I process it and send it to the index.html file. However, every time I load the webpage, it takes approximately 24 seconds to fully load. Here's an overview of my setup: I have a Django app configured to connect to a PostgreSQL database. In my views.py file, I'm using raw SQL queries to fetch data from the database using Django models. After processing the data, I pass it to the index.html template for rendering. I've added print statements in views.py to measure the time taken to retrieve and process the data. Additionally, I'm tracking the time it takes for the webpage to load using JavaScript in the DOM of index.html. Despite optimizing my SQL queries and processing logic, I'm still experiencing significant delays in webpage loading. I'm seeking guidance on potential reasons for this delay and strategies to improve the loading time of my Django application. Any insights or suggestions would be greatly appreciated. Thank you! -
Dynamic mocking using patch from unittest in Python
I'm going to mock a Python function in unit tests. This is the main function. from api import get_users_from_api def get_users(user_ids): for user_id in user_ids: res = get_users_from_api(user_id) I'm trying to mock get_users_from_api function in the unit test because it's calling the 3rd party api endpoint. This is the test script. @patch("api.get_users_from_api") def test_get_users(self, mock_get_users) user_ids = [1, 2, 3] mock_get_users.return_value = { id: 1, first_name: "John", last_name: "Doe", ... } # mock response get_users(user_ids) # call main function The issue is that I'm getting the same result for all users because I only used one mock as the return value of get_users_from_api. I want to mock different values for every user. How can I do this? -
Why is Django REST Framework APITestCase unable to create the test database which is hosted on ElephantSQL?
I am currently trying to learn how to run tests in Python/Django REST Framework. I've created a database which is stored on ElephantSQL, using their free tier (tiny turtle) plan. I've connected the database successfully and have been able to create tables on there. However, I'm trying to learn unit testing so I'm currentlt trying to use APITestCase to test the register view. My test is written as below: import json from django.contrib.auth.models import User from django.urls import reverse from rest_framework.authtoken.models import Token from rest_framework.test import APITestCase from rest_framework import status from users.serializers.common import RegistrationSerializer, UserSerializer class RegistrationTestCase(APITestCase): def test_registration(self): data = {'username': 'testuser', 'email': 'test@email.com', 'password': 'super_unique_password', 'password_confirmation': 'super_unique_password'} # Add a test user to database response = self.client.post('/api/auth/register/', data) # Test that 201 status is receieved self.assertEqual(response.status_code, status.HTTP_201_CREATED) My databases in settings.py are set up like this: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': env('DATABASE_NAME'), 'HOST': env('DATABASE_HOST'), 'PORT': 5432, 'USER': env('DATABASE_USER'), 'PASSWORD': env('DATABASE_PASS'), }, 'test': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': env('DATABASE_NAME'), 'HOST': env('DATABASE_HOST'), 'PORT': 5432, 'USER': env('DATABASE_USER'), 'PASSWORD': env('DATABASE_PASS'), } } When I run python manage.py test --verbosity=2 I get the following error: Found 1 test(s). Skipping setup of unused database(s): test. Creating test database for alias 'default' … -
How to document server sent-event with drf-spectacular
I am migrating from drf-yasg to drf-spectacular and I am having trouble migrating the documentation for a server sent event / StreamingHttpResponse. This is the code that worked in drf-yasg. How would you write this with drf-spectacular? class EventStreamData(SwaggerAutoSchema): def get_produces(self): return ["text/event-stream"] def get_consumes(self): return ["text/event-stream"] @api_view(["GET"]) @renderer_classes([EventStreamRenderer]) response = StreamingHttpResponse(event_stream(), content_type="text/event-stream") response['Cache-Control'] = 'no-cache' return response swagger_info = extend_schema(methods='GET', auto_schema=EventStreamData, tags=['2. Server Sent Events'], responses={200: openapi.Response( description="text/event-stream", examples={ "text/event-stream": "data: { " "'field1': '', " "'field2': '', " "'field3': '', " "'field4': '', " "}" }) }) data_stream = swagger_info(data_stream) -
Is there a reason to individualize Django class based views?
In a Django tutorial I am watching someone writes: class GetUserProfileView(APIView): def get(self, request, format=None): # user profile get code class UpdateProfileView(APIView): def put(self, request, format=None): # user profile put code whereas to me a beginner it seems to make way more sense to organize it in one view: class ProfileView(APIView): def get(self, request, format=None): # user profile get code def put(self, request, format=None): # user profile put code Is there a reason for organizing them into different views or is the tutorial maker unexperienced? -
NextCloud user_oidc (as RP) with django-oidc-provider (as OP) fails
My goal is to authenticate NextCloud (v.28.0.2) users against my own Django (v.4.2.7) based web service. I decided to integrate two "libraies": OpenID Connect Login (v.5.0.1) and django-oidc-provider (v.0.8.2). Details: Integration starts, "authorize" endpoint seems to work fine but finally (see last line): INFO 2024-02-29 18:25:23,644 basehttp 142 139883821131456 "GET /oidc/authorize?client_id=989432&response_type=code&scope=openid+email+profile&redirect_uri=https%3A%2F%2Farch.stg.leonarski.pl%2Fapps%2Fuser_oidc%2Fcode&claims=%7B%22id_token%22%3A%7B%22email%22%3Anull%2C%22name%22%3Anull%2C%22quota%22%3Anull%2C%22groups%22%3Anull%7D%2C%22userinfo%22%3A%7B%22email%22%3Anull%2C%22name%22%3Anull%2C%22quota%22%3Anull%2C%22groups%22%3Anull%7D%7D&state=JSEINWUTEKPX53VRYGWSM57JG03RXB6L&nonce=S1Q1SVUP854OIAA05HENUOCXPQBSQ12B HTTP/1.0" 302 0 WARNING 2024-02-29 18:25:24,106 basehttp 142 139883821131456 "GET /oidc/token HTTP/1.0" 405 0 I applied default (I think) settings on both sites and expect "happy end". Also I tried with another package on Django site (django-oauth-toolkit v.2.3.0) but found the same error: WARNING 2024-02-29 18:25:24,106 basehttp 142 139883821131456 "GET /oidc/token HTTP/1.0" 405 0 Question: according to resourecs I found, "token" endpoint should be reached with POST method. So why there is a GET request sent from NextCloud? BTW, status code 405 is reasonable here. Finally, as I belive I'm not the first person worldwide trying this kind of integration then I must be wrong somewhere. But who knows where? Regards, Dariusz -
Vue.js (using nginx, Django, + gunicorn) site being served at wrong url: www.myurl.com/static/ instead of www.myurl.com/
I am using Vue.js for the frontend and Django RF for the backend of my project. When developing locally, the project works as intended with the root of the Vue project functioning at localhost:8081/#/ and accessing components like "Example.vue" at localhost:8081/#/example. I am using nginx on an AWS Ubuntu instance to serve my project. After running 'npm run build', my project is served successfully and works with my Django backend as expected, however, only if accessing the project at www.myurl.com/static. When navigating to www.myurl.com, I am served a basic html page that says "My Project is coming soon". I must have created this file at some point but cannot figure out where it lives in ubuntu file system. Ultimately I need to fix whatever I've misconfigured so that navigating to www.myurl.com serves my Vue.js files. enter image description here This is my current Vue file structure. enter image description here This is how my static path is configured with Django's settings.py - I am not sure if this would affect my setup for the Vue files, however, I wanted to include it for reference. enter image description here This is my nginx.conf file This is my sites-available project file which … -
Does Faust Streaming Consumer retry the offset commit if it fails?
After investigating my consumer logs I found out the following error: [ERROR] OffsetCommit failed for group gaming-processor on partition TopicPartition(topic='my_topic', partition=3) with offset OffsetAndMetadata(offset=29426192, metadata=''): UnknownTopicOrPartitionError This error occurred when my kafka broker leader pod on GKE was rotating. I think this error is expected while rebalancing is occurring my question is if the application is going to retry to commit this offset again or will it only commit the next offset in the next commit wave? Additionally I would like to know if this can cause the consumer to re-read older messages that were already consumed or to lose any message that wasn't yet consumed. -
Pass JS variable to another JS and to django view
I have several cards with items. I added a counter to each card and a button 'Add to cart'. I want to pass the count of item into django view using ajax. But I dont know how to pass variable from counter to ajax function, for each card. The current version doesn't work correctly, cuz every time count = 1. var globalVariable; var buttonPlus = $(".qty-btn-plus"); var buttonMinus = $(".qty-btn-minus"); var incrementPlus = buttonPlus.click(function() { var $n = $(this) .parent(".col") .find(".input-qty"); $n.val(Number($n.val()) + 1); globalVariable = $(this).$n.val(); }); var incrementMinus = buttonMinus.click(function() { var $n = $(this) .parent(".col") .find(".input-qty"); var amount = Number($n.val()); 1 if (amount > 0) { $n.val(amount - 1); globalVariable = $(this).$n.val(); } }); $(document).ready(function() { $(".send-quantity").click(function() { var quantity = globalVariable; if (quantity === undefined) { quantity = 1; } var id = $(this).data("id"); $.ajax({ url: "{% url 'stripe_order:cart_add' %}", data: { 'id': id, 'quantity': quantity, }, }); }); }); My HTML: {% for item in items %} <div class="col"> <div class="card mb-4 rounded-4 shadow-sm"> <div class="card-header py-3"> <h3 class="my-0 fw-normal">{{ item.name }}</h3> </div> <div class="card-body"> <h4 class="card-title pricing-card-title ">${{ item.price }}</h4> <ul class="list-unstyled mt-3 mb-4"> <li>{{ item.description }}</li> </ul> <div class="row"> <div class="col"> <div class="col … -
Is it possible to obtain both the count and results of a query in a single MySQL query?
I'm currently working on optimizing a MySQL query, and I'm wondering if there's a way to retrieve both the count of the results and the actual result set in a single query. I'm aware that I can achieve this using separate queries, one for the count and one for fetching the results, but I'm curious if there's a more efficient way to accomplish this within a single query. -
Django DeserializationError: "string indices must be integers, not 'str'" when loading large JSON data into SQLite
I'm encountering a TypeError: string indices must be integers, not 'str' error while trying to load large JSON data into my Django application using the load data command. The data is stored in C:\Users\ambai\PyCharm Projects\Task1\app/fixtures\data.json. My models are defined in models.py. this is the models.py fields I created based on the raw json format data I used gemini.ai to generate these fields did not done it manually: from django.db import models # Create your models here. class Game(models.Model): team=models.CharField(max_length=50) team1=models.CharField(max_length=50) team_score=models.IntegerField() team1_score=models.IntegerField() box=models.URLField() box1=models.URLField() class Team(models.Model): game_set=models.ForeignKey(Game,on_delete=models.CASCADE,related_name='team_set') points=models.IntegerField() field_goals=models.IntegerField() field_goals_attempts=models.IntegerField() field_goals_percentage=models.FloatField() three_pointers_made=models.IntegerField() three_point_attempts= models.IntegerField() three_point_percentage=models.FloatField() free_throws_made= models.IntegerField() free_throw_attempts= models.IntegerField() free_throw_percentage=models.FloatField() offensive_rebounds= models.IntegerField() total_rebounds= models.IntegerField() assists= models.IntegerField() personal_fouls= models.IntegerField() steals= models.IntegerField() turnovers= models.IntegerField() blocks= models.IntegerField() class Field(models.Model): game_set = models.ForeignKey(Game, on_delete=models.CASCADE) author= models.CharField(max_length=100) body=models.TextField(max_length=100) created_at= models.DateTimeField(auto_now_add=True) the error it shows when I run the loaddata command is of Deserialization: python manage.py loaddata app/fixtures CommandError: No fixture named 'fixtures' found. (.venv) PS C:\Users\ambai\PycharmProjects\Task1> python manage.py loaddata app/fixtures/data.json Traceback (most recent call last): File "C:\Users\ambai\PycharmProjects\Task1\.venv\Lib\site-packages\django\core\serializers\json.py", line 70, in Deserializer yield from PythonDeserializer(objects, **options) File "C:\Users\ambai\PycharmProjects\Task1\.venv\Lib\site-packages\django\core\serializers\python.py", line 114, in Deserializer Model = _get_model(d["model"]) ~^^^^^^^^^ TypeError: string indices must be integers, not 'str' The above exception was the direct cause of the following exception: Traceback … -
KeyError in Django when using Huggingface API
i use Django and i want to use Huggingface API with it. The API sometimes return error to me saying: KeyError at /GenerativeImage2Text 0 34. if "generated_text" in output[0]: ^^^^^^^^ this is my view.py def GIT(request): output = None generated_text = None form = ImageForm() if request.method == 'POST': form = ImageForm(request.POST, request.FILES) if form.is_valid(): form.save() image_name = str(form.cleaned_data['Image']) imgloc = os.path.join( 'media', 'images', image_name) while True: output = query(imgloc) if "generated_text" in output[0]: generated_text = output[0].get('generated_text') break else: print(output[0]) else: print("This image is invalid") return render(request, "imagecaptioning.html", {"form": form, "output": generated_text}) i want to fix this problem and make sure that API always return no error such that. is the problem in my code or with the API ? thanks in advance -
Add more than one custom order to a bag session - Django e-commerce application
I am building a Django e-commerce application. I have implemented to ability to leave a custom order on the site and for users to be able to update the quantity, delete the custom order and checkout. I am now trying to refactor the code to allow more than one custom order to be placed in the users bag. What is currently happening is the second custom order is replacing the first custom order in the bag. context.py file if 'custom_order' in bag: custom_order_id = bag['custom_order'] custom_order = CustomOrder.objects.get(pk=custom_order_id) if 'quantity' in bag: total += bag['quantity'] * custom_order.price individual_total = bag['quantity'] * custom_order.price bag_items.append({ 'product_id': custom_order.product_id, 'custom_order_id': custom_order_id, 'category': custom_order.category, 'material': custom_order.material, 'individual_total': individual_total, 'quantity': bag['quantity'], 'product_name': custom_order.product_name, 'price': custom_order.price, }) else: total += custom_order.price bag_items.append({ 'product_id': custom_order.product_id, 'custom_order_id': custom_order_id, 'category': custom_order.category, 'material': custom_order.material, 'individual_total': custom_order.price, 'quantity': 1, 'product_name': custom_order.product_name, 'price': custom_order.price, }) my view where I am adding to the bag: def add_custom_order_to_bag(request, custom_order_id): """Add custom order to the shopping bag """ custom_order = CustomOrder.objects.get(pk=custom_order_id) bag = request.session.get('bag', {}) bag['custom_order'] = custom_order_id request.session['bag'] = bag return redirect(reverse('view_bag')) I tried adding a list into the view to handle the multiple custom orders, which seemed like the right way to go, but … -
Python requests returns 503 status code as response when sending a file through POST request
So I am using python requests to send a post request to another server (both servers are internal to the company). It worked some weeks ago, but I tried today and it has suddenly stopped working. I can use postman to send the same request and the server responds with 201. I can perform a get request from my python code using requests library. The problem ONLY occurs on post request from python code. Here's the piece: with open(filepath, "rb") as f: # f is a file-like object. data = {"name": experiment_id + ".zip", "content": f} #The CALCSCORE_URL is an env variable named CALCSCORE_BE set up in each environment. calcscore_url = f"{settings.CALCSCORE_URL}/api/hive/experiment/{experiment_id}/roi" response = request.post(calcscore_url, files=data) I tried different things, like sending the data in a separate 'files' and 'data' argument but its always the same error. The file is 5 MB in size. I don't think its that big? response.content shows response timed out. -
django view with redis cluster not working
I'm using AWS elasticache redis cluster. However, I'm unable to implement my current view to utilize the cluster. Here's my view: redis_conn = redis.Redis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=0, decode_responses=True) def orders(request): logger.info(f"Accessing the orders view for user: {request.user.username}") # Fetch user-specific cached shipment data processed_shipments_display_str = redis_conn.get(f"processed_shipments_display_{request.user.id}") all_shipments_display = [] last_updated_at = "Not Available" if processed_shipments_display_str: cache_data = json.loads(processed_shipments_display_str) all_shipments_display = cache_data.get('shipments', []) last_updated_at = cache_data.get('timestamp', 'Not available') else: all_shipments_display = [] last_updated_at = 'Not available' return render(request, 'app/orders.html', { 'all_shipments': all_shipments_display, 'last_updated_at': last_updated_at }) Everytime I try to access the page it just loads and nothing ever happens. I'm unable to use redis-py-cluster (which worked initially) since my redis version is incompatible with channels-redis and this. I also tried using startup_nodes = [{"host": settings.REDIS_HOST, "port": settings.REDIS_PORT}] redis_conn = RedisCluster(startup_nodes=startup_nodes, decode_responses=True) but then I keep getting the error AttributeError at /app/orders/ 'dict' object has no attribute 'name' Here's my settings.py: REDIS_HOST = os.getenv('REDIS_HOST', 'clustercfg.rediscluster.m0rn9y.use1.cache.amazonaws.com') REDIS_PORT = os.getenv('REDIS_PORT', 6379) CHANNEL_LAYERS = { "default": { "BACKEND": "channels_redis.pubsub.RedisPubSubChannelLayer", "CONFIG": { "hosts": [{ "address": "rediss://clustercfg.rediscluster.m0rn9y.use1.cache.amazonaws.com:6379", "ssl_cert_reqs": None, }] }, }, } CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "rediss://clustercfg.rediscluster.m0rn9y.use1.cache.amazonaws.com:6379", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "SSL_CERT_REQS": None, } } } Any help is appreciated. Thanks. -
datefield not showing a default value
I tried using a DateField and show a default value, but it does not show on the page (but in the HTML): class foo(models.Model): date = models.DateField() class FooForm(ModelForm): class Meta: model = Foo fields = "__all__" widgets = {"date": DateInput(format=("%d-%m-%Y"), attrs={"class": "form-control", "value": timezone.now().strftime("%d-%m-%Y"), "type": "date"}),} this produces: <input type="date" name="date" value="29-02-2024" class="input" prod_date="input" required="" id="id_date"> which shows as: But not with the current date as placeholder. -
Django Admin: How to Override Add Form to Choose Existing Object Instead of Raising 'Already Exists' Error?
I am working with Django and using the Django admin panel for managing a model called Keyword. When adding a new instance of the Keyword model, I want to customize the behavior so that if the keyword already exists, the admin form should select the existing keyword instead of raising the 'Already Exists' error. When i try to add keyword that already exists it wont let me so i have to scroll thru hundreds of keywords to find the one i need like this I have attempted various approaches, including custom forms and overriding the save_model method in the admin class, but the issue persists. The current implementation still raises a "Keyword with this Name already exists" error. -
How to edit apps platform files on digital ocean?
I used nano editor on the app's console to access and edit my Django files but the thing is in the console the file is showing edited but my live site code isn’t updating. here are the images nano command console html file The actual web app file which wasn't updating I am expecting that the code I changed in the console will update on the digital ocean server. -
On click function is not working in script though models and views are ok and original template is working perfectly
In product_detail.html: {% extends 'partials/base.html'%} {%load static%} {% block content %} <style> /* Basic Styling */ html, body { height: 100%; width: 100%; margin: 0; font-family: 'Roboto', sans-serif; } .containerbox { max-width: 1200px; margin: 0 auto; padding: 15px; display: flex; } /* Columns */ .left-column { width: 65%; position: relative; } .right-column { width: 35%; margin-top: 60px; } /* Left Column */ .left-column img { width: 70%; position: absolute; left: 0; top: 0; opacity: 0; transition: all 0.3s ease; } .left-column img.active { opacity: 1; } /* Right Column */ /* Product Description */ .product-description { border-bottom: 1px solid #E1E8EE; margin-bottom: 20px; } .product-description span { font-size: 12px; color: #358ED7; letter-spacing: 1px; text-transform: uppercase; text-decoration: none; } .product-description h1 { font-weight: 300; font-size: 52px; color: #43484D; letter-spacing: -2px; } .product-description p { font-size: 16px; font-weight: 300; color: #86939E; line-height: 24px; } /* Product Configuration */ .product-color span, .cable-config span { font-size: 14px; font-weight: 400; color: #86939E; margin-bottom: 20px; display: inline-block; } /* Product Color */ .product-color { margin-bottom: 30px; } .color-choose div { display: inline-block; } .color-choose input[type="radio"] { display: none; } .color-choose input[type="radio"] + label span { display: inline-block; width: 40px; height: 40px; margin: -1px 4px 0 0; vertical-align: … -
why is this error coming after trying to deploy a django app on vercel?
After trying to deploy a django app on vercel, this error comes Running build in Washington, D.C., USA (East) – iad1 Cloning github.com/Anupam-Roy16/Web_project (Branch: main, Commit: 90df2f4) Cloning completed: 677.995ms Previous build cache not available Running "vercel build" Vercel CLI 33.5.3 WARN! Due to builds existing in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings Installing required dependencies... Failed to run "pip3.9 install --disable-pip-version-check --target . --upgrade -r /vercel/path0/requirements.txt" Error: Command failed: pip3.9 install --disable-pip-version-check --target . --upgrade -r /vercel/path0/requirements.txt ERROR: Ignored the following versions that require a different python version: 5.0 Requires-Python >=3.10; 5.0.1 Requires-Python >=3.10; 5.0.2 Requires-Python >=3.10; 5.0a1 Requires-Python >=3.10; 5.0b1 Requires-Python >=3.10; 5.0rc1 Requires-Python >=3.10 ERROR: Could not find a version that satisfies the requirement Django==5.0.2 (from versions: 1.1.3, 1.1.4, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.2.7, 1.3, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.4, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 1.4.14, 1.4.15, 1.4.16, 1.4.17, 1.4.18, 1.4.19, 1.4.20, 1.4.21, 1.4.22, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.5.11, 1.5.12, 1.6, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.8, 1.6.9, 1.6.10, 1.6.11, 1.7, … -
How can I use get_or_create in TranslatableModel?
I am using dajngo-parler to make my site multi-language. But I have a problem when querying. For example, in this query, only ID is created and the rest of the fields are not stored in the database. MyModel.objects.language('en').get_or_create(title='test',description='test') But when I use this method, there is no problem. MyModel.objects.language('en').create(title='test',description='test') Is there another way to create data in multi-language models with parler??