Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Executing Selenium, Tesseract, and Pandas in a Web App Without Python/Chrome Installed?"
I have a business that downloads and extracts federal tax liens from hundreds of clerk and recorder sites everyday for the last few years I’ve been just running the individual .py scripts from task scheduler. I want to create a product that I can sell as a SASS. I don’t really know what my options are . To be honest my business partner is the code guy I’m the sales guy but I need to understand the process to sell him on this. What are my options, from reading online articles this is what I believe is possible : Create a Python GUI (use figma for look and feel) integrate the figma design with the python code. last create a exe file I can offer to customers 1A. I understand I would have to have the customer install at least chromedriver as the py to exe packs in the needed libraries with the exe. Create a web based dashboard in Django with authentication and isql database. Would this dashboard be able to have features like a button user could click to execute certain python scripts that would complete the python selenium task, export the data to excel and then have … -
Site not available with gunicorn --bind 0.0.0.0:8000 myproject.wsgi
I'm new to deployment, when i do python manage.py runserver 0.0.0.0:8000 i am able to access it on domain and ip with http but when i do gunicorn --bind 0.0.0.0:8000 core.wsgi i tried testing it by running wget http:server_ip:8000 or 127.0.0.1:8000 its just stuck on it Connecting to 127.0.0.1:8000... connected. HTTP request sent, awaiting response... result from sudo ufw status To Action From Nginx Full ALLOW Anywhere 22/tcp ALLOW Anywhere 8000 ALLOW Anywhere Nginx Full (v6) ALLOW Anywhere (v6) 22/tcp (v6) ALLOW Anywhere (v6) 8000 (v6) ALLOW Anywhere (v6) -
Wagtail: How to set InlinePanel Child Label based on model fields?
How can I set the label on the InlinePanel child ("Field 1") to a value based on fields of a model being added? My models: class FormField(AbstractFormField): label = models.CharField( blank=True, verbose_name=_("label"), max_length=255, help_text=_("The label of the form field"), ) field_type = models.CharField( verbose_name="field type", max_length=16, choices=(("section", "Section"),) + FORM_FIELD_CHOICES, ) page = ParentalKey( 'ContactPageBase', on_delete=models.CASCADE, related_name='form_fields', ) And contact form page: class ContactPageBase(WagtailCaptchaEmailForm, BasePage): ... content_panels = AbstractEmailForm.content_panels + [ FieldPanel('contact_intro'), InlinePanel('form_fields', heading=_('Form fields'), label=_("Field")), FieldPanel('thank_you_text') ] I understand the label can be edited like above but that is for the whole set of children in the InlinePanel but I would like to show something like "{FormField.field_type} - {FormField.label}" in the label so it's clear in the overview on the right. How can this be achieved? -
Django - Get a list of the items for which values exist
I have a project in Django. I have 2 modules, QlikApp and QlikAppUserAccess that are related to a ForeignKey. I want to get all the apps that have related 'Qlik AppUser Access' data. How can i do that? class QlikApp(models.Model): id = models.CharField( verbose_name="App ID", primary_key=True, max_length=100, null=False, blank=False, ) application_name = models.CharField( verbose_name="Qlik app name", max_length=100, blank=False, null=False, ) def __str__(self): return f"{self.application_name}" class QlikAppUserAccess(models.Model): app = models.ForeignKey( QlikApp, related_name="qlik_app_user", on_delete=models.PROTECT, null=True, blank=True, ) employee = models.ForeignKey( Employee, related_name="employee_app_access", on_delete=models.PROTECT, null=True, blank=True, ) access_type_dropdown = ( ("ADMIN", "ADMIN"), ("USER", "USER"), ) access_type = models.CharField( verbose_name="Access Type", max_length=30, blank=True, null=True, choices=access_type_dropdown, ) def __str__(self): return f"{self.app.application_name} - {self.employee.employee_user_name} - {self.access_type}" For example: I have 10 apps but only 2 of them have related data and I wanna show inly them. For example: I have 3 apps: app1 app2 app3 I have 2 values in QlikAppUserAccess model. Roni -> related to app1 Avi -> related to app2 So i need to see only app1 and app2. Thanks a lot. -
How to retrieve a constraint name in an existing database
In a migration, I want to remove an index from a table (before adding a new one). I can do that with a RunSQL and a DROP CONSTRAINT constraint_name, but it turns out that the name of the constraint (for the primary key) is not always the same, because it used to be named differently in the past. So I'm looking for a way to retrieve this constraint name, be it with the DJANGO ORM, or with a SQL request, so I can then remove it. -
I made a color model in django by installing and importing colorfield and it is working but when I am clicking in save button the color is not saving
In admin pannel color field screenshot------>color field screenshot when I am clicking save button(image---->save button ) it is not saving the color in the products(model) In my models.py:(app name:"core") from django.db import models from shortuuid.django_fields import ShortUUIDField from django.utils.html import mark_safe from userauths.models import CustomUser from colorfield.fields import ColorField class Color(models.Model): color = ColorField(default='#FF0000') class Meta: verbose_name_plural="colors" user=models.ForeignKey(CustomUser, on_delete=models.SET_NULL ,null=True) cagtegory=models.ForeignKey(Category, on_delete=models.SET_NULL ,null=True,related_name="category") vendor=models.ForeignKey(Vendor, on_delete=models.SET_NULL,null=True) color = ColorField(image_field="image",default=None) title=models.CharField(max_length=100,default="Apple") image=models.ImageField(upload_to=user_directory_path,default="product.jpg") description=models.TextField(null=True, blank=True,default="This is a product") price = models.DecimalField(max_digits=10, decimal_places=2, default=1.99) old_price = models.DecimalField(max_digits=10, decimal_places=2, default=2.99) specifications=models.TextField(null=True, blank=True) # tags=models.ForeignKey(Tags, on_delete=models.SET_NULL ,null=True) product_status=models.CharField(choices=STATUS, max_length=10,default="In_review") status=models.BooleanField(default=True) in_stock=models.BooleanField(default=True) featured=models.BooleanField(default=False) digital=models.BooleanField(default=False) sku=ShortUUIDField(length=10,max_length=100,prefix="sku",alphabet="abcdef") date=models.DateTimeField(auto_now_add=True) updated=models.DateTimeField(null=True,blank=True) class Meta: verbose_name_plural="Products" def product_image(self): return mark_safe('<img src="%s" width="50" height="50"/>'%(self.image.url)) def __str__(self): return self.title def get_percentage(self): new_price=((self.old_price-self.price)/self.old_price)*100 return new_price In admin.py: from django.contrib import admin from core.models import * class ProductAdmin(admin.ModelAdmin): inlines=[ProductImagesAdmin] list_display=['user','title','product_image','price','featured','product_status','color'] class ColorAdmin(admin.ModelAdmin): list_display=['color'] admin.site.register(Product,ProductAdmin) admin.site.register(Color,ColorAdmin) In my code when I am clicking on save button my colors are not saving in the admin pannel other this are working perfectly. I am posting also my problem in a video. I am giving you the link YouTube (my Problem link): https://youtu.be/7CTPBAvJEDY -
Filter dropdown choices based on another fields value: [Django, django-smart-selects]
I want to show only relevant option in first_model_field dropdown based on values of product and product_state. When admin changes values of one of these fields in SecondModel, it should get only first_model_field choices that have same state and product. How can I get filtered FirstModel based on these two values without writing async JavaScript ? It should also change when one of these values changes in dropdown. class FirstModel(models.Model): product = models.ForeignKey("Product", on_delete=models.CASCADE) product_state = models.CharField(default=PRODUCT_STATE_START, choices=PRODUCT_CHOICES) class SecondModel(models.Model): product = models.ForeignKey("Product", on_delete=models.CASCADE) product_state = models.CharField(default=PRODUCT_STATE_START, choices=PRODUCT_CHOICES) first_model_field = ChainedForeignKey( FirstModel, on_delete=models.CASCADE, chained_field="product", chained_model_field="product", ) ps: Currently it only filters based on product field -
im getting an error on post and get method. im using django framework
[26/Feb/2024 13:03:35] "GET /registration/ HTTP/1.1" 200 6389 Method Not Allowed (POST): /registration/ Method Not Allowed: /registration/ [26/Feb/2024 13:03:44] "POST /registration/ HTTP/1.1" 405 0 try to get the user username and password on the database.but it showign error e.g method not allowed -
my serilazer not working , show "'Tag' object is not iterable" , could you help me
i am building my personal blogpost and i am using django rest framework to build my api i have problem with my tag Post_TagSerializer when i access to tag like python it show me error that i motion it the image above this is my code this is my serializer class Post_TagSerializer(serializers.ModelSerializer): tags = TagSerializer(many=True) # Show names of associated tags postlist = PostSerializer(many=True, read_only=True) class Meta: model = Post_Tag fields="__all__" and this is my model from django.db import models # Create your models here. class Tag(models.Model): tName = models.CharField(max_length=100) _created = models.DateField() def __str__(self): return self.tName class Category(models.Model): cName = models.CharField(max_length=50) cDescription = models.CharField(max_length=250) def __str__(self): return self.cName class Post(models.Model): postName = models.CharField(max_length=200) postDescription = models.CharField(max_length=250) category_id = models.ForeignKey(Category, on_delete=models.CASCADE , related_name="postlist") release_date = models.DateField(auto_now_add=True) #tags = models.ManyToManyField(Tag) def __str__(self): return self.postName class Post_Tag(models.Model): postId = models.ForeignKey(Post , on_delete=models.CASCADE ,related_name="postlist") tags = models.ForeignKey(Tag, on_delete=models.CASCADE , related_name='tags') def __str__(self): return str(self.postId) and this is my view class TagPostAV(APIView): def get(self, request, tags): try: # Filter Post_Tag objects based on tags__tName tagpost = Post_Tag.objects.filter(tags__tName=tags) # Check if any results were found if not tagpost.exists(): return Response({'error': 'tag not found'}, status=status.HTTP_404_NOT_FOUND) # Create a serializer instance with many=True for multiple objects serializer … -
MetaApi profile issue
I am using MetaApi service to integrate MT5 account. Currently working with MT5 groups. Here is the API **https://mt-manager-api-v1.new-york.agiliumtrade.ai/users/current/mt5/provisioning-profiles/{profile_id}/groups ** When i use Manger API id it gives timeout error and when i use ProvisioningProfile id it give 403 error. Can any one help? I have given all the information correct like auth-token and profile id still not getting the required output. Any help would be appreciated. Thanks. -
Page not found (404) No Category matches the given query
When I click the add movie button its showing "Page not found (404) No Category matches the given query." error. it was working till I added a dropdown option to the website where movies are show with respect to the category selected. urls.py -
How can I assign multiple Model in One Foreign Key Model as a Parent Model [ database design ]
I have 3 separate Models 1. InitialBills id uuid name varchar 2. CurrentBills id uuid name varchar 3. BillPaymentInfo id uuid name varchar Now I have one another table which is Document attachment table BillPaymentDocument id uuid biil_data FK [ models either from InitialBills, currentBill or BillPaymentInfo ] doc_name varchar doc_type choice field I want it to be like BillPaymentDocument project = models.ForeignKey(InitialBills,currentBill,BillPaymentInfo on_delete=models.SET_NULL, blank=False, null=True, related_name='bill_payment_detail') I do not want to give seperate table for this how can I do this??? -
Why am I getting 'OperationalError at /account/me/ no such table: main_enroll' if I have the table clearly in main/models?
I have gotten the error 'Operational Error: No Such Table main_enroll' In Django, and I do not understand why as I have defined it properly: Main/Models.py: from django.contrib.auth.models import AbstractUser from django.conf import settings from django.db import models class Course(models.Model): course_name = models.CharField(max_length=30) course_slug = models.CharField(max_length=70) # Other course-related fields def __str__(self): return self.course_name class Enroll(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) course = models.ForeignKey('main.Course', on_delete=models.CASCADE) Accounts/Models.py: from django.contrib.auth.models import AbstractUser class CustomUser(AbstractUser): pass Screenshot of error: Copy & Paste view of error: Environment: Request Method: POST Request URL: http://127.0.0.1:8000/account/me/ Django Version: 5.0.2 Python Version: 3.11.5 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_extensions', 'main', 'welcome', 'userprofile', 'accounts'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback (most recent call last): File "C:\Users\shaur\BrainBall\Website\venv\Lib\site-packages\django\db\backends\utils.py", line 105, in _execute return self.cursor.execute(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\shaur\BrainBall\Website\venv\Lib\site-packages\django\db\backends\sqlite3\base.py", line 329, in execute return super().execute(query, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The above exception (no such table: main_enroll) was the direct cause of the following exception: File "C:\Users\shaur\BrainBall\Website\venv\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner response = get_response(request) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\shaur\BrainBall\Website\venv\Lib\site-packages\django\core\handlers\base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\shaur\BrainBall\Website\skeleton\userprofile\views.py", line 19, in account_page Enroll.objects.create(user=user, course=course) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\shaur\BrainBall\Website\venv\Lib\site-packages\django\db\models\manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\shaur\BrainBall\Website\venv\Lib\site-packages\django\db\models\query.py", … -
Duplicate request when displaying a form associated with the Django model
I am displaying the SendRnxForm form on the Django website. The form is linked to the FilesData model and displays a drop-down list - class SendRnxForm(forms.ModelForm): class Meta: model = FilesData widgets = { 'el_type': forms.Select(attrs={'class': 'form-select', 'id': 'elTypeId'}), } class FilesData(models.Model): el_type = models.ForeignKey(ElType, blank=False, default='1', on_delete=models.DO_NOTHING, related_name='files', verbose_name="Types el") The drop-down list should contain all records of the linked table, and the first record is selected by default. FilesData is associated with the model - class ElType(models.Model): name = models.CharField(max_length=16, db_index=True, verbose_name="Types el") slug = models.SlugField(max_length=24, unique=True, db_index=True, verbose_name="Код") def __str__(self): return self.name In this case, the request to get data from the database is duplicated SELECT `dashApp_cordtype`.`id`, `dashApp_cordtype`.`name`, `dashApp_cordtype`.`slug` FROM `dashApp_cordtype` ORDER BY `dashApp_cordtype`.`id` ASC Views is based on CreateView: class dashForm(DataMixin, CreateView): form_class = SendRnxForm template_name = 'dashApp/dash.html' success_url = reverse_lazy('home') How can I get rid of duplicate requests in this case? I can't figure out where to use select_related/prefetch_related -
I created a model in models.py and it is working but when I clicked on save button it is not saving
here I created a color model but When I am clicking on this save button it is not saving the color Models.py class Color(models.Model): color = ColorField(default='#FF0000') class Meta: verbose_name_plural="colors" def __str__(self): return self.title class Product(models.Model): pid=ShortUUIDField(length=10,max_length=100,prefix="prd",alphabet="abcdef") user=models.ForeignKey(CustomUser, on_delete=models.SET_NULL ,null=True) cagtegory=models.ForeignKey(Category, on_delete=models.SET_NULL ,null=True,related_name="category") vendor=models.ForeignKey(Vendor, on_delete=models.SET_NULL,null=True) color = ColorField(image_field="image") title=models.CharField(max_length=100,default="Apple") image=models.ImageField(upload_to=user_directory_path,default="product.jpg") description=models.TextField(null=True, blank=True,default="This is a product") price = models.DecimalField(max_digits=10, decimal_places=2, default=1.99) old_price = models.DecimalField(max_digits=10, decimal_places=2, default=2.99) specifications=models.TextField(null=True, blank=True) # tags=models.ForeignKey(Tags, on_delete=models.SET_NULL ,null=True) product_status=models.CharField(choices=STATUS, max_length=10,default="In_review") status=models.BooleanField(default=True) in_stock=models.BooleanField(default=True) featured=models.BooleanField(default=False) digital=models.BooleanField(default=False) sku=ShortUUIDField(length=10,max_length=100,prefix="sku",alphabet="abcdef") date=models.DateTimeField(auto_now_add=True) updated=models.DateTimeField(null=True,blank=True) class Meta: verbose_name_plural="Products" def product_image(self): return mark_safe('<img src="%s" width="50" height="50"/>'%(self.image.url)) def __str__(self): return self.title def get_percentage(self): new_price=((self.old_price-self.price)/self.old_price)*100 return new_price see I created models In admin.py class ProductAdmin(admin.ModelAdmin): inlines=[ProductImagesAdmin] list_display=['user','title','product_image','price','featured','product_status','color'] class ColorAdmin(admin.ModelAdmin): list_display=['color'] admin.site.register(Product,ProductAdmin) admin.site.register(Color,ColorAdmin) You can see that I created those models and registered it in admin.py. I also imported all necessary things.When I clicked on the save button and refresh the page it is not saving the colors. So how can I solve it? -
LemonSqueezy webhook requests coming through as GET instead of POST, why?
I have a python/django app which is hosted on PythonAnywhere, DNS and SSL via Cloudflare, and using LemonSqueezy to process payments. Per the docs, LemonSqueezy should send a webhook via POST to the URL I have supplied when an order is created. They do indeed send a webhook, however it is a GET request with an empty body, and I cannot figure out why. I am able to successfully send POST requests both to my local version and to my live version of the site with Postman, so I don't think its a configuration issue with my server. However, I am able to successfully receive the POST webhook on webhook.site (a site for testing webhooks). So I don't think the LemonSqueezy webhooks are broken, either. I've tested several variations of Cloudflare-proxied DNS records with and without a Cloudflare SSL certificate, and with and without a Let's Encrypt SSL Certificate from Pythonanywhere. I've also tested various SSL/TLS modes. In all of the combinations that actually resulted in successful page loads, I consistently was able to get POST requests from Postman but only GET requests from LemonSqueezy. Don't think it's a code issue but including the debug code I'm using anyways. @csrf_exempt … -
Django Model self reference OneToOne, Can't set link while bulk_create
Context Bare with me as im new to Django. I have model Account which I want to refer to itself, in one-to-one relationship. Account also has a one to Many with Activities. Goal When saving Account, save linked_account_id as a self fk Being able to fetch all activities linked to BOTH accounts or just one Problem error stacks: cannot save linked_account_id (string_value), it expects type Account It is also possible the linked account has not yet been persisted so it wont return an entity when trying to save object by linked_account_id This is the data im trying to save using bulk_create for data in filteredList: account_data = { 'accountNumber': data['id'], 'status': data['status'], 'last_synced': parse_datetime(data['last_synced_at']), 'created_at': parse_datetime(data['created_at']), 'updated_at': parse_datetime(data['updated_at']), 'current_balance': data['current_balance']['amount'], 'net_deposits': data['net_deposits']['amount'], 'linked_account_id': data['linked_account_id'], (FK) 'currency': data['base_currency'], 'type': data['account_type'], } this is my Model code class Account (models.Model): accountNumber = models.CharField(default=0, max_length=20,primary_key=True) type = models.CharField(default='', max_length=20) current_balance = models.DecimalField(default=0, max_digits=20, decimal_places=0) net_deposits = models.DecimalField(default=0, max_digits=20, decimal_places=0) currency = models.CharField(default='', max_length=10) last_synced = models.DateTimeField(default=timezone.now) is_primary = models.BooleanField(default=False) linked_account_id = models.OneToOneField('self', on_delete=models.SET_NULL, null=True, blank=True) created_at = models.DateTimeField( default=timezone.now) updated_at = models.DateTimeField(default=timezone.now) status = models.CharField(default='', max_length=10) def __str__(self): return self.type # Or whatever you want to represent your Account instance with def set_linked_account(self, … -
Problem importing nouislider in Django project
In my base template i am trying to link to the nouislider library: {% load static %} <!DOCTYPE html> <html lang="en"> <head> <!-- existing code in the head --> <!-- Include noUiSlider CSS --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.7.1/nouislider.css" integrity="sha512-MKxcSu/LDtbIYHBNAWUQwfB3iVoG9xeMCm32QV5hZ/9lFaQZJVaXfz9aFa0IZExWzCpm7OWvp9zq9gVip/nLMg==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <!-- existing code in the head --> </head> <body> <!-- existing code in body --> <!-- Include noUiSlider library --> <script src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.7.1/nouislider.min.js" integrity="sha512-UOJe4paV6hYWBnS0c9GnIRH8PLm2nFK22uhfAvsTIqd3uwnWsVri1OPn5fJYdLtGY3wB11LGHJ4yPU1WFJeBYQ==" crossorigin="anonymous" referrerpolicy="no-referrer"> </script> <script src="{% static 'javascript/slideshow.js' %}" defer></script> <script src="{% static 'javascript/scrollToTop.js' %}" defer></script> <script src="{% static 'javascript/productFilter.js' %}" defer></script> </body> This base template is extended in another template. Now, the problem is that in my productFilter.js i have all the javascript code i need including the ones for the nouislider, however, while the codes in the productFilter.js are being executed as intened, the nouislider itself does not work on the page. The slider does not even show up. The odd thing is that if i, instead of using the productFilter.js, just put everything in a HTML file like this - <body> <!-- existing code in body --> <!-- Include noUiSlider library --> <script src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/15.7.1/nouislider.min.js" integrity="sha512-UOJe4paV6hYWBnS0c9GnIRH8PLm2nFK22uhfAvsTIqd3uwnWsVri1OPn5fJYdLtGY3wB11LGHJ4yPU1WFJeBYQ==" crossorigin="anonymous" referrerpolicy="no-referrer"> </script> <script> // contents of the productFilter.js </script> </body> the slider shows and works. what i dont … -
How can I solve this problem with Django? [closed]
Anyone who understands Django, please help. I'm trying to run a local server in a completely empty project using the command "./manage.py runserver", before that I went to the root folder with the command "cd myFirstDjangoProject", but instead of issuing the IP address of the local server and a standard Django page, it redirects me to the page in the browser where the text of the manage.py file is simply written. What could be wrong? when entering the commands "migrate" or "startapp" the same thing happens Кто шарит за джанго, помогите пж. Я пытаюсь запустить локальный сервер в абсолютно пустом проекте с помощью команды "./manage.py runserver", до этого зашёл в корневую папку командой "cd myFirstDjangoProject", но вместо выдачи IP адреса локального сервера и стандартной Джанго страницы меня перекидывает в браузер на страницу где просто написан текст файла manage.py. В чём может быть ошибка? при вводе команд "migrate" или "startapp" происходит то же самое The terminal in pycharm should have given me the address of the local server, but I was transferred to the browser where the text of the manage.py file was opened -
In django authentication in login function user always given none value ,how to fix this issue?
In Django authentication, the login function returns None for the user if authentication fails or credentials are incorrect. During login, the authenticate function consistently returns None, but it should return a value when the email and password match. -
Defining abstract base model that can be referenced in another model in Django
Having these models in Django. Album and Playlist as song collections. Library consists of playlists and albums. After I defined base model to hold some common fields of Album and Playlist, some complications occured: class Collection(models.Model): title = models.CharField(max_length=64) release_date = models.DateField() class Meta: abstract = True class Album(Collection): pass class Playlist(Collection): is_public = models.BooleanField(default=True) is_liked_songs_playlist = models.BooleanField(default=False) description = models.TextField(blank=True) class Library(models.Model): collections = models.ManyToManyField("Collection", related_name="libraries") # playlists = models.ManyToManyField("Playlist", related_name="libraries") # albums = models.ManyToManyField("Album", related_name="libraries", blank=True) This code errors since Collection is abstract. Is is possible to change somehow that so that works without changing Collection from abstract to regular? I do not want Collection model has its own table in db. Maybe I need to change type of relation from ManyToManyField to some other? Please advice -
ModuleNotFoundError: No module named 'modeltranslation'
I've created a django project, where I want to use modeltranslation, but I cant get it to work as I keep getting this error: (portfolio_env) jonas@kea-dev: ~/portfolio_project (main|✚11…)% django makemigrations Traceback (most recent call last): File "/home/jonas/portfolio_project/manage.py", line 22, in <module> main() File "/home/jonas/portfolio_project/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/jonas/.local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line utility.execute() File "/home/jonas/.local/lib/python3.11/site-packages/django/core/management/__init__.py", line 416, in execute django.setup() File "/home/jonas/.local/lib/python3.11/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/jonas/.local/lib/python3.11/site-packages/django/apps/registry.py", line 91, in populate app_config = AppConfig.create(entry) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jonas/.local/lib/python3.11/site-packages/django/apps/config.py", line 193, in create import_module(entry) File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1204, in _gcd_import File "<frozen importlib._bootstrap>", line 1176, in _find_and_load File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked ModuleNotFoundError: No module named 'modeltranslation' It is installed in the venv: (portfolio_env) jonas@kea-dev: ~/portfolio_project (main|✚11…)% pip list Package Version ----------------------- --------- asgiref 3.7.2 Django 5.0.2 django-cuser 2017.3.16 django-modeltranslation 0.18.11 django-tinymce 3.7.1 importlib-metadata 7.0.1 modeltranslation 0.25 phonenumbers 8.13.30 phonenumberslite 8.13.30 pip 24.0 psycopg-binary 3.1.18 psycopg2-binary 2.9.9 python-dotenv 1.0.1 setuptools 65.5.0 sqlparse 0.4.4 style 1.1.0 typing_extensions 4.9.0 zipp 3.17.0 And I have added in the "INSTALLED_APPS" in settings.py: INSTALLED_APPS = [ 'modeltranslation', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'portfolio_app', ] I import the … -
django-tailwind is not rebuilding styles
I'm trying to use tailwind with my django project and i've followed as this documentation (https://django-tailwind.readthedocs.io/en/latest/installation.html) when i'm making changes in tailwind classes in my html files in the terminal it get rebuild but the changes are not being seen to my design somehow. settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'authen', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'tailwind', 'theme', 'django_browser_reload', 'rental', 'roommate' ] TAILWIND_APP_NAME = 'theme' INTERNAL_IPS = [ "127.0.0.1", ] index.html in my templates folder where theme, manage.py etc folders exist. {% load static tailwind_tags %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Rentopia</title> <!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"> --> <link rel="icon" href="{% static 'images/home.png' %}" type="image/png"> {% tailwind_css %} i've tried with this in package.json but it still does nothing "dev": "cross-env NODE_ENV=development CHOKIDAR_USEPOLLING=1 tailwindcss --postcss -i ./src/styles.css -o ../static/css/dist/styles.css -w", -
I am building a website with Django and React and i am encountering the following error
This is the error that I encountered, it describes something that has to do with the apps installed, but I checked all necessary apps and all of them are correctly installed, i have also setup my environment correctly as far as I know, please give me a solution to this problem -
Django app rendering poorly after deployment
I just deployed my django app to my custom domain. I'm using Nginx as the web server and Uvicorn for ASGI. Static files are stored in an AWS S3 bucket. The Django application is deployed on an EC2 instance. However my styling for mydomain.com/app is messed up. All my other apps render correctly including the main website but visiting /app for some reason doesn't render correctly in terms of styling/layout. I've tried to troubleshoot as much as I can including making sure Nginx can access and serve my static files but I can't figure out what the issue is. My tailwind css and static files render correctly on my website but not when I visit /app. Any help is appreciated.