Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
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? -
How to display card picture to the right side of the text?
I've started writing my first website project using django (recipe storage website). I've imported a template for the whole project and it came with its own stylesheet and other bits and bobs. Now, I am writing a page where I want to display all the recipes that are in the database. For that, I also borrowed a recipe display card template (it came with its own HTML and CSS). So, I looked up how to merge them and for the most part it works and displays properly. However, whatever I do, for the life of me I can't seem to make the image of the card to display to the right of the text (within the card), even though I've pasted my stylesheet and the cards style and HTML into jsfiddle.net and it displays perfectly. It only ever displays below the text. I assume it's not a conflict with my existing stylesheet, because none of the class names in the imported card stylesheet are the same as ones in my existing one, but I've been banging my head at this problem for like 8 hours now, and I can't seem to get it to work. I feel like I am … -
How to convert calculated properties (that involve calling other methods) into Django generated fields?
Let's say I have this following model: class Product(models.Model): price = models.DecimalField( max_digits=19, decimal_places=4, validators=[MinValueValidator(0)], blank=False, null=False, ) expiry_date = models.DateTimeField( blank=True, null=True, ) @property def price_in_cents(self): return round(self.price * 100) @property def has_expired(self): if self.expiry_date: return date.today() > self.expiry_date.date() else: return False So two fields, and two other properties that rely on these two fields to generate an output. I'm trying to convert these fields into generated fields (for Django 5). My first understanding was simply just putting in the property function in the expression, so something like this: class Product(models.Model): price = models.DecimalField( max_digits=19, decimal_places=4, validators=[MinValueValidator(0)], blank=False, null=False, ) price_in_cents = models.GeneratedField( expression=round(F("price") * 100), output_field=models.BigIntegerField(), db_persist=True, ) expiry_date = models.DateTimeField( blank=True, null=True, ) @property def has_expired(self): if self.expiry_date: return date.today() > self.expiry_date.date() else: return False Unfortunately, this does not seem to work, and I get the following error: TypeError: type CombinedExpression doesn't define round method Going by this, I assume I won't be able to simply convert the second property either. So how would this actually work? Is there a resource to help me convert these Python functions (properties) into valid expressions? -
Apache mod_wsgi macOS Error: Cannot load mod_wsgi.so - Library not loaded: @rpath/libpython3.9.dylib
I'm setting up a Django project with Apache and mod_wsgi on macOS using Homebrew. When I restart the Apache server, I encounter the following error: httpd: Syntax error on line 67 of /usr/local/etc/httpd/httpd.conf: Cannot load /usr/local/lib/httpd/modules/mod_wsgi.so into server: dlopen(/usr/local/lib/httpd/modules/mod_wsgi.so, 0x000A): Library not loaded: @rpath/libpython3.9.dylib Referenced from: /usr/local/Cellar/httpd/2.4.58/lib/httpd/modules/mod_wsgi.so Reason: no LC_RPATH's found context: Installed Apache using Homebrew. Installed mod_wsgi using pip. Apache configuration file (httpd.conf) includes the following block: <VirtualHost *:8080> ServerName webmaster@localhost DocumentRoot /var/www/html Alias /static /Users/abbasahmed/Desktop/AWD/topic9/bioweb/static <Directory /Users/abbasahmed/Desktop/AWD/topic9/bioweb/static> Require all granted </Directory> <Directory /Users/abbasahmed/Desktop/AWD/topic9/bioweb/bioweb> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess bioweb python-path=/Users/abbasahmed/Desktop/AWD/topic9/bioweb python-home=/Users/abbasahmed/Desktop/AWD/topic9/envs/bioweb_install WSGIProcessGroup bioweb WSGIScriptAlias / /Users/abbasahmed/Desktop/AWD/topic9/bioweb/bioweb/wsgi.py </VirtualHost> I also include this with the other module loading code in the config file LoadModule wsgi_module /usr/local/lib/httpd/modules/mod_wsgi.so I'm facing an issue with Apache and mod_wsgi on macOS. The error suggests a problem with the library path (@rpath/libpython3.9.dylib). How can I resolve this issue and successfully load mod_wsgi.so into the Apache server? I uninstalled and installed mod_wsgi with the correct python version but I still get an error -
Setting up pytest django database
I need to run this SQL after the test database is created but before creating any tables: `CREATE EXTENSION pg_trgm; CREATE EXTENSION btree_gin; I know that I can somehow use django_db_setup fixture to do this but I can't figure out how. I use addopts = --no-migrations in my pytest.ini file so this can't be done using migrations It should be something like this: @pytest.fixture(scope='session') def django_db_setup(): # Some code to create database with connection.cursor() as cursor: cursor.execute('CREATE EXTENSION IF NOT EXISTS pg_trgm;') cursor.execute('CREATE EXTENSION IF NOT EXISTS btree_gin;') # Code for creating tables -
AJAX call to Django View returns None
I trying to get data which I send with AJAX base.html <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script> function getAjaxResponse() { console.log('myAjax'); $.getJSON('/ajax', { get_param: 'data' }, function(data) { $.each(data, function(key, val) { console.log(key); console.log(val); }); }); } $(function(){ $("input[name='barcode']").change(function() { var barcode = document.getElementById("id_barcode").value; $.ajax({ type:'GET', url:`ajax/?variable=${barcode}`, headers: {'X-CSRFToken': '{{ csrf_token }}'}, success: function(response){ console.log('success'); console.log(barcode); setTimeout(getAjaxResponse, 3000); }, error: function (response){ console.log('error'); } }); }); }); </script> urls.py path('ajax/', views.ajaxBarcode, name='ajaxBarcode'), views.py def ajaxBarcode(request): barcode = request.GET.get('variable') dict = {} if len(str(barcode)): dict['hint1'] = str(barcode) return JsonResponse(dict) When I retrieve data in browser I always had hint1 and None. But when I type in address line /ajax/?variable=115 I have response {"hint1": "115"} -
How to create a form that updates multiple field for multiple user simultaneously in Django?
I want to create a form that able to take multiple respond and update the database for multiple instances. Here is my case: I have 2 models, Members and Cash class Members(models.Model): nim = models.IntegerField(default=0) name = models.CharField(max_length=40) position = models.CharField( max_length=30, choices=POSITION_OPTION, ) year = models.IntegerField() program = models.CharField(max_length=30) potrait = models.CharField(max_length=100, default='NO PHOTO') class Cash(models.Model): name = models.ForeignKey(Members, on_delete=models.CASCADE) jan = models.BooleanField(default=False) feb = models.BooleanField(default=False) mar = models.BooleanField(default=False) apr = models.BooleanField(default=False) may = models.BooleanField(default=False) jun = models.BooleanField(default=False) jul = models.BooleanField(default=False) aug = models.BooleanField(default=False) sep = models.BooleanField(default=False) The logic behind this model is, each Member has their record of Cash. So my end goal is to sum the number of True in each Member and determine how much cash they have deposited to the organization. Back to the topic, I want to create a form page that is formed like tables, NIM January February So on... 010456 [ ] (checkbox) [ ] (checkbox) So on... ----------- --------------------------- --------------------------- ------------------ 010457 [ ] (checkbox) [ ] (checkbox) So on... <button>UPDATE RECORD</button> But I'm stuck at figuring out how to connect this multiple form to multiple user at once. The alternative way I can achieve my end goal is to create … -
Test (selenium) Google Oauth login on my Django website
On our login screen we have a Google login. But when I try to test it with Selenium I get an error at Google saying: "device_id and device_name are required for private IP: http://..../accounts/google/login/callback/" Error 400: invalid_request. Now I have (I think) 2 options: Make it so the request is valid. Check the request we send to Google to see if it is valid Oauth and fake a response that back. But I have no idea how to do them and which one is better then the other one. The request we send to google has this payload: "client_id": "redirect_uri": "scope": "response_type": "state": "access_type": <!--begin::Google link--> <a href="{% provider_login_url "google" %}" class="btn btn-flex flex-center btn-light btn-lg w-100 mb-5"> <img alt="Logo" width="28" height="28" src="{% manifest "media/svg/brand-logos/google-icon.svg" %}" class="h-20px me-3" /> {% trans "Continue with Google" %} </a> <!--end::Google link--> When I tried clicking in the Selenium browser on the google I Expected for it to show the normal google login. Instead of the normal google login I got an error. -
Page not found (404) No Profile matches the given query. using django multi tenants
I am encountering a 404 error with the message "No Profile matches the given query" when trying to access the crm_details view with profile IDs higher than 4 in a multi-tenancy Django application views.py def crm_details(request, profile_id): if request.user.is_authenticated: tenant = Tenant.objects.get(schema_name=request.tenant) # Fetch the current tenant profile = get_object_or_404(Profile, id=profile_id, tenant=tenant) # Filter by tenant crm_instance = crm.objects.filter(person_detail=profile, tenant=tenant).first() # Filter by tenant properties = AddProperty.objects.filter(tenant=tenant) if request.method == 'POST': form = crmForm(request.POST, instance=crm_instance) if form.is_valid(): crm_entry = form.save(commit=False) crm_entry.person_detail = profile crm_entry.save() else: form = crmForm(instance=crm_instance) context = { 'profile': profile, 'crm_form': form, 'properties': properties } return render(request, 'crm_details.html', context) return redirect("blog:user_login") def create_profile(request): if request.user.is_authenticated: tenant = Tenant.objects.get(schema_name=request.tenant) # Fetch the current tenant if request.method == 'POST': form = ProfileForm(request.POST) if form.is_valid(): profile = form.save(commit=False) profile.tenant = tenant # Associate the profile with the current tenant profile.save() return redirect('blog:profile_list') else: form = ProfileForm() return render(request, 'create_profile.html', {'form': form}) return redirect("blog:user_login") def add_property(request): if request.user.is_authenticated: tenant = Tenant.objects.get(schema_name=request.tenant) # Fetch the current tenant if request.method == 'POST': form = AddPropertyForm(request.POST, request.FILES) if form.is_valid(): property_instance = form.save(commit=False) property_instance.tenant = tenant # Associate the property with the current tenant property_instance.created_by = request.user property_instance.save() return redirect('blog:property_list') else: form = AddPropertyForm() else: … -
how to make a Clickmap on a Django application?
`Hello! I'm building an application with django and I need to make a clickmap/heatmap to get some statistics from my site. My problem: almost all the forms are out of date and I don't want to use Google Analytics or anything like that. I need a visual map that shows me where users are clicking, the most accessed pages, etc. Things i tried: https://django-analytical.readthedocs.io/en/latest/ clickmap.js https://learn.microsoft.com/en-us/clarity/setup-and-installation/clarity-setup` -
I cant add Products to admin
Im having some errors updating products in my Django adminthe error that shows up whenever I try to add a new product it keeps telling me to return to my django root file and make some changes{Error that comes up} I was expecting a successful operation that says product added successfully OperationalError at /admin/products/product/add/ no such table: main.auth_user__old Request Method: POST Request URL: http://127.0.0.1:8000/admin/products/product/add/ Django Version: 2.1 Exception Type: OperationalError Exception Value: no such table: main.auth_user__old Exception Location: C:\Python\Python37\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 296 Python Executable: C:\Python\Python37\python.exe Python Version: 3.7.4 Python Path: ['C:\Users\Admin\Desktop\Afresh', 'C:\Python\Python37\python37.zip', 'C:\Python\Python37\DLLs', 'C:\Python\Python37\lib', 'C:\Python\Python37', 'C:\Python\Python37\lib\site-packages'] Server time: Thu, 25 Jan 2024 11:31:08 +0000