Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Trying to implement Google login on my django-restframework - Vue app but keep getting redirect_uri_mismatch
Title is self explanatory. I have tried every which way to take a crack at this, but kept getting the same error, no matter what I tried for days. Troubleshooting has been difficult due to me not being able to check exactly what redirect_uri string is being passed to the google's endpoint. I figured I would ask here in the hopes that someone else had a similar issue and figured it out. Vue-side: using vue3GoogleLogin main.ts: import vue3GoogleLogin from 'vue3-google-login' ... const clientId = import.meta.env.VITE_VUE_APP_GOOGLE_CLIENT_ID; app.use(vue3GoogleLogin, {clientId: clientId}); SignIn.vue: ... <GoogleLogin :callback="callback"> <button class="btn btn-flex flex-center btn-light btn-lg w-100 mb-5"> <img alt="Logo" :src="getAssetPath('media/svg/brand-logos/google-icon.svg')" class="h-20px me-3" /> Continue with Google </button> </GoogleLogin> ... const callback = (response) => { // This callback will be triggered when the user selects or login to // his Google account from the popup console.log("Handle the response", response); // const googleUser = decodeCredential(response.credential); // console.log(googleUser); const jwtToken = axios.post('http://127.0.0.1:8000/dj-rest-auth/google/',{ code: response.code }); console.log(jwtToken); } return { onSubmitLogin, login, submitButton, getAssetPath, callback }; }, }); </script> console.log(response.code) shows the Authorization code that is returned by google. Django-side: using allauth, dj-rest-auth among others Google settings (client_id, secret) are not present in the settings.py, but rather in the DB. … -
Enter a valid date. at BC/AD field in django framework
Here is the code I'm using: class BCEDateField(models.DateField): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def from_db_value(self, value, expression, connection): if value: if value.endswith('BC'): # Parse the BC date string and convert it to a negative year year, month, day = map(int, value[:-2].split('-')) return models.DateField().from_string(f"{-year:04d}-{month:02d}-{day:02d}") else: # Parse the CE date string directly return models.DateField().from_string(value) return value def to_python(self, value): if isinstance(value, str): if value.endswith('BC'): # Parse the BC date string and convert it to a negative year year, month, day = map(int, value[:-2].split('-')) return models.DateField().from_string(f"{-year:04d}-{month:02d}-{day:02d}") else: # Parse the CE date string directly return models.DateField().from_string(value) return value def get_prep_value(self, value): if value: if value.year <= 0: # Convert the negative year to a BC date string year, month, day = value.year * -1, value.month, value.day return f"{year:04d}-{month:02d}-{day:02d}BC" else: # Convert the CE date to a string return value.strftime("%Y-%m-%d") return value BUT IT SHOWS AN ERROR: Enter a valid date. -
How can i pass build model in deepface library?
I am using face recognition library deepface,and using find method for identify images i need to pass prebuild model to that method but it is not working can any one explain how can i do that? output2 = DeepFace.find(img2,img1_path,model_name=model_name) -
Error in PyCharm: Package requirement 'Django==5.0.7' is not satisfied
I'm trying to set up a Django project in PyCharm, but I keep encountering the following error: Package requirement 'Django==5.0.7' is not satisfied I have already tried the following steps: Ensured that Django==5.0.7 is listed in my requirements.txt file. pip install -r requirements.txt Verified that my virtual environment is activated Despite these efforts, PyCharm still doesn't recognize the installed Django package. Here are some additional details: PyCharm version: 2023.3.2 Python version: 3.10.1 OS: Windows 10 What could be causing this issue, and how can I resolve it? -
Django huey task not giving a result
I have created a task and I want to wait on its completion. However, for some reason I don't get a task result. I only get None. from django_huey import db_task, on_startup, signal, task @task(queue='test_q') def add_numbers(a, b): return a + b res = add_numbers(1, 2) print(res) In the example above, res will be None. Therefore, I can't use res.get(blocking=True) to wait on the task. This is my queue: 'test_q': { 'huey_class': 'huey.RedisHuey', 'immediate': False, 'results': False, 'connection': { 'url': '<>' }, 'consumer': { 'workers': 4, 'worker_type': 'thread', }, } The add_numbers task does get executed in the task. What could be the problem? -
DRF error serializing many to many relation
The error occurs after inserting the DetallePedido record, the serializer is looking for the fields 'producto' and 'cantidad'. And it receives a Producto object and an integer (cantidad) and it is looking for the field 'producto' inside the Producto object, that's why the error occurs. And at the end of the create() function it sends the Pedido object with the empty detalles_pedido attribute which is where the DetallePedido records should be stored. Any idea how to fix it? error: Got AttributeError when attempting to get a value for field producto on serializer DetallesPedidoSerializer. The serializer field might be named incorrectly and not match any attribute or key on the Producto instance. Original exception text was: 'Producto' object has no attribute 'producto'. models.py class Producto(models.Model): nombre = models.CharField(max_length=100, blank=False, default='') precio = models.DecimalField(max_digits=6, decimal_places=2) coste_envio = models.DecimalField(max_digits=6, decimal_places=2) def __str__(self): return self.nombre class Pedido(models.Model): ESTADOS = { 'pendiente': 'Pendiente', 'pagado': 'Pagado', 'enviado': 'Enviado', 'entregado': 'Entregado', } cliente = models.ForeignKey(User, on_delete=models.CASCADE) direccion = models.CharField(max_length=300) fecha_creacion = models.DateTimeField(auto_now_add=True) estado = models.CharField(max_length=10, choices=ESTADOS, default=ESTADOS['pendiente']) detalles_pedido = models.ManyToManyField(Producto, through='DetallePedido') def save(self, *args, **kwargs): super().save(*args, **kwargs) def __str__(self): return f'Pedido {self.id} - {self.cliente}' class DetallePedido(models.Model): pedido = models.ForeignKey(Pedido, on_delete=models.CASCADE) producto = models.ForeignKey(Producto, on_delete=models.CASCADE) cantidad = models.PositiveIntegerField() … -
Django Admin Page - Create a link to list of objects, filtered by foreign key
i am learning Django right now and still struggling with it. I have two models: Database and DatabaseUser, linked with a foreign-key. In the admin page, I want to add a link to the list with databases, that directs me to a list with database-users of that specific database. Python: 3.9; Django: 4.2.13 # models.py class Database(models.Model): datenbank_name = models.CharField(max_length=300) datenbank_art = models.CharField(max_length=100) # ... (omitted some attributes) def __str__(self): return self.datenbank_name class DatabaseUser(models.Model): datenbank = models.ForeignKey(Database, on_delete=models.CASCADE) user_name = models.CharField(max_length=300) # ... (omitted some attributes) def __str__(self): return self.user_name My admin models are looking like this: # admin.py class PasswordInput(forms.ModelForm): passwort = forms.CharField(widget=forms.PasswordInput()) class DatabaseAdmin(admin.ModelAdmin): form = PasswordInput fieldsets = [ ("Allgemein", {"fields": ["datenbank_name", "datenbank_art", "kunde", "host", "port"]}), ("Anmeldeinformationen", {"fields": ["user_name", "passwort"]}), ] list_display = ["datenbank_name", "kunde", "datenbank_art", "port", "erreichbar"] admin.site.register(Database, DatabaseAdmin) class DatabaseUserAdmin(admin.ModelAdmin): form = PasswordInput fieldsets = [ ("Datenbank", {"fields": ["datenbank"]}), ("Anmeldeinformationen", {"fields": ["user_name", "passwort"]}), ("Datenbank-Rechte", {"fields": ["rechte"]}), ] list_filter = ["datenbank"] list_display = ["user_name", "rechte", "datenbank"] admin.site.register(DatabaseUser, DatabaseUserAdmin) Now I have tried couple of things and found 2 very similar questions on Stack Overflow. However i couldn't get them to work in my code. The second one is not creating a link to the list of … -
'AnonymousUser' object has no attribute '_meta' in Login view
with custom AuthenticationForm get error when trying login with a non-existent account but when use existent account error dont raise File "C:\python\CTFp\.venv\Lib\site-packages\django\utils\functional.py", line 253, in inner return func(_wrapped, *args) ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'AnonymousUser' object has no attribute '_meta' forms.py class AuthenticationForm(BaseAuthenticationForm): def clean(self): username = self.cleaned_data.get("username") password = self.cleaned_data.get("password") ogg = User.objects.filter(Q(email=username) or Q(username=username)).first() if ogg is not None and password: self.user_cache = authenticate( self.request, username=ogg.username, password=password ) if self.user_cache is None: raise self.get_invalid_login_error() else: self.confirm_login_allowed(self.user_cache) return self.cleaned_data urls.py urlpatterns = [path('signin', views.LoginView.as_view(authentication_form=forms.AuthenticationForm), {'template_name': 'users/signin.html'}, name='signin'),] models.py class User(AbstractUser): challenges = models.ManyToManyField(Challenge) tried to change auth form to base AuthenticationForm and error dont raises. -
How many vps do i need for angular apps,django and mysql
I have a project that contains web apps and a django backend and mysql db Mydomaine.com Admin.mydomaine.com Mydomaine.com/company/workAndDevis CompanyAdmin.Mydomaine.com All of these are angular apps I'm a little bit confused how many vps to use and how much resource for these vps Some times i say I'll make em all ubuntu server 4vCores with 4G ram. some times 2vCores with 2 G ram. I need help to decide my required resources -
ValueError('JSON string "{0}" is not valid json. {1}'.format(json_str, err)) ValueError: JSON string "{" is not valid json [closed]
I have a serviceAccountKey.json file with the following code { "type": "service_account", "project_id": "...", "private_key_id": "...", "private_key": "-----BEGIN PRIVATE KEY-----...", "client_email": "...", "client_id": "...", "auth_uri": "...", "token_uri": "...", "auth_provider_x509_cert_url": "...", "client_x509_cert_url": "...", "universe_domain": "..." } All this information is, of course, filled in when I downloaded the file from firebase console for my project. I keep getting this error message. \ raise ValueError('JSON string "{0}" is not valid json. {1}'.format(json_str, err)) ValueError: JSON string "{" is not valid json. Expecting property name enclosed in double quotes: line 1 column 2 (char 1) The error seems to be coming from the line json_data = json.loads(json_str) from the init.py file in firebase admin in the "lib" sub directory of my virtual environment. I am using python 3.6. I looked at different solutions online, but none of them answered my question. Thanks for any help. -
Django test database configuration for unittest
I am running unittest with coverage command but having trouble with test database interaction. Here is my code snippet. from django.test import TestCase from myapp.models import Animal class AnimalTestCase(TestCase): def setUp(self): Animal.objects.create(name="lion", sound="roar") Animal.objects.create(name="cat", sound="meow") def test_animals_can_speak(self): """Animals that can speak are correctly identified""" all_animals = Animal.objects.all() print(all_animals) If I run this code and try to print all animals in the database, it only prints the animals in the real database and not print for Animals like lion and cat. I think this might be related to the database configuration I tried to use this configuration in the settings.py. from django.test import override_settings @override_settings(DATABASES={ "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": "db.sqlite3", "TEST": { "ENGINE": "django.db.backends.sqlite3", "NAME": "test.sqlite3", } }, "read_replica": { "ENGINE": "django.db.backends.sqlite3", "NAME": "db.sqlite3", "TEST": { "ENGINE": "django.db.backends.sqlite3", "NAME": "test.sqlite3", } }, }) but this is still not working. My expectation is to interact with test database so based on my code snippet, I want to print lion and cat. -
Create a one-time code and a specific time
I want to generate a random code for user registration on the website And the time to use the random code is 3 minutes my class: class Otp(models.Model): token = models.CharField(max_length=200, null=True) phone_number = models.CharField(max_length=11) code = models.SmallIntegerField() expiration_date = models.DateTimeField(auto_now_add=True) def __str__(self): return self.phone_number my view: class CheckOtpView(View): def get(self, request): form = CheckOtp() return render(request, 'userlogin/verify-phone-number.html', {'register': form}) def post(self, request): token = request.GET.get('token') form = CheckOtp(request.POST) if form.is_valid(): cd = form.cleaned_data if Otp.objects.filter(code=cd['code'], token=token).exists(): otp = Otp.objects.get(token=token) user, is_create = User.objects.get_or_create(phone=otp.phone_number) login(request, user) otp.delete() next_page = request.GET.get('next') if next_page: return redirect(next_page) return redirect('userlogin:welcome') return render(request, 'userlogin/verify-phone-number.html', {'register': form}) my form: class CheckOtp(forms.Form): code = forms.CharField(widget=forms.TextInput(attrs={'class': 'number-email-input'}), validators=[validators.MaxLengthValidator(5), validators.MinLengthValidator(5)]) -
AWS ECS with Django + Python + Alpine produce Segmentation Fault
we are currently having trouble with Alpine Linux, since the Update to Version>=17. It seems that since alpine17 the openssl library in alpine was updated to openssl3. The problem is that we have our Django application, which is built via Dockerfile does not work with alpine>=17 on AWS ECS anymore. We are installing additional dependencies, such as: gcc, build-base, bind-tools, mysql-client, mariadb-dev, postgresql14-client, xmlsec, git, util-linux, curl-dev, openssl, libffi-dev Then we tested different images, e.g. python3.11.9-alpine3.20,python3.11.9-alpine3.18, python3.11.3-alpine3.17, python3.12.4-alpine3.18 etc. It worked with python3.11.3-alpine3.16. The strange thing is: it does actually work if we built and deploy the django application locally via docker-compose and use python3.11.9-alpine3.20 for example. But if we build the containers (nginx, django, worker, beat) via git-ci and deploy them on AWS ECS with Fargate or EC2 as launch types, it gives those errors. The log in the django-container simply states: !!! uWSGI process 35 got Segmentation Fault !!! Then the worker process is terminated. This error arises everytime a connection to django, to nginx or to the loadbalancer is done. Locally we also see the output: 485BA4DBE17F0000:error:0A000126:SSL routines:ssl3_read_n:unexpected eof while reading:ssl/record/rec_layer_s3.c:322: ssl_client: SSL_connect We assume that there might be some incompatibility between the new openssl3, the openssl … -
How to add a template using {% include %} tag, by comparing which user is logged in, on django?
My asset_list html is like this <div class="right"> <div class="search-container"> <input type="text" id="searchInput" placeholder="Search by AssetName..." aria-label="Search"> <button class="add-button" aria-label="Add Asset" id="addUserButton"><i class="fas fa-plus"></i> Add</button> </div> login database is like this , with roles admin and user class UserDetails(models.Model): username = models.CharField(max_length=100, unique=True) password = models.CharField(max_length=100) # Ideally, this should be hashed role = models.CharField(max_length=45) views for asset list def asset_list(request): users = Asset_Table.objects.all() return render(request, 'asset_mng/asset_pro.html', {'users': users}) I have 2 roles Admin and User , when Admin is logged in, I want to show admin side bar and if user is logged in , show user sidebar. {% include 'admin_sidebar.html'%} or {% include 'user_sidebar.html'%} <div class="right"> <div class="search-container"> <input type="text" id="searchInput" placeholder="Search by AssetName..." aria-label="Search"> <button class="add-button" aria-label="Add Asset" id="addUserButton"><i class="fas fa-plus"></i> Add</button> </div> -
Difficulty adding page numbers to printed table using Paged.js without content overflow
I have a table with numerous elements in its , and I'm attempting to add page numbers to each printed page using Paged.js. However, I'm encountering issues where the table content overflows the page or the layout doesn't respect margins properly when using Paged.js. -
Wagtail 5.0 to 5.2
I have a wagtail project and developed in version 5.0. I want to upgrade it to 5.2. But, I'm not fully experienced in Wagtail. I don't know what to do. Please help me. Are there any potential problems or issues in doing so? I never tried. I don't know what to do. -
Vuetify icons not loading properly (Vuetify2 + Django)
I want to embed vuetify into my project, everything is ok with the connection, but the standard vuetify icons are not loading no matter what I do main.js import Vue from 'vue'; import App from './App.vue'; import vuetify from './plugins/vuetify'; import store from './store'; import 'material-design-icons-iconfont/dist/material-design-icons.css' new Vue({ vuetify, store, render: h => h(App) }).$mount('#app'); vuetify.js import Vue from 'vue'; import Vuetify from 'vuetify'; import 'vuetify/dist/vuetify.min.css'; import 'material-design-icons-iconfont/dist/material-design-icons.css' Vue.use(Vuetify); export default new Vuetify({ icons: { iconfont: 'mdi', } }); { "name": "frontend", "version": "0.1.0", "private": true, "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build --dest ../static/vue-build-files/main-builds", "lint": "vue-cli-service lint", "dev": "vue-cli-service build --dest ../static/vue-build-files --mode=development --watch" }, "dependencies": { "@mdi/font": "^7.4.47", "core-js": "^3.8.3", "file-loader": "^6.2.0", "material-design-icons-iconfont": "^6.7.0", "vue": "^2.6.14", "vuetify": "^2.7.2", "vuex": "^4.1.0" }, "devDependencies": { "@babel/core": "^7.12.16", "@babel/eslint-parser": "^7.12.16", "@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-eslint": "~5.0.0", "@vue/cli-service": "~5.0.0", "eslint": "^7.32.0", "eslint-plugin-vue": "^8.0.3", "vue-template-compiler": "^2.6.14" }, "eslintConfig": { "root": true, "env": { "node": true }, "extends": [ "plugin:vue/essential", "eslint:recommended" ], "parserOptions": { "parser": "@babel/eslint-parser" }, "rules": {} }, "browserslist": [ "> 1%", "last 2 versions", "not dead" ] } after build/dev/serve command vue start working but there is no standart vuetify icons (example below), how do i manage this problem? after dev/build command … -
django Add a button that creates a new entry field each time it's clicked
I am creating a Recipe app- currently for my form I have Title, Ingredients and Description as text inputs. However I want the user to be able to individually input the ingredients so I can manipulate the inputted data- for instance I want Carrot | 700 | g to come in as three inputs rather than currently where it comes in as text. So my question a) would be how you can horizontally supply form inputs so I can take the three values together side by side a.k.a Ingredient: Input1(textfield) | Input 2(int) | Input 3(dropdown menu) question b) is how you can allow for the user to add an additional field on a button click. I won't know how many ingredients they want to input so by default I would give maybe 5 rows of input and then when they button press it allows them to input a new row? New to Django so appreciate the help and some direction on where I should be going with this- is the easiest solution to use ArrayFields and Javascript? I am more experienced with Python but can figure it out with Javascript if that is the way to go- Here is … -
How can I troubleshoot Django POST request issues despite correct form handling?
I'm having an issue in Django where when I click save on a form, it sends a GET request instead of a POST. I'm not sure why this is happening. Hola, estoy con un problema en django, que cuando apretó guardar en un formulario se envía un GET en lugar de un POST, no entiendo bien por que pasa. subir_noticia.html `{% extends "homepage/base.html" %} {% block title %}Estacion Obrera{% endblock %} {% block content %} \<!-- Formulario para subir una noticia --\> \<form action="" method="POST" enctype="multipart/form-data"\> {% csrf_token %} {{ form.as_p }} \<input type="submit" value="Guardar" class="btn btn-dark"\> \</form\> {% endblock %}` view.py ` def crear_noticia(request): if request.method == 'POST': form = NoticiaForm(request.POST, request.FILES) if form.is_valid(): form.save() return redirect('ver_noticias_pendietes.html') else: form = NoticiaForm() return render(request, 'administrar_noticias/subir_noticia.html', {'form': form})` terminal `\[15/Jul/2024 23:50:30\] "GET /administrar_noticias/subir_noticia/?busqueda=&csrfmiddlewaretoken=6JWbqf0Dgo1AExf6P27MzAPlXc06iyvFquFaZ4ztBJSsa0Z1qjK1F5BXjV1Wg88A&titulo=Prueba&subtitulo=pruebita&categoria=hjkhk&cuerpo_noticia=asda&pie_de_foto=ada&imagen=WhatsApp+Image+2024-07-08+at+23.23.38+%281%29.jpeg&autor=asda HTTP/1.1" 200 5097 ` urls.py `urlpatterns = \[ path("subir_noticia/", views.crear_noticia, name='subir_noticia'), path("ver_noticias_pendientes/", views.ver_noticias_pendientes, name='ver_noticias_pendientes'), \] ` forms.py `class NoticiaForm(forms.ModelForm): class Meta: model = Noticia fields = \['titulo', 'subtitulo', 'categoria', 'cuerpo_noticia', 'pie_de_foto', 'imagen','autor'\] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs)` models.py `class Noticia(models.Model): ESTADOS = ( ('pendiente', 'Pendiente'), ('publicado', 'Publicado'), ('oculto', 'Oculto'), ) categoria = models.CharField(max_length=50, unique=True) titulo = models.CharField(max_length=255, unique=True) subtitulo = models.CharField(max_length=255) cuerpo_noticia = models.TextField() autor = models.CharField(max_length=255) … -
How can I configure Django to search for the Redis backend on the server instead of localhost?
I am working on updating an old Django 2.2 app, and am running into an issue with the connections between Celery, Django, Docker, and Redis. I am using Docker Compose to build the app, and using Celery to schedule tasks with Redis as a backend. Celery schedules emails to be sent and I am able to receive those emails, so I am pretty sure that Celery is properly connected to Redis. When running django.contrib.auth.login(), I run into an error TypeError: Cannot create property 'status' on string 'ConnectionError at /api/auth/registration/register_pro/ Error 99 connecting to localhost:6379. Cannot assign requested address. The error message prints all the config and environment variables of the Django app, and it shows that everywhere in the app redis_url, result_backend, and broker_url are configured as redis://<NO_USERNAME_HERE>:<REDIS_PASSWORD>@redis:6379. This should be the correct URL since it works for Celery, but it doesn't work for Django, which searches for Redis on localhost. I've searched the entire app for any references to localhost, but there are none. I've tried adding and removing env variables, changing the Django config, running Django in development and production environments, building my own Redis docker image, tweaking redis.conf, and so many other suggested fixes on Stackoverflow, GitHub … -
Activate/deactivate filtering in django based on condition
I have a bool and if it is True, I want to filter in my query by some stuff, if not I don't want to filter. At the moment my solution is this: if my_boolean: objects = Class.objects.filter(argument=valuexyz)... else: objects = Class.objects... My real query is much longer. I just used this for simplification. Now my questions is could I do this inline? Like: objects = Class.objects.filter( if my_boolean: argument=valuexyz; else: no_filtering) Is there a way to do it like this somehow? This would save me quite some redundant lines of code. -
Django app on Heroku: email sending failure using AWS SES non-default region
I have two django projects at Heroku and use AWS SES for emails. Requirements: django 4.2.10, django-ses 3.5.2. Domain project-one.com is verified at aws us-east-1. These are my settings: ADMINS = ( ('John Smith', 'jsmith@gmail.com'), ) # Setup email backend. if DEBUG: EMAIL_PORT = 1025 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' else: EMAIL_BACKEND = 'django_ses.SESBackend' SERVER_EMAIL = "Project One <no-reply@project-one.com>" DEFAULT_FROM_EMAIL = "Project One <no-reply@project-one.com>" ACCOUNT_EMAIL_SUBJECT_PREFIX = 'Project One ' Emails are correctly sent from no-reply@project-one.com. This works. Domain project-two.com is verified at aws eu-west-1. These are my settings: ADMINS = ( ('John Smith', 'jsmith@gmail.com'), ) # Setup email backend. if DEBUG: EMAIL_PORT = 1025 EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' else: EMAIL_BACKEND = 'django_ses.SESBackend' AWS_SES_REGION_NAME = 'eu-west-1' AWS_SES_REGION_ENDPOINT = 'email.eu-west-1.amazonaws.com' SERVER_EMAIL = "Project Two <no-reply@project-two.com>" DEFAULT_FROM_EMAIL = "Project Two <no-reply@project-two.com>" ACCOUNT_EMAIL_SUBJECT_PREFIX = 'Project Two ' This results in application trying to send emails from admin email jsmith@gmail.com and I get: botocore.errorfactory.MessageRejected: An error occurred (MessageRejected) when calling the SendRawEmail operation: Email address is not verified. The following identities failed the check in region EU-WEST-1: jsmith@gmail.com Any idea why defining AWS_SES_REGION_NAME / ENDPOINT in settings results is admin email being used as sender? If I omit specifying the region, sender is no-reply@project-two.com, but that domain is … -
Django Admin updating tabularinline forms
I have a django modeladmin like so: Class PlanInline(admin.TabularInLine): model = Plan form = PlanForm Class SettingsInline(admin.TabularInLine): model = Settings form = SettingsForm Class StoreAdmin(admin.ModelAdmin): form = StoreForm inlines = (PlanInline, SettingsInline,) .... And I need to pass a value from my Plan form field into my settings form field ss this possible to do from the parent admin form or any method? -
Website giving "an error repeatedly occurred" error in both safari and chrome for iPhone
I am at my wits end. I have tested my website on multiple devices and keep getting mixed results. I can't reliably recreate the issue. The website I am trying to diagnose is clawson-honda-staging.herokuapp.com (this is the staging area that is having the same issue as the main website). When I navigate to this website on some iPhones, can't tell you which one in particular since it happens on 15 pro max, 14 pro max, 14, 13, and 11 so far and not every one, I get "an error repeatedly occurred..." error. I have debugged the website by taking the third party plugins off of the website in a staging area and the problem still occurs. I have broken the website down to just the base html with no css or js, I have tried everything. i have debugged on a mac for hours with multiple devices. Some I could recreate the issue over and over again, some I never get the error. I have not been able to find any patterns or issues that would fix anything reliably. I have taken absolute positioning and translate3d out of the entire application and it's still has the error. Please help!!! -
What's the workaround for Django/PostgreSQL GeneratedField error
When defining a GeneratedFieldedField with PostgreSQL, it is not uncommon to encounter the: django.db.utils.ProgrammingError: generation expression is not immutable. This error is mentioned in the docs about PostgreSQL-specific restriction: ...PostgreSQL requires functions and operators referenced in a generated column to be marked as IMMUTABLE. This error occurs with almost all Func() expressions (with a specified database function). For example: age_func = Func("date_of_birth", function="age") age_years = Func(Value("year"), age_func, function="date_part", output_field=...) This will throw the above error ifage_years is used in GeneratedField expression. Another reproducible example is with Concat() function. If used as is, Concat will also raise the same error, but there is a workaround for it (this custom implementation may not be necessary in Django 5.1). If I was defining these functions in sql, I suppose it wouldn't be a problem marking them as IMMUTABLE. My question is, working with only Django, how do we implement IMMUTABLE functions /expressions? I assume there is a way of passing extra arguments/options that will be used to specify whether the database function will be IMMUTABLE, STABLE, VOLATILE, etc., but I have no clue how to specify this. Perhaps we could subclass Func and override some sql-generating method, but again, I don't know whicker …