Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
I would like to send a html as a popup in django admin
Admin is not sending the html page in the form of popup its displaying in window admin.py def RESTORE(self,obj): url = f'/system/displayer/' opensrt = f"window.open({url},'width=600,height=400')" return format_html('<a href="{url}"onclick="{opensrt}">RESTORE</a>', opensrt=opensrt,url=url) views.py def display(request): if request.method=='POST': print("HI POST") output=request.POST.get('output') if output=='YES': pass return render(request, "abc.html",{'form':UserForm}) -
How to find all objects as objects in the list in django?
i have 1 model like this class SomeModel(models.Model): data = models.JSONField(null=False) SomeModel's data is like id:1, data:{'one': ['1', '2', '3'], 'two': ['2', '3'], ...} id:2, data:{'one': ['1', '2'], 'two': ['2'], ...} id:3, data:{'one': ['1', '3'], 'two': ['3'], ...} I want to filter all objects got '2'. i need some help :( -
How can I use AWS dynamo db local and postgresql in a single django project?
I have a django project in which I need both postgresql and AWS dynamo db.I had configured postgresql and it is working well but I cant find a way to configure dynamo db. settings.py: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'postgres', 'USER': 'postgres', 'PASSWORD': 'postgres', 'HOST': 'db', 'PORT': 5432 } } How can I configure dynamo db in this project? -
My pagination in Category pages is not working
I made a blog app in which I want to add pagination both on home page and category page. but after a lot of efforts I didn't get how to use it in the category page. I use 2 parameters in category view and I don' know how to fix it now. whenever I click on category "That page number is not an integer" displays. views.py: def allpost(request): postData = Post.objects.all() paginator = Paginator(postData, 5) # Show 5 contacts per page. page_number = request.GET.get('page') page_obj = paginator.get_page(page_number) return render(request, 'posts.html', {'page_obj': page_obj}) def CategoryView(request, cats='category__title'): category_posts = Post.objects.all() paginator = Paginator(category_posts, 5) # We don't need to handle the case where the `page` parameter # is not an integer because our URL only accepts integers try: category_posts = paginator.page('cats') except EmptyPage: # if we exceed the page limit we return the last page category_posts = paginator.page(paginator.num_pages) return render(request, 'categories.html', {'category_posts': category_posts}) urls.py: path('category/<str:cats>/', views.CategoryView, name ="category"), categories.html {% extends 'base.html' %} {%block content%} <h1> Category: {{ cats }} </h1> {% for post in category_posts %} <div class="container mt-3"> <div class="row mb-2"> <div class="col-md-6"> <div class="card flex-md-row mb-4 box-shadow h-md-250"> <div class="card-body d-flex flex-column align-items-start"> <strong class="d-inline-block mb-2 text-primary">{{ post.category }}</strong> … -
Reverse for 'delete_reply' with arguments '(7, '')' not found
I am a new for Django and need some help. I want to make a 'delete' function regarding comments, but when I clicked the deletion button, I got the error Reverse for 'delete_reply' with arguments '(7, '')' not found. 1 pattern(s) tried: ['boards/(?P<board_pk>[0-9]+)/reply/(?P<reply_pk>[0-9]+)/delete/\Z'] I guess that there is no pk for the reply_pk, so I tried to give the pk into the url. However, I couldn't get the answer what I want. I spend lots of time to find solutions on google and here, but all wonderful answers couldn't help me to fix it. I attached my code here and please help me model.py class ReplyBoard(core_models.TimeStampedModel): reply = models.TextField(default="") user = models.ForeignKey(user_models.User, related_name = "reply", on_delete = models.CASCADE) board = models.ForeignKey("Board", related_name = "reply", on_delete = models.CASCADE, null = True) view.py class Board_detail(View): def get(self, *args, **kwargs): pk = kwargs.get("pk") try: form = forms.ReplyForm() board = board_models.Board.objects.get(pk=pk) return render(self.request, "boards/board_detail.html", {"board": board, "form": form}) except board_models.Board.DoesNotExist: raise Http404() def create_reply(request, board_pk): form = forms.ReplyForm(request.POST) if request.method =="POST": board = board_models.Board.objects.get(pk=board_pk) if form.is_valid(): reply = form.save() reply.board = board reply.user = request.user reply.save() messages.success(request, "creted the comment.") return redirect(reverse("boards:board_detail", kwargs={"pk": board.pk})) @login_required() def delete_reply(request, board_pk, reply_pk): try: reply = board_models.ReplyBoard.objects.get(pk=reply_pk) if … -
Is there any way to make my model only take input which is an x-ray image?
I am a newbie here in ML. I have a CNN model which predicts between 2 classes i.e. Pneumonia and Normal x-ray images.. It was great until I found that it also processes any image other than x-rays like Given a picture of a dog, it would still predict pneumonia or normal randomly. Is there any way to make it accept only x-ray images. or some workaround in Django to make it work? -
How do I solve the problem of " 'mssql' isn't an available database backend or couldn't be imported" on windows?
I ran into this problem when trying to deploy some django project on a Windows 10 computer. Every time I try to access localhost, it displays this error: Error occurred while reading WSGI handler: Traceback (most recent call last): File "c:\programdata\anaconda3\lib\site-packages\django\db\utils.py", line 113, in load_backendreturn import_module("%s.base" % backend_name) File "c:\programdata\anaconda3\lib\importlib\__init__.py", line 127, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 961, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1014, in _gcd_importFile "", line 991, in _find_and_load File "", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'mssql' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\XXX\AppData\Roaming\Python\Python38\site-packages\wfastcgi.py", line 791, in mainenv, handler = read_wsgi_handler(response.physical_path) File "C:\Users\XXX\AppData\Roaming\Python\Python38\site-packages\wfastcgi.py", line 633, in read_wsgi_handlerhandler = get_wsgi_handler(os.getenv("WSGI_HANDLER")) File "C:\Users\XXX\AppData\Roaming\Python\Python38\site-packages\wfastcgi.py", line 600, in get_wsgi_handlerhandler = __import__(module_name, fromlist=[name_list[0][0]]) File "C:\inetpub\wwwroot\ScenarioAnalysis\ScenarioAnalysis\wsgi.py", line 16, in application = get_wsgi_application() File "c:\programdata\anaconda3\lib\site-packages\django\core\wsgi.py", line 12, in get_wsgi_applicationdjango.setup(set_prefix=False) File "c:\programdata\anaconda3\lib\site-packages\django\__init__.py", line 24, in setupapps.populate(settings.INSTALLED_APPS) File "c:\programdata\anaconda3\lib\site-packages\django\apps\registry.py", line 116, in populateapp_config.import_models() File "c:\programdata\anaconda3\lib\site-packages\django\apps\config.py", line 269, in import_modelsself.models_module = import_module(models_module_name) File "c:\programdata\anaconda3\lib\importlib\__init__.py", line 127, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level) File "c:\programdata\anaconda3\lib\site-packages\django\contrib\auth\models.py", line 3, in from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "c:\programdata\anaconda3\lib\site-packages\django\contrib\auth\base_user.py", … -
Django admin.py fieldsets: How to add a field from a ManyToMany field inside listdisplay?
I have these 2 models: class Size(models.Model): _id = models.AutoField(primary_key=True, editable=False) size = models.CharField(max_length=50, null=True, blank=False) SIZE_TYPES = ( ('XS', 'XS'), ('S', 'S'), ('M', 'M'), ('L', 'L'), ('XL', 'XL'), ('XXL', 'XXL'), ) size_type = models.CharField(max_length=10, choices=SIZE_TYPES, null=True, blank=True) GENDERS = ( ('M', 'Male'), ('F', 'Female'), ('U', 'Unisex'), ) gender = models.CharField(max_length=50, choices=GENDERS, null=True, blank=False) def __str__(self) -> str: return f'{self.size} ({self.size_type}) - {self.gender}' and: class Product(models.Model): _id = models.AutoField(primary_key=True, editable=False) user = models.ForeignKey(CustomUser, on_delete=models.SET_NULL, null=True) category = models.ForeignKey(Category, on_delete=models.SET_NULL, null=True) brand = models.ForeignKey(Brand, on_delete=models.SET_NULL, null=True) size = models.ManyToManyField(Size) (... other attributes) and on my admin.py I want that ProductAdmin had the Size's attributes on listdisplay, but it doesn't work so I have my ProductAdmin like this: @admin.register(Product) class ProductAdmin(admin.ModelAdmin): list_display = ['_id','name', 'brand', 'price', 'stock', 'category','rating','user','size'] But I can't get it to work, I've tried also size__size, also doesn't work. What I need: For list_display, I just want that the admin could see the product's size as a column on the Product's table in admin panel. The Product table should look like this: id name (...) size 1 Jordan sneakers (...) 7.5 (US) - M -
I am trying to connect to mysql on django app but i am facing this error and cannot find solution online
and the pacakge i used is mysql-connector-python and the error that i am facing is -
How to filter custom field in graphene django?
from graphene_django import DjangoObjectType from .models import Question class QuestionType(DjangoObjectType): class Meta: model = Question fields = ("id", "question_text") extra_field = graphene.String() def resolve_extra_field(self, info): return "hello!" On my Query result = Question.objects.filter(extra_field='hello!') Error Cannot resolve keyword 'extra_field' into field. How can I filter the extra_field in my Query? -
Problem with logic building for registering a model in django
I am in the middle of a project. I have extended the custom django user and modified it. this is my user model:- class User(AbstractUser): name = models.CharField(max_length=200, null=True, blank=True) usertype = models.CharField(choices = [('d','doctor'), ('p','patient')], max_length=1) USERNAME_FIELD = 'username' REQUIRED_FIELDS = [] def __str__(self): return self.name Also I have declared two seperate models named Patient and Doctors. My objective is to register the users in their respective models(Doctors or Patients) by checking the usertype. Here are those models:- class Patient(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='patient') dob = models.DateField(null=True, blank=True) contact = models.CharField(null=True, blank=True, max_length=100) def __str__(self): return self.user.name class Doctor(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='doctor') deg = models.TextField(null=True, blank=True) def __str__(self): return self.user.name Now at the front end I want to apply the logic as every time a user is registered the user selects the usertype and based on that selection the Doctor or the Patient module is updated. I have tried creating separate forms for that too. Here are my forms :- class MyUserCreation(UserCreationForm): class Meta: model = User fields = ['name','username','usertype'] class DoctorCreation(ModelForm): class Meta: model = Doctor fields = ['user','deg'] class PatientCreation(ModelForm): class Meta: model = Patient fields = ['dob', 'contact','user'] The view handling this URL … -
How to store user specific data in Django
In Django, How to store user specific data? I'm trying to creating a django web app, where user need to remember the order of random sequence fetched from database. I have to functions in my views, home and result I tried to store random sequence generated by home function into a global variable, and use that to validate in results function But , I think this can serve only one user at time What if second user requested for home page and that cause change in global variable, resulting unable to validate first user. -
How Can I search Django Multiple Tables with List
I want to search three models using forms in Django which are related by Foreignkey. And I also want to display a list of this search result with their respective details. The idea is that, I have the following django models; Event, Ticket, and Pin. And I want to search using the Event name but I can't figure out what is really the issue with my code I am having error which says Field 'id' expected a number but got 'Birth Day' so below is what I tried, Models: class Event(models.Model): event_name = models.CharField(max_length=100) date = models.DateField(auto_now_add=False, auto_now=False, null=False) event_venue = models.CharField(max_length=200) event_logo = models.ImageField(default='avatar.jpg', blank=False, null=False, upload_to ='profile_images') added_date = models.DateTimeField(auto_now_add=True) def __str__(self): return f"{self.event_name}" #Prepare the url path for the Model def get_absolute_url(self): return reverse("event_detail", args=[str(self.id)]) class Ticket(models.Model): event = models.ForeignKey(Event, on_delete=models.CASCADE) price = models.PositiveIntegerField() category = models.CharField(max_length=100, choices=PASS, default=None, blank=True, null=True) added_date = models.DateField(auto_now_add=True) def __str__(self): return f"{self.event} " #Prepare the url path for the Model def get_absolute_url(self): return reverse("ticket-detail", args=[str(self.id)]) def generate_pin(): return ''.join(str(randint(0, 9)) for _ in range(6)) class Pin(models.Model): ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE) value = models.CharField(max_length=6, default=generate_pin, blank=True) added = models.DateTimeField(auto_now_add=True, blank=False) reference = models.UUIDField(primary_key = True, editable = False, default=uuid.uuid4) status = models.CharField(max_length=30, … -
how to show tabularinline data in json api django rest framework?
This is my code, the api only shows the "shorts" data and i want also shows the "subcard" tabularinline data models.py class Shorts(models.Model): shortName = models.CharField(max_length=50,verbose_name='Short name') video = models.FileField(upload_to='shorts',verbose_name='VideoFile') short_url = models.URLField(default=False, verbose_name='Short URL') def __str__(self): return self.shortName class SubCards(models.Model): sentence = models.CharField(max_length=150, verbose_name='Sentence',default=False) meaning = models.CharField(max_length=150, verbose_name='meaning',default=False) parent_card = models.ForeignKey(Shorts,null=True,on_delete=models.CASCADE) positionCard= models.IntegerField(null=True,verbose_name='positionCard') skip_to = models.FloatField(null=True,verbose_name='skip video to') def __str__(self): return "subCard" admin.py class cartita(admin.TabularInline): model = SubCards class subcard(admin.ModelAdmin): inlines=[cartita] admin.site.register(User) admin.site.register(Cards) admin.site.register(Shorts,subcard) This view sends the api response views.py class shortView(View): @method_decorator(csrf_exempt) def dispatch(self, request, *args, **kwargs): return super().dispatch(request, *args, **kwargs) def get(self, request): shorts = list(Shorts.objects.values()) if len(shorts) > 0: data = {'message':'success','shorts': shorts} else: data = {'message':'short not found'} return JsonResponse(data) -
Django - webbrowser.open doesn`t work in production mode
I am developing an app that should send msg by WhatsApp. Running from Django Development Server works fine, but from Xampp it doesn't, I even tried opening whatsapp from the url directly in the project and it doesn't work either. The problem is open function from webbrowser module. Python 3.10.6 Django 3.2.0 def send_whatsapp(telefono, mensaje): try: webbrowser.open_new_tab(f"https://web.whatsapp.com/send?phone={telefono}&text={mensaje}") print("Mensaje enviado") except Exception: print("Error") Thanks!! -
How to use values and distinct on different field on Django ORM?
currently I have terms on my applications and one user can have a lot of terms registered, and my current model is like this class Term(models.Model): id = models.UUIDField("id", default=uuid.uuid4, editable=False, primary_key=True) user_id = models.PositiveIntegerField("user id", default=None) name = models.CharField() sometimes I need to do a query to get all the users who have terms registered, so I do the following query: Term.objects.filter(active=True) .order_by("user_id") .values("user_id") .distinct() and this is enough to solve my problems, but now I'll change my model and it will look like this: class Term(models.Model): id = models.UUIDField("id", default=uuid.uuid4, editable=False, primary_key=True) user_id = models.PositiveIntegerField("user id", default=None) name = models.CharField() shared_with = ArrayField(models.PositiveIntegerField("id do usuario"), blank=True) # New How you can see, I've added a new field named shared_with, that basically is a array of user ids which I want to share terms, So now I need to make a query who will return all ids who can have terms registered (shared_with included). So if i register a Term with user_id = 1 and shared_with = [2,3], my query need to return [1,2,3]. I've solved this problem today with the following code, but I think I can do this just using django ORM and one query: users = … -
Django failing to load images from my media file but is not giving me a 404 error and has the correct file path. What could be causing this issue?
To clarify my title, I have a database set up in my Django application that takes information from albums, including album covers. The image saves in the database, goes to the correct MEDIA_ROOT specified in my settings.py file, and shows the correct url path when checking the request path. I am using the latest version of Django and have Pillow installed to add the images into the database through the admin site. Previously, when the file path was wrong, Django served a 404 error and couldn't find the file. Now that the path is correct, it loads for a moment and then says "server not found". When I inspect the image, it says that the "connection used to fetch this resource was not secure." however I am running the server locally and am not in a production enviroment, and all answers related to this issue seem to come from running the server in production. When I attempt to open the image in a new tab, the tab says "Server not found" after attempting to load the filepath: "http://albums/filename_oja97pG.png" (you can see here the unsercure http response. I replaced the file name for privacy reasons.) I am unsure what would be … -
Cannot find default form templates after upgrading django from 3.x to 4.x
I just upgraded django from 3.x to 4.x. I am getting error for template not found: TemplateDoesNotExist at /admin/login/ django/forms/errors/list/default.html The template is in this location: ./lib/python3.8/site-packages/django/forms/templates/django/forms/errors/list/default.html Django is trying to look in those locations: django.template.loaders.filesystem.Loader: ./project/templates/django/forms/errors/list/default.html (Source does not exist) django.template.loaders.app_directories.Loader: ./lib/python3.8/site-packages/django/contrib/admin/templates/django/forms/errors/list/default.html (Source does not exist) django.template.loaders.app_directories.Loader: ./lib/python3.8/site-packages/django/contrib/auth/templates/django/forms/errors/list/default.html (Source does not exist) django.template.loaders.app_directories.Loader: ./project/android/templates/django/forms/errors/list/default.html (Source does not exist) django.template.loaders.app_directories.Loader: ./project/webapp/templates/django/forms/errors/list/default.html (Source does not exist) django.template.loaders.app_directories.Loader: ./lib/python3.8/site-packages/oauth2_provider/templates/django/forms/errors/list/default.html (Source does not exist) django.template.loaders.app_directories.Loader: ./lib/python3.8/site-packages/rest_framework/templates/django/forms/errors/list/default.html (Source does not exist) django.template.loaders.app_directories.Loader: ./lib/python3.8/site-packages/debug_toolbar/templates/django/forms/errors/list/default.html (Source does not exist) django.template.loaders.app_directories.Loader: ./lib/python3.8/site-packages/ajax_select/templates/django/forms/errors/list/default.html (Source does not exist) So obviously, django is not even looking into it's own django.forms directory and I cannot figure out why. Is there some new settings on 4.x, that I am missing? Edit: It is caused in all places, where there's a form and form.non_field_errors is called, because returned ErrorList class is using this template. -
How to read the header content of a webpage in Django?
I created a search engine in Django and bs4 that scrapes search results from the Ask.com search engine. I would like when Django fetches search results from Ask, it checks the value of the X-Frame-Options header or if CSP_FRAME_ANCESTORS has the values "'self'", '*' in case the header exists in order to give a value to my notAccept boolean depending on the result of the condition. I took inspiration from this page of the Django documentation and also from this other page to write the following code: for page_num in range(1, max_pages_to_scrap+1): url = "https://www.ask.com/web?q=" + search + "&qo=pagination&page=" + str(page_num) res = requests.get(url) soup = bs(res.text, 'lxml') result_listings = soup.find_all('div', {'class': 'PartialSearchResults-item'}) for result in result_listings: result_title = result.find(class_='PartialSearchResults-item-title').text result_url = result.find('a').get('href') result_desc = result.find(class_='PartialSearchResults-item-abstract').text final_result.append((result_title, result_url, result_desc)) for header in final_result[1]: if(header.CONTENT_TYPE.X-Frame-Options == "DENY" | header.CONTENT_TYPE.X-Frame-Options == "SAMEORIGIN" | !(CSP_FRAME_ANCESTORS == ("'self'", '*'))): #The error is generated on this line head = True notAccept = bool(head) else: notAccept = bool(False) However, this gives me the following errors in the command line of my IDE: "(" was not closed Expected expression Expected ":" and the following warnings: "Frame" is not defined "Options" is not defined "CSP_FRAME_ANCESTORS" is not defined … -
data of foreign keys are not saving in django admin nested inlines
I'm trying to build a list of replicable fields where the order can be interchanged. To do so I've built three different models Multicap Multitext Multimg which are Inlines of the model Multis which is an Inline of the model Delta. I'm using django-nested-admin and everything works fine on the admin page, I can add new objects and change their order. The problem I have is that when I populate the fields, save the model and then check its content, all the data of the text fields are turned into zeros 0. instead, when I try to save the image I get this error: AttributeError: 'int' object has no attribute 'field' models.py class Multis(models.Model): name = models.TextField(max_length=50, null=True, blank=True) delta = models.ForeignKey('Delta', related_name="delta", null=True, on_delete=models.CASCADE) class Meta: ordering = ('name',) def __str__(self): return str(self.name) class Multicap(models.Model): caption = models.TextField(max_length=50, null=True, blank=True) multic = models.ForeignKey('Multis', related_name="multicap", null=True, on_delete=models.CASCADE) class Meta: ordering = ('caption',) def __str__(self): return str(self.caption) class Multimg(models.Model): img = models.ImageField(upload_to="images", verbose_name='Image', null=True, blank=True,) multim = models.ForeignKey('Multis', related_name="multimg", null=True, on_delete=models.CASCADE) class Meta: ordering = ('img',) @property def img_url(self): if self.img and hasattr(self.img, 'url'): return self.img.url def get_image_filename(instance, filename): title = instance.post.title slug = slugify(title) return "post_images/%s-%s" % (slug, filename) def … -
Django get data from related model which has the FK
how can i make this queryset: SELECT p.*, o.name, o.link FROM property p INNER JOIN listing l on l.property_id = p.id INNER JOIN ota o on o.id = l.ota_id models class Property(Model): code = CharField() ... class Listing(Model): ota = ForeignKey(Ota) property = ForeignKey(Property) class Ota(Model): name = Charfield() link = Charfield() with Property.objects.all() I can see in the returned object that there is a listing_set let's say: queryset = Property.objects.all() queryset[0].listing_set.all() but it brings the entire model, and not the related to property_id; also tried to get Ota data in serializer with SerializerMethodField and perform a new query to get this info, but decrease performance significantly. -
Django User Authentication Trouble
Hello community, i'm new to Django. Learning and creating my first project. I'm trying to making the user authentication app, i create a Customer model which relate to Django default User Model, but unfortunately when i approve registration form its create Customer model and User model separately, and User can use my web application only after i assume his profile in admin panel. Is a way automate this process? It doesn't cause errors, but doing it by hand every time is insane. Would be thankful for the help ... Here is my authentication.views from django.contrib.auth import authenticate, login, logout from django.shortcuts import render, redirect from django.contrib.auth.models import User from django.contrib import messages from utils import cookieCart from django.conf import settings from django.core.mail import send_mail # Create your views here. def auth_home(request): if request.method == 'POST': username = request.POST['username'] first_name = request.POST['first_name'] last_name = request.POST['second_name'] mobile_number = request.POST['mobile'] email = request.POST['email'] city = request.POST['city'] pass1 = request.POST['password1'] pass2 = request.POST['password2'] my_user = User.objects.create_user(username, email, pass1) my_user.username = username my_user.email = email my_user.first_name = first_name my_user.last_name = last_name my_user.confirmed_password = pass2 my_user.city_from = city my_user.mobile_number = mobile_number my_user.save() messages.success(request, "Ваш аккаунт успешно создан! :) ") subject = "WHO'S THE BOSS ONLINE STORE" … -
envfile syntax. How integers (like PORTs) should be written
I wonder if these configs are the same: Config 1: EMAIL_PORT=587 EMAIL_USE_TLS=True EMAIL_USE_SSL=None Config 2: EMAIL_PORT='587' EMAIL_USE_TLS='True' EMAIL_USE_SSL='None' settings.py (or just a random python file): EMAIL_PORT = os.getenv('EMAIL_PORT') EMAIL_USE_TLS = os.getenv('EMAIL_USE_TLS') EMAIL_USE_SSL = os.getenv('EMAIL_USE_SSL') Will my, let's say EMAIL_PORT in settings.py get a value of 587 or it will be '587' instead, or if EMAIL_USE_TLS will get the pythonic boolean True or 'True' instead? What is the suggestion on assigning variables in envfile? How to handler such booleans, integers or any other non-string values? thanks! -
ModuleNotFoundError: No module named 'widget_tweaks' with Django in VSCode Debugger
widget_tweaks is installed and added in INSTALLED_APPS in my setting.py. If I start the server with python3 manage.py runserver in the terminal it works. If I start the vscode debugger, I get this error in the Debug Console: File "/Users/frank/Dev/MyListApp/env/lib/python3.10/site-packages/django/apps/config.py", line 193, in create import_module(entry) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'widget_tweaks' My launch.json is: { "name": "MyList", "python": "/Users/frank/Dev/MyListApp/env/bin/python3", "type": "python", "request": "launch", "program": "${workspaceFolder}/MyListApp/manage.py", "console": "internalConsole", "args": [ "runserver" ], "django": true, "justMyCode": true, } As test: If I use PyCharm, I get the same error when I start the PyCharm debugger. Where is the problem? In the terminal it works, in the debugger not... -
How to add RQ progress bar in Django
What I'm trying to do is to display a progress bar from background task from rq library, so is there a way to display a progress bar , I'm running rq from windows 10 on WSL 2 from Ubuntu 20.0.4 Any help will be appreciated , Thanks alot!