Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Rendering HTML files ISSUE
This might be something simple, but this is an error I've never faced before. Instead of rendering the template normally, Im getting plain HTML Code... Just like a Plain Text File, without a single error, it just suddenly started showing plain HTML text. Not getting a single error message... -
I get data of last form in django when I am using pagination
views.py def quiz (request): questions = Question.objects.order_by("?")[0:101] paginator = Paginator(questions , 1) page_number = request.GET.get("page") page_obj = paginator.get_page(page_number) if request.method == "POST" : user_timer = request.POST.get("timer") total=len(questions) score=0 wrong=0 correct=0 for q in questions : user_answer = request.POST.get(str(q.pk)) if user_answer : print(user_answer) if q.answer == user_answer : score += 5 correct += 1 else : wrong += 1 score += 0 percent = correct / total * 100 profile = Profile.objects.get(user=request.user) profile.score += score # type: ignore profile.save() context={'score':score , 'wrong':wrong, 'correct':correct,'percent' : percent, 'timer':user_timer , 'total' : total} return render(request, "quizApp/result.html", context) return render(request, "quizApp/quiz.html", {"paginator":paginator , "page_obj":page_obj, "questions":questions}) How I get marge two forms in pagination ? I want get answers of form has pagination but I get data of last form in pagination. How can I do this ? -
Plotting a bar graph in django using matplotlib
I want a bar graph of expense vs date in my django webapp using matplotlib. There can be multiple entries of expense for a single date. The html page shows 'barcontainer object of 2 artists' . How to solve this question. -
django app localhost refused to connect docker
I'm trying to setup my django project with docker. It will have multiple containers one is for code that is server, worker for celery, redis for redis, db for postgres and there is nginx. Every one of them are running without any error but the localhost:8080 is not accessible. I tried accessing localhost:8000 directly and it is still not accessible. Here's all the relevant configuration files of docker. the docker-compose.yml is as: version: '2' services: nginx: restart: always image: nginx:1.23-alpine ports: - 8080:8080 volumes: - /default.conf://etc/nginx/conf.d - static_volume:/app/django_static server: restart: unless-stopped build: context: . dockerfile: Dockerfile entrypoint: /app/server-entrypoint.sh volumes: - static_volume:/app/django_static expose: - 8000 environment: DEBUG: "True" CELERY_BROKER_URL: "redis://redis:6379/0" CELERY_RESULT_BACKEND: "redis://redis:6379/0" DJANGO_DB: postgresql POSTGRES_HOST: db POSTGRES_NAME: postgres POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_PORT: 5432 worker: restart: unless-stopped build: context: . dockerfile: Dockerfile entrypoint: /app/worker-entrypoint.sh volumes: - static_volume:/app/django_static environment: DEBUG: "True" CELERY_BROKER_URL: "redis://redis:6379/0" CELERY_RESULT_BACKEND: "redis://redis:6379/0" DJANGO_DB: postgresql POSTGRES_HOST: db POSTGRES_NAME: postgres POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_PORT: 5432 depends_on: - server - redis redis: restart: unless-stopped image: redis:7.0.5-alpine expose: - 6379 db: image: postgres:13.0-alpine restart: unless-stopped volumes: - postgres_data:/var/lib/postgresql/data/ environment: POSTGRES_DB: postgres POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres expose: - 5432 volumes: static_volume: {} postgres_data: {}version: '2' services: nginx: restart: always image: nginx:1.23-alpine ports: - … -
DO Spaces on Django Cookiecutter Docker - AWS Connection Issue
I am trying to run DO Spaces on a Django/Docker. (setup via Django-Cookiecutter.) I know all this data is good. DJANGO_AWS_ACCESS_KEY_ID='DO00CBN....BATCXAE' DJANGO_AWS_SECRET_ACCESS_KEY='vkmMV3Eluv8.....U1nvalkSFugkg' DJANGO_AWS_STORAGE_BUCKET_NAME='my-key' DJANGO_AWS_DEFAULT_ACL = 'public-read' DJANGO_AWS_S3_REGION_NAME = 'sgp1' DJANGO_AWS_S3_CUSTOM_DOMAIN = 'https://my-key.sgp1.digitaloceanspaces.com' in production.py AWS_ACCESS_KEY_ID = env("DJANGO_AWS_ACCESS_KEY_ID") AWS_SECRET_ACCESS_KEY = env("DJANGO_AWS_SECRET_ACCESS_KEY") AWS_STORAGE_BUCKET_NAME = env("DJANGO_AWS_STORAGE_BUCKET_NAME") AWS_QUERYSTRING_AUTH = False _AWS_EXPIRY = 60 * 60 * 24 * 7 AWS_S3_OBJECT_PARAMETERS = { "CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate", } AWS_S3_MAX_MEMORY_SIZE = env.int( "DJANGO_AWS_S3_MAX_MEMORY_SIZE", default=100_000_000, # 100MB) AWS_S3_REGION_NAME = env("DJANGO_AWS_S3_REGION_NAME", default=None) AWS_S3_CUSTOM_DOMAIN = env("DJANGO_AWS_S3_CUSTOM_DOMAIN", default=None) # aws_s3_domain = AWS_S3_CUSTOM_DOMAIN or f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com" aws_s3_domain = AWS_S3_CUSTOM_DOMAIN or f"{AWS_STORAGE_BUCKET_NAME}.digitaloceanspaces.com" I chaged the '.s3.amazonaws.com' to '.digitaloceanspaces.com' which gives me 'https://my-zzz.sgp1.digitaloceanspaces.com' But nothing i do or change makes a difference and I always get this error. botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://my-key.s3.sgp1.amazonaws.com/static/sass/project.scss" It seems that the connection is always being overwritten by the '.s3.sgp1.amazonaws.com' What can I do to change this setting which seems to happen in boto? remember this is via Docker. Can it be done via an enviorment in the production.yml? Or in the AWS Dockerfile? Thanks! -
Celery workers do not perform django db update tasks
I am working on a dashboard which requires running long background tasks, and eventually updating a model in database. I am using Celery to perform the background operations Here is my task function in tasks.py @shared_task() def generate_content_async(system_prompt, user_prompt, section_id): data = get_data() # long running operation section = Section.objects.get(id = id) section.data = data section.save() return f"Section with section id: {id} updated" Please note that I am only updating the value of data in Section model. Everything in the code is working fine, and there are no issues, the background task finishes with success, but the database update does not work. What would be the reason for such an issue? TIA I have tried using transactions to perform any database operations after commit, but did not work (this should not be an issue, as there are no ongoing transactions in my case). -
Django - Uploading image through custom models in admin not working
I'm currently working on a Django project, and for this I need to add a way of inputting images to each custom page through the admin panel. However, when I attempt to add this functionality and fill in the form on the admin page, I get shown this: This is what my models.py looks like: from django.db import models from django.urls import reverse # Create your models here. class Bird(models.Model): image = models.ImageField(help_text='Upload Image') breed = models.CharField(max_length=200, help_text='Enter Breed') breed_sub_category = models.CharField(max_length=200, help_text='Enter Breed Subtype') description = models.CharField(max_length=5000, help_text='Enter Description') price = models.FloatField(help_text='Enter Price Here') age_in_years = models.IntegerField(max_length=200, help_text='Enter Age in Years') age_in_months = models.IntegerField(max_length=200, help_text='Enter Age in Months') tame = models.BooleanField(help_text='Is the bird tame?') def get_absolute_url(self): return reverse('model-detail-view', args=[str(self.id)]) def __str__(self): return self.image return self.breed return self.price return self.age_in_years return self.age_in_months return self.breed_sub_category return self.tame return self.description And this is what my admin.py looks like: from django.contrib import admin from .models import Bird # Register your models here. admin.site.register(Bird) -
Django not updating html templates in browser
I set up Django with cookiecutter and am running the project with docker compose. Everything worked fine, however, when I update an .html template file. The change isn’t reflected on the webpage. I made sure that DEBUG = TRUE and refreshed/cleared my browser cache. When I navigate the to the html file through the django sidebar I can see the changes there but not on the actual webpage (see attached screenshot). I confirmed DEBUG =TRUE and cleared my chache/did a hard refresh with now luck. I'm on a windows pc. Thank you in advance. Github Docker compose file. version: '3' volumes: dtj_local_postgres_data: {} dtj_local_postgres_data_backups: {} services: django: &django build: context: . dockerfile: ./compose/local/django/Dockerfile image: dtj_local_django container_name: dtj_local_django depends_on: - postgres - redis - mailpit volumes: - .:/app:z env_file: - ./.envs/.local/.django - ./.envs/.local/.postgres ports: - '8000:8000' command: /start postgres: build: context: . dockerfile: ./compose/production/postgres/Dockerfile image: dtj_production_postgres container_name: dtj_local_postgres volumes: - dtj_local_postgres_data:/var/lib/postgresql/data - dtj_local_postgres_data_backups:/backups env_file: - ./.envs/.local/.postgres docs: image: dtj_local_docs container_name: dtj_local_docs build: context: . dockerfile: ./compose/local/docs/Dockerfile env_file: - ./.envs/.local/.django volumes: - ./docs:/docs:z - ./config:/app/config:z - ./dtj:/app/dtj:z ports: - '9000:9000' command: /start-docs mailpit: image: docker.io/axllent/mailpit:latest container_name: dtj_local_mailpit ports: - "8025:8025" redis: image: docker.io/redis:6 container_name: dtj_local_redis celeryworker: <<: *django image: dtj_local_celeryworker container_name: dtj_local_celeryworker … -
Im trying to deplay a django project on Heroku but I get the following error. /bin/bash: line 1: gunicorn: command not fot found
Log from Heroku 2024-01-25T22:53:03.888631+00:00 app[web.1]: /bin/bash: line 1: gunicorn: command not found 2024-01-25T22:53:03.939373+00:00 heroku[web.1]: Process exited with status 127 2024-01-25T22:53:03.967679+00:00 heroku[web.1]: State changed from starting to crashed 2024-01-25T22:53:03.974999+00:00 heroku[web.1]: State changed from crashed to starting 2024-01-25T22:53:09.010573+00:00 heroku[web.1]: Starting process with command `gunicorn Website.wsgi:application` 2024-01-25T22:53:09.615178+00:00 app[web.1]: /bin/bash: line 1: gunicorn: command not found 2024-01-25T22:53:09.650096+00:00 heroku[web.1]: Process exited with status 127 2024-01-25T22:53:09.670492+00:00 heroku[web.1]: State changed from starting to crashed 2024-01-25T22:53:10.709561+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=uchennasporfolio-e180324e16c1.herokuapp.com request_id=0f77cc0c-29eb-4fbe-a84f-4569840f965d fwd="96.246.176.87" dyno= connect= service= status=503 bytes= protocol=https 2024-01-25T22:53:11.629206+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=uchennasporfolio-e180324e16c1.herokuapp.com request_id=9afb6ed6-0121-4818-8779-752e3d3f7478 fwd="96.246.176.87" dyno= connect= service= status=503 bytes= protocol=https Pipfile [[source]] url = "https://pypi.org/simple" verify_ssl = true name = "pypi" [packages] django = "==5.0.1" django-cors-headers = "==4.3.1" djoser = "==2.2.2" djangorestframework = "==3.14.0" requests = "==2.31.0" django-heroku = "==0.3.1" asgiref = "==3.7.2" certifi = "==2023.11.17" cffi = "==1.16.0" charset-normalizer = "==3.3.2" cryptography = "==42.0.0" defusedxml = "==0.8.0rc2" dj-database-url = "==2.1.0" django-templated-mail = "==1.1.1" djangorestframework-simplejwt = "==5.3.1" idna = "==3.6" oauthlib = "==3.2.2" packaging = "==23.2" psycopg2 = "==2.9.9" pycparser = "==2.21" pyjwt = "==2.8.0" python3-openid = "==3.2.0" pytz = "==2023.3.post1" requests-oauthlib = "==1.3.1" social-auth-app-django = "==5.4.0" social-auth-core = "==4.5.1" sqlparse = "==0.4.4" typing-extensions = "==4.9.0" tzdata = "==2023.4" … -
How do you use short-term AWS credentials with django-storages?
I want to migrate away from using long-term access keys to further harden my security. I am seeking to implement short term security credentials for the AWS services I am using, such as S3. Specifically, I have an IAM user which can assume a role which gives it access to S3. This role is only assumed for a limited amount of time before it expires and then needs to be reassumed. I am wondering if anyone has successfully implemented this pattern using django-storages, and if they can provide advice? It seems like there is support for a config called AWS_SESSION_TOKEN here but there is no documentation for it. Additionally, there is a config called AWS_S3_SESSION_PROFILE, but I can't tell if this is related to what I'm trying to do. -
Cant define another class
WARNINGS: products.Product: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'. HINT: Configure the DEFAULT_AUTO_FIELD setting or the ProductsConfig.default_auto_field attribu te to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'. products.offer: (models.W042) Auto-created primary key used when not defining a primary key type, by de fault 'django.db.models.AutoField'. HINT: Configure the DEFAULT_AUTO_FIELD setting or the ProductsConfig.default_auto_field attribu te to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'. System check identified 3 issues (0 silenced). i tried adding a new class to tha admin page And was expecting it to operate with zero issue and load the offer class -
Django tutorial project
I am new to Django and I am doing a Django tutorial project to create a portfolio. When I first started doing the project, my Django project was able to run the browser correctly and display "Hello World". However, after adding new lines of code to my project, I still only see "Hello World" which is my first project run. How can I fix this issue on VSC to show the result of my new line of code? I'm not sure what the issue is. I tried running "python manage.py runserver" or "python manage.py migrate" but, it still only shows "Hello World". With the code I added from the tutorial, I was supposed to see a display of "first project", "second project", and "third project". -
Advice on Selling My Project: What Steps Should I Take?
Subject: Seeking Guidance on Selling My Django E-commerce Website Code Body: Greetings, Over the past four months, I've dedicated significant effort to developing an e-commerce website using Django. The project is now around 90% complete, and I am contemplating selling the code. As a developer with limited experience in this domain, I am reaching out to seek advice on how to proceed. At the moment, I haven't explored any avenues for selling the code. Are there specialized platforms or websites where I can list and potentially sell my Django e-commerce website code? I should mention that I lack experience in hosting as well. I would greatly appreciate any guidance, recommendations, or insights from those with experience in selling code or utilizing platforms for such transactions. Thank you for your time and assistance. Best regards. -
Deploying Django Application to Railway. Error with requirements.txt
I am trying to deploy a simple django application to Railway, but keep running into this issue. 5.606 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.0a1 Requires-Python >=3.10; 5.0b1 Requires-Python >=3.10; 5.0rc1 Requires-Python >=3.10 5.606 ERROR: Could not find a version that satisfies the requirement Django==5.0 (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 ... 4.2.9) 5.606 ERROR: No matching distribution found for Django==5.0 ... ERROR: failed to solve: process "/bin/bash -ol pipefail -c python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt" did not complete successfully: exit code: 1 Error: Docker build failed My requirements.txt file is: asgiref==3.7.2 crispy-bootstrap4==2023.1 Django==5.0 django-crispy-forms==2.1 gunicorn==21.2.0 packaging==23.2 Pillow==10.1.0 pytz==2023.3.post1 sqlparse==0.4.4 My Procfile is: web: gunicorn 'django_net.wsgi' --log-file - my runtime.txt file is: python-3.12.1 I am very new to deploying so I have no idea what I'm doing wrong here. Any help would be appreciated. I am very new to deploying so I have no idea what I'm doing wrong here. Any help would be appreciated. -
I'm looking for a Frappe Gantt equivalent to apply in my Django project
I'm sorry in advance if I could not phrase my issue right, I'm currently new to Django and developing a project. I was looking for an interactive drag and drop Gantt chart solution for my project. I stumbled on Frappe Gantt chart and found it perfect for my requirements. However, I understand that I can't really apply it in Django. Is there a way to apply? an alternative? I have looked around and found some solutions, but none of them were compatible as frappe. Moreover, there's not much around that are open source with appropriate license. I thought about creating the chart from scratch, but I'm not sure where to start. -
Django cannot connect to Postgres in dev container
I hope you can assist me. I have a Django application that should use a Postgres database and use a dev container approach to do this. I have written a "wait_for_db" command (django-devcontainers/core/management/commands/wait_for_db.py) to wait until the database becomes available and then connects to the database. When I test this using python manager.py wait_for_db This works fine displaying "Database available" when a connection is successfully made. And the database name is "devdb" However, if I run the following after the above command python manager.py runserver I see an error django.db.utils.OperationalError: connection to server at "postgresdb" (172.20.0.2), port 5432 failed: FATAL: database "devdb" does not exist Even though the "wait_for_db" command confirmed it exists My GitHub repo is here if anyone could take a look and tell me where I am going wrong My attempt to implement Postgres in Django -
Django_seed Seeding Process Inserting Excessive Data and Causing Database Overflow
I'm encountering an issue with the seeding process in my Django application using the django_seed library. I've configured the seed data for my TipoSuscripcion model following the documentation and examples provided. However, when I execute the seeding process, it inserts an excessive amount of data into the database, filling it with unwanted records. Here's a summary of the problem and my setup: Utilizing the django_seed library for data seeding. Defined seed data for the TipoSuscripcion model in a separate seed script (seeds.py). Running the seeding process via the python manage.py seed app command. this is my code from django_seed import Seed from app.models import TipoSuscripcion def seed_data(): seeder = Seed.seeder() tipo_suscripcion_data = [Private] seeder.add_entity(TipoSuscripcion, tipo_suscripcion_data, custom_fields={'activo': True}) # Assuming 'activo' is a boolean field # Execute the seeding seeder.execute() if __name__ == '__main__': seed_data() This si the file tree drwxr-xr-x - emilioramirezmscarua 25 Jan 10:13. app .rw-r--r-- 131k emilioramirezmscarua 23 Jan 13:16 db.sqlite3 .rwxr-xr-x 686 emilioramirezmscarua 23 Jan 13:16 manage.py .rw-r--r-- 5.9k emilioramirezmscarua 25 Jan 10:13 README .md.rw-r--r-- 45 emilioramirezmscarua 23 Jan 13:16 requirements .txtdrwxr-xr-x - emilioramirezmscarua 25 Jan 11:44 seeds .rw-r--r-- 5.7k emilioramirezmscarua 25 Jan 11:40 └── seeds .pydrwxr-xr-x - emilioramirezmscarua 24 Jan 11:28 sistema_control_de_inventarios drwxr-xr-x - emilioramirezmscarua 23 … -
how do I curve an In image from one side in a div?
I am making a webpage and for the homepage I want a blue image as the header. I want the picture to have a curved border from only the bottom right corner. How do I do it? <div class="carousel-inner"> <img src="/static/Home.png" class="img-fluid" alt="..."> </div> I don't know how to apply the border only on one corner. -
In Django, when I compare two html texts, how to remove the blank lines with the aim of making the comparison positive despite the blank lines?
I'm comparing two texts with Django. Precisely i am comparing two HTML codes using Json: user_input.html and source_compare.html. These two html files are compared with the def function_comparison function in views.py. PROBLEM: The comparison happens correctly, but the problem is that if there is a space between the lines (1 or even more lines), then I get the preconfigured message "No, it is not the same!". WHAT WOULD I WANT: I would like the comparison to be correct (so I get the message "Yes, it is the same!") if there are empty lines (1 or even more lines). EXAMPLE: I'll show you an example. I would like the comparison to be the same, if for example I have this html in the two files (note the spaces between the lines in user_input.html): In source_compare.html: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1 class="heading">This is a Heading</h1> <p>This is a paragraph.</p> </body> </html> And instead the user in user_input.html writes: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1 class="heading">This is a Heading</h1> <p>This is a paragraph.</p> </body> </html> Here is the code. The app also needs highlight.js (serves the purpose of text color, but also aligns lines) and my … -
Django m2m signal not saving data on DB
I am trying to use m2m signals to copy some data from a M2M field to another if a conditional is met. From logs I can see that the signal works as expected but when I query the DB I do not see any data - while I would expect to see the same as I see in the logs. models.py class NatObjectLocal(PrimaryModel): """NAT Object Local model implementation.""" nat_type = models.CharField(max_length=200, choices=NatTypes, verbose_name="Local NAT") real_ip = models.ManyToManyField( to="ipam.IPAddress", related_name="real_ips_local", ) local_routable_ip = models.ManyToManyField( to="ipam.IPAddress", related_name="routable_ips_local", ) @receiver(m2m_changed, sender=NatObjectLocal.real_ip.through) def copy_real_ip(sender, instance, action, **kwargs): if action == "post_add": if instance.nat_type == NatTypes.ECN: instance.local_routable_ip.clear() real_ips = instance.real_ip.all() print(f"real_ips: {real_ips}") instance.local_routable_ip.add(*real_ips) instance.save() print(f"instance.local_routable_ip.all(): {instance.local_routable_ip.all()}") debug output real_ips: <IPAddressQuerySet [<IPAddress: 10.0.0.1/32>]> instance.local_routable_ip.all(): <IPAddressQuerySet [<IPAddress: 10.0.0.1/32>]> ORM output In [16]: related_objects = a.real_ip.all() In [17]: related_objects Out[17]: <IPAddressQuerySet [<IPAddress: 10.0.0.1/32>]> In [18]: related_objects_2 = a.local_routable_ip.all() In [19]: related_objects_2 Out[19]: <IPAddressQuerySet []> -
why my response payload not getting parsed properly in django restframework?
I have below code: class MergeCompanyDetails(APIView): @staticmethod def get(_, id=None): api_log(msg="Processing GET request in MergeAccounts...") comp__id_client = Basic(base_url=settings.BASE_URL, token=settings.TOKEN, key=settings.KEY) try: organization_data = comp__id_client.account.info.retrieve(id=id, expand=CompanyInfo.XYZ) print('[organization_data1] :::', organization_data) except Exception as e: api_log( msg=f"Error retrieving organizations details: {str(e)} - Status Code: {status.HTTP_500_INTERNAL_SERVER_ERROR}: {traceback.format_exc()}") return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) # Create the payload dynamically from organization_data formatted_addresses = [ { "type": addr.type, "street_1": addr.street_1, "street_2": addr.street_2, "city": addr.city, "state": addr.state, "country_subdivision": addr.country_subdivision, "country": addr.country, "zip_code": addr.zip_code, "created_at": addr.created_at, "modified_at": addr.modified_at, } for addr in organization_data.addresses ] phone_types = [ { "number": phone.number, "type": phone.type, "created_at": phone.created_at, "modified_at": phone.modified_at, } for phone in organization_data.phone_numbers ] formatted_data = [] for org_tup in organization_data: organization = dict(org_tup[0]) print("@@@@@@@@@@@@@@@@@@@@@@@@@@", organization) formatted_entry = { "id": organization.get("id"), "remote": organization.get("remote"), "addresses": formatted_addresses, "phone_numbers": phone_types, } formatted_data.append(formatted_entry) api_log(msg=f"FORMATTED DATA: {formatted_data} - Status Code: {status.HTTP_200_OK}: {traceback.format_exc()}") return Response(formatted_data, status=status.HTTP_200_OK) when I simply print the organization_data, I get below output in the IDE console id='a5945ed8-932d-4c9d-9090-e8a50c58fbb6' remote_id='3f03913f-d173-4aa9-a7d8-cf8fc0525fa4' addresses=[Address(type=None, street_1='23 Main Street', street_2='Central City', city='Marinevill e', state='', country_subdivision='', country=None, zip_code='12345', created_at=datetime.datetime(2024, 1, 16, 6, 44, 57, 937035, tzinfo=datetime.timezone.utc), modified_at=datetime.datetime(2024, 1, 16, 6, 44, 57, 937052, tzinfo=date time.timezone.utc))] phone_numbers=[AccountingPhoneNumber(number='1234 5678', type='OFFICE', created_at=datetime.datetime(2024, 1, 16, 6, 44, 57, 965582, tzinfo=datetime.timezone.utc), modified_at=datetime.datetime(2024, 1, 16, 6, 44, 57, … -
celery dont do anything after recived a task from rabbitmq
iam running a simpel task to send email to user after ordering somthing in my django app i am using RabbitMQ as broker and i am running it on docker using : docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:management and running celery with celery -A myshop worker -l info i have this in my celery.py beside my setting.py file in main django app : import os from celery import Celery # set the default Django settings module for the 'celery' program. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myshop.settings') app = Celery('myshop') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() and in the init.py file of the main django app : from .celery import app as celery_app __all__ = ['celery_app'] and this is the task in one of my django app from celery import shared_task from django.core.mail import send_mail from .models import Order @shared_task def order_created(order_id): """ Task to send an e-mail notification when an order is successfully created. """ order = Order.objects.get(id=order_id) subject = f'Order nr. {order.id}' message = f'Dear {order.first_name},\n\n' \ f'You have successfully placed an order.' \ f'Your order ID is {order.id}.' mail_sent = send_mail(subject, message, 'email@gmail.com', [order.email]) return mail_sent celery getting the order like this : [2024-01-25 16:12:51,674: INFO/MainProcess] Task orders.task.order_created[679c4592-e5e2-42f4-9f15-b07f9492fce3] received [2024-01-25 … -
Django x Postgres Migrate and Migration error
I get this error anytime i run makemigrations: /home/azeez/bendownselect/venv/lib/python3.12/site-packages/django/core/management/commands/makemigrations.py:160: RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': could not translate host name "postgres" to address: Temporary failure in name resolution and i get this error if i run migrate: django.db.utils.OperationalError: could not translate host name "postgres" to address: Temporary failure in name resolution this is my db config: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': env("POSTGRES_DB"), 'USER': env("POSTGRES_USER"), 'PASSWORD': env("POSTGRES_PASSWORD"), 'HOST': env("POSTGRES_HOST"), 'PORT': env("POSTGRES_PORT"), } } Thank you! -
Python Rest Api GroupDocs
I am trying to convert ppt file into pdf and then save it into a file. I am able to upload to the cloud of GroupDocs, Convert to PDF, but last step, download the file doesnt work. Some errors that gives me are my folder doesnt exist and I cant find PDF downloaded in any place. def generate_and_save_pptx(self): # Ruta del PPTX a modificar pptx_template_path = 'panel/templates/originals/Prueba.pptx' presentation = Presentation(pptx_template_path) # modifico ppt self.modify_presentation(presentation) # Ruta PDF final pdf_filename = f'{self.client.name} - {self.type_submission.name}_tutorial.pdf' pptx_filename = f'{self.client.name} - {self.type_submission.name}_tutorial.pptx' pdf_path = submission_directory_path(self, pdf_filename) my_storage = "FilesToConvert" pdf_cloud_path = f'FilesToConvert/{pdf_filename}' # Usar / en lugar de \ # Crear un archivo temporal para guardar el PPTX with tempfile.NamedTemporaryFile(delete=False, suffix=".pptx") as temp_pptx: temp_pptx_path = temp_pptx.name presentation.save(temp_pptx_path) try: # Crea una instancia de la api file_api = FileApi(Configuration(app_sid, app_key)) # Subir el archivo upload_request = UploadFileRequest(pptx_filename, temp_pptx_path, my_storage) file_api.upload_file(upload_request) except ApiException as e: print(f"Error durante la carga del archivo PPTX: {e}") try: # Crear una instancia de la API convert_api = ConvertApi.from_keys(app_sid, app_key) # Configurar las opciones de conversión convert_settings = ConvertSettings() convert_settings.file_path = pptx_filename # El nombre del archivo subido convert_settings.format = "pdf" convert_settings.output_path = my_storage # Crear la solicitud de conversión del … -
dynamically changing text on a page using CKEditor 5 in django
please tell me, is there a ready-made solution for Ckeditor - 5 to change the contents of the page without going to the admin panel, as well as without refreshing the page? example: in general, you can do this yourself using forms and ajax, for example, but why invent a bicycle if you already have one?