Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
You are seeing this page because DEBUG=True is in your settings file and you have not configured any URLs
Getting the error: You are seeing this page because DEBUG=True is in your settings file and you have not configured any URLs. meetups/urls.py from django.urls import path from . import views urlpatterns = [ path('meetups/', views.index) #domain_name.com/meetups/ ] urls.py from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('', include('meetups.urls')) ] views.py from django.shortcuts import render # Create your views here. def index(request): return render(request,'templates/meetups/index.html') -
How to upgrade my AWS ebs Platform from running Python 3.8 to python 3.10?
More specifically I am currently running Python 3.8 running on 64bit Amazon Linux 2/3.3.16. I was hoping to make it python 3.10. I have seen instructions online but I do not know where to run those commands and where to start. Thanks in advance for any help. -
Withdrawal in Django Rest API
I am getting an error "UserRoom object has no attribute 'images'" models.py class UserRoom(models.Model): objects = None categoty = [ ('President Lux', 'President Lux'), ('Lux', 'Lux'), ('Double', 'Double'), ('Standard', 'Standard'), ] name = models.CharField(max_length=150, choices=categoty, verbose_name='Категория') room_num = models.CharField(max_length=150,verbose_name='Доступные номера для категории') about = models.TextField(verbose_name='Подробности') price = models.IntegerField(verbose_name='Цена') img360 = models.FileField(verbose_name='Фотография в 360') class Meta: verbose_name = 'Номер (About)' verbose_name_plural = 'Номера (About)' class UserImg(models.Model): objects = None name = models.ForeignKey(UserRoom, on_delete=models.CASCADE, verbose_name='img2') img = models.FileField(upload_to='User img', verbose_name='Фотография') class Meta: verbose_name = 'Фотографию' verbose_name_plural = 'Фотографии' views.py class UserRoomViewSet(ModelViewSet): permission_classes = [AllowAny] queryset = UserRoom.objects.all() serializer_class = UserRoomSer serializers.py class UserImgSer(ModelSerializer): class Meta: model = UserImg fields = '__all__' class UserRoomSer(ModelSerializer): images = RelatedField( many=True, queryset=UserImg.objects.all()) class Meta: model = UserRoom fields = [ 'name', 'room_num', 'about', 'price', 'img360', 'images', ] urls.py from rest_framework import routers router = routers.DefaultRouter() router.register(r'room', UserRoomViewSet) urlpatterns = router.urls please help me with this problem i can't get json IN THE IDEA I SHOULD LOOK LIKE THIS { "images": [ { "name": "", "img": "" }, { "name": "", "img": "" } ], "name": "", "room_num": "", "about": "", "price": "", "img360": "" } ANOTHER PROGRAMMER HELPED ME AND EVERYTHING WORKS FOR HIM BUT WHY … -
Reverse for 'AddCart' not found. 'AddCart' is not a valid view function or pattern name
I am Working on my project and I don't know how this error I got Can anybody see what I'm missing? Traceback Environment: Request Method: GET Request URL: http://127.0.0.1:8000/onlinePizza/menu/ Django Version: 4.0.5 Python Version: 3.10.4 Installed Applications: ['onlinePizza.apps.OnlinepizzaConfig', 'cart', 'accounts', 'blog', 'django_user_agents', 'import_export', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] 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', 'django_user_agents.middleware.UserAgentMiddleware'] Template error: In template C:\Django venv\Project\DjPizza\templates\onlinePizza\pc_menu.html, error at line 72 Reverse for 'AddCart' not found. 'AddCart' is not a valid view function or pattern name. 62 : {{i|cart_quantity:request.session.cart}} 63 : </div> 64 : <div class="col-auto"> 65 : <form action="{% url 'cart:AddCart' %}" method="POST">{% csrf_token %} 66 : <input hidden type="text" name="product" value="{{i.id}}"> 67 : <button class="main-btn cart cart-btn" style="padding: 3px 17px;"><i class="fa-solid fa-plus"></i></button> 68 : </form> 69 : </div> 70 : </span> 71 : {% else %} 72 : <form action=" {% url 'cart:AddCart' %} " method="POST">{% csrf_token %} 73 : <input hidden type="text" name="product" value="{{i.id}}"> 74 : <button class="main-btn cart cart-btn" style="padding: 5px 32px">Add <i class="fa-solid fa-cart-shopping"></i></button> 75 : </form> 76 : {% endif %} 77 : </div><!-- /Cart Button --> 78 : </div> 79 : </div> 80 : </div> 81 : </div> 82 : {% endfor %} Traceback (most … -
In admin I see "Topic_object(1)" but not actual object name
from django.db import models # Create your models here. class Topic(models.Model): """A topic the user is learning about.""" text = models.CharField(max_length=200) date_added = models.DateTimeField(auto_now_add=True) class Entry(models.Model): """Something specific learned about a topic.""" topic = models.ForeignKey(Topic, on_delete=models.CASCADE) text = models.TextField() date_added = models.DateTimeField(auto_now_add=True) class Meta: verbose_name_plural = 'entries' def __str__(self): """Return a string representation of the model.""" return self.text # return f"{self.text[:50]}..." but I see this: Topic object(1), however I want to see Chess! enter image description here -
Slack Bot replies to every channel
I am using a slack bot to send messages from my app to slack. My use cases: ---> user types IN command to a specific bot and then the bot returns with system generated message within a channel Now everything is going well ..i want bot replies only if user's send direct messages to that bot. but in my case that is not happening.no matter which channel user;s type in command the bot replies but that is what i do not want. i want the system to reply only if user sends in command to my bot channel class SlackEvents(APIView): def post(self, request, *args, **kwargs): slack_message = request.data # denied if request is sent from some other url if slack_message.get('token') != SLACK_VERIFICATION_TOKEN: return Response(status=FORBIDDEN) # verification challenge if slack_message.get('type') == 'url_verification': return Response(data=slack_message,status=OK) # greet bot if 'event' in slack_message: event = slack_message.get('event') # ignore bot's own message if event.get('subtype') == 'bot_message': return Response(status=OK) # process user's message if event['type'] == 'message': # a = Client.conversations_open() user = event['user'] channel = event['channel'] other_channel = 'C03SKDLHUPP' msg = event['text'] if msg == 'in': in_command(channel,other_channel,user) if msg == 'out': out_command(channel,other_channel,user) if msg == 'brb': brb_command(channel,other_channel,user) if msg == 'lunch': lunch_command(channel,other_channel,user) if msg … -
drf viewset : multiple choices
I tried to make method(location_item) that shows item by region. And I want to implement the 'gu, dong' field(in location model) with multiple choices. so, wrote this method code. but filtering doesn't work.. This shows all item objects, not just the objects I want. TypeError: Field 'id' expected a number but got <Item: 애니원모어 원피스입니다!>. [13/Aug/2022 15:01:07] "GET /item_post/location/location_item/ HTTP/1.1" 500 152955 I don't know what sholud i do. please help me... models.py class Item(models.Model): user_id = models.ForeignKey(User, related_name='item_sets', on_delete=models.CASCADE) category_id = models.ForeignKey(Category, related_name='item_sets', on_delete=models.DO_NOTHING) description = models.TextField() feature = models.TextField() product_defect = models.TextField() size = models.CharField(max_length=6) wear_count = models.IntegerField() price = models.IntegerField() created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.description class Location(models.Model): city = models.CharField(max_length=10) gu = models.CharField(max_length=10) dong = models.CharField(max_length=10) def __str__(self): return self.city+" "+self.gu+" "+self.dong class LocationSet(models.Model): item_id = models.ForeignKey(Item, on_delete=models.CASCADE, related_name='location_sets') location_id = models.ForeignKey(Location, on_delete=models.CASCADE, related_name='location_sets') serializers.py class ItemSerializer(serializers.ModelSerializer): photos = PhotoSerializer(source='photo_sets', many=True, read_only=True) style_photos = StylePhotoSerializer(source='style_photo_sets', many=True, read_only=True) class Meta: model = Item fields = '__all__' class LocationSerializer(serializers.ModelSerializer): class Meta: model = Location fields = '__all__' class LocationSetSerializer(serializers.ModelSerializer): class Meta: model = LocationSet fields = '__all__' views.py class ItemViewSet(ModelViewSet): queryset = Item.objects.all() serializer_class = ItemSerializer filter_backends = [SearchFilter, OrderingFilter] search_fields = ['description'] # … -
Django Error (unsupported operand type(s) for +: 'float' and 'NoneType')
I'm facing an issue of unsupported operand type(s) for +: 'float' and 'NoneType' actually I want to sum two different database column value in specific date range and one column has no value in this specific date range and that's why I'm facing that issue can anyone one help me One more thing help me to solve this in simple ways because I have many more arguments like that and if I use condition to make that value to zero that will be difficult for me the date range(modified6, modified5) is correct, if it contain a value, it display the number cell = Celldetail.objects.filter(DatePur__range=[modified6, modified5]).aggregate(Sum('Cell_price'))['Cell_price__sum'] bms = BMSdetail.objects.filter(DatePur__range=[modified6, modified5]).aggregate(Sum('BMS_price'))['BMS_price__sum'] -
Encrypt message field in django & render it on React after decrypting
i'm cloning a Whatsapp app as my personal project. i'm using React as my Frontend & Django as my backend. i'm using MongoDB to store my data & using django Rest framework to fetch it on frontend(i don't know how to retrieve it from MongoDB directly so if let me know if you can. it'll help me a lot). since it's personal messages, even logged in users shouldn't access to others messages but i can't hide them from others so i wan't to encrypt the data while storing it on backend & want to retrieve it by decrypting on frontend using React. i know a few libraries that Django has to encrypt a field but how can i decrypt it on the frontend??? #model.py from email import message from tkinter import Image from django.db import models from django.contrib.auth.models import User from django.dispatch import receiver # Create your models here. class Room(models.Model): name = models.CharField(max_length=100,blank=True,null=True) def __str__(self): return self.name class Message(models.Model): user = models.ForeignKey(User,on_delete=models.CASCADE,blank=False,null=True) message = models.TextField(max_length=500,blank=False,null=True) name = models.CharField(max_length=100,blank=True,null=True) room = models.ForeignKey(Room,on_delete=models.CASCADE,null=True) time = models.DateTimeField(auto_now_add=True) received = models.BooleanField(default=False,null=True) views.py from rest_framework.response import Response from django.http import HttpResponse from rest_framework.decorators import api_view from App.models import * from .serializers import messageSerializer, roomSerializer … -
django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)")
the ERROR above I became in the tutorial lesson 'The Ultimate Django 3' of Mosh Hamedani. Lesson part: Running Background Tasks, 5-Celery and Windows. If you followed the pdf instruction and got no error, and lastly you had to run 'python manage.py migrate', maybe you got ERROR above. I wanna share the solution here and it`s so simple ). I am grateful to nicholas.allarick, it was his solution in codewithmosh forum. -
drf viewset method error : TypeError: Field 'id' expected a number but got <Item: ```>
I tried to make method that shows item by region. so, wrote this method code. but arise error like this. TypeError: Field 'id' expected a number but got <Item: 애니원모어 원피스입니다!>. [13/Aug/2022 15:01:07] "GET /item_post/location/location_item/ HTTP/1.1" 500 152955 I think filtering is works. but to fix error, I don't know what sholud i do. please help me... models.py class Item(models.Model): user_id = models.ForeignKey(User, related_name='item_sets', on_delete=models.CASCADE) category_id = models.ForeignKey(Category, related_name='item_sets', on_delete=models.DO_NOTHING) description = models.TextField() feature = models.TextField() product_defect = models.TextField() size = models.CharField(max_length=6) wear_count = models.IntegerField() price = models.IntegerField() created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.description class Location(models.Model): city = models.CharField(max_length=10) gu = models.CharField(max_length=10) dong = models.CharField(max_length=10) def __str__(self): return self.city+" "+self.gu+" "+self.dong class LocationSet(models.Model): item_id = models.ForeignKey(Item, on_delete=models.CASCADE, related_name='location_sets') location_id = models.ForeignKey(Location, on_delete=models.CASCADE, related_name='location_sets') serializers.py class ItemSerializer(serializers.ModelSerializer): photos = PhotoSerializer(source='photo_sets', many=True, read_only=True) style_photos = StylePhotoSerializer(source='style_photo_sets', many=True, read_only=True) class Meta: model = Item fields = '__all__' class LocationSerializer(serializers.ModelSerializer): class Meta: model = Location fields = '__all__' class LocationSetSerializer(serializers.ModelSerializer): class Meta: model = LocationSet fields = '__all__' views.py class LocationViewSet(ModelViewSet): queryset = Location.objects.all() serializer_class = LocationSerializer # 지역별 아이템 조회 @action(detail=False, methods=['GET']) def location_item(self, request): locations = Location.objects.all() city = request.GET.get('city', None) # 시는 한개 gu = request.GET.getlist('gu', None) … -
AttributeError: 'Manager' object has no attribute 'Raw' , raw queryset(RawQuerySet) - Python, Django
Hey guys i was getting AttributeError: 'Manager' object has no attribute 'Raw' -
Login/Register feature not working on Deployed website
I have deployed the website by following all the steps in the video. But in the deployed site, I'm not able to register or login. Getting this error in the console. enter image description here I have used Next.js for the frontend and Django for the backend. Backend is deployed using Heroku CLI. And I've used Postgres for the database. -
Will google translate free api work when working on production website?
Will Google translator function work when hosting it in a live website, or there are any chances it will stop it services if google detects traffic. I am talking about the free translator function that we use in python. What are the chances? -
Adding a tag to a pagination element django
When creating a pagination, everything works as it should. Added (?page= page number selection) pagination. How can I add the pagination page number to its object? When selecting an object and reloading the page, I need it to be spelled out in the URL (/?page=pagination number). And the pagination remained on the selected page. class MovieShow(DetailView): model = Movie template_name = 'movies/movie_play.html' context_object_name = 'movie' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['object_list'] = Movie.objects.filter(course__slug=self.kwargs['course_slug']) context['title'] = context['movie'] paginator = Paginator(context['object_list'], 1) page = self.request.GET.get('page') try: context['object_list'] = paginator.page(page) except PageNotAnInteger: context['object_list'] = paginator.page(1) except EmptyPage: context['object_list'] = paginator.page(paginator.num_pages) return context This is how I present pagination in the template <div class="pagination" id="pagination"> <span class="step-links" > {% if object_list.has_previous %} <a class="page-link" href="?page=1"> << </a> <a class="page-link" href="?page={{ object_list.previous_page_number }}"> < </a> {% endif %} <span class="current"> {{ object_list.number }} из {{ object_list.paginator.num_pages }} </span> {% if object_list.has_next %} <a class="page-link" href="?page={{ object_list.next_page_number }}"> > </a> <a class="page-link" href="?page={{ object_list.paginator.num_pages }}"> >> </a> {% endif %} </span> And so I have a search of the elements inside the pagination, on which I want to hang the pagination page number. I really hope I asked the question correctly. I will be glad … -
I am not sure why I am getting an attributeError
So I have been using locust for stress testing my python programs. I attempted to do a post request using the client class, but for some reason I keep getting this error. this error occurs every time I try to make a most request by calling the register link -
Fetch files from outside of SvelteKit project directory
I'm fetching data, including media file links, from a Django API. Project structure as follows: -backend (Django) -core -media -frontend (SvelteKit) -src -lib -node_modules Both apps are running on different ports and I can't figure out how to access the files inside of backend/core/media from SvelteKit after fetching the link. The media link I'm receiving by my API would be something like this: /media/images/user1/image.jpg Thanks in advance! -
Django Uploading an image from form and displaying that image without refreshing the page
For my project I am trying to make a post through ajax by prompting the user to fill out a form with an animal type, img upload, and description. Right now when the user fills out all 3 fields and submits the post, the animal type and description shows up in the admin page but the image file does not and it is also not uploaded to the /images/ file as specified within my model code. class Post(models.Model): BISON = 'Bison' WOLF = 'Wolf' ELK = 'Elk' BLACKBEAR = 'Black Bear' GRIZZLY = 'Grizzly Bear' MOOSE = 'Moose' MOUNTAINLION = 'Mountain Lion' COYOTE = 'Coyote' PRONGHORN = 'Pronghorn' BIGHORNSHEEP = 'Bighorn Sheep' BALDEAGLE = 'Bald Eagle' BOBCAT = 'Bobcat' REDFOX = 'Red Fox' TRUMPETERSWAN = 'Trumpeter Swan' YELLOWBELLIEDMARMOT = 'Yellow-bellied Marmot' RIVEROTTER = 'River Otter' LYNX = 'Lynx' SHREW = 'Shrew' PIKA = 'Pika' SQUIRREL = 'Squirrel' MULEDEER = 'Mule Deer' SANDHILLCRANE = 'Sandhill Crane' FLYINGSQUIRREL = 'Flying Squirrel' UINTAGROUNDSQUIRREL = 'Uinta Ground Squirrel' MONTANEVOLE = 'Montane Vole' EASTERNMEADOWVOLE = 'Eastern Meadow Vole' BUSHYTAILEDWOODRAT = 'Bushy-tailed Woodrat' CHIPMUNK = 'Chipmunk' UINTACHIPMUNK = 'Uinta Chipmunk' WHITETAILEDJACKRABBIT = 'White-tailed Jackrabbit' BEAVER = 'Beaver' AMERICANMARTEN = 'American Marten' MOUNTAINCHICKADEE = 'Mountain Chickadee' BOREALCHORUSFROG … -
HTML Calendar Appearing Under Footer
I've created an HTML Calendar for my django app. However when I add it to one of my templates it adds it underneath my footer. I'm not understanding why this would happen. {% extends "bf_app/app_bases/app_base.html" %} {% block main %} {% include "bf_app/overviews/overview_nav.html" %} <div class="flex justify-between mx-10"> <a href="{% url 'calendar_overview_context' previous_year previous_month %}">< {{ previous_month_name }}</a> <a href="{% url 'calendar_overview_context' next_year next_month %}">{{ next_month_name }} ></a> </div> <div class="grid grid-cols-1 md:grid-cols-3 px-4"> <table> <thead> <tr> <th class="text-left">Transaction</th> <th class="text-left">Amount</th> <th class="text-left">Date</th> </tr> </thead> {% for transaction, tally in monthly_budget.items %} <tr> <td>{{ transaction }}</td> <td class="{% if tally|last == "IN" %}text-green-700{% else %}text-red-700{% endif %}"> {{ tally|first|floatformat:2 }} </td> <td>{{ transaction.next_date|date:"D, d M, Y" }}</td> </tr> {% endfor %} </table> </div> <div> {{ calendar }} </div> {% endblock %} I pretty much followed this tutorial: https://www.huiwenteo.com/normal/2018/07/24/django-calendar.html Is there something I'm missing? This to my understanding should be above the footer like everything else I've created. -
How to sort Django's list_display of a function using admin_order_field?
class ProductAdmin(admin.ModelAdmin): def got_inactive_variation(self, obj): res = obj.active_variation.__func__(obj) var_list = [i for i in res] active_list = [] for i in var_list: active_list.append(i.is_active) if False in active_list: return 'Yes' else: return 'No' got_inactive_variation.admin_order_field = "???" got_inactive_variation.short_description = 'Got Inactive Variation' list_display = ( 'product_name', 'product_description', 'price', 'stock', 'is_available', 'category', 'created_date', 'sku', 'got_inactive_variation') As the code above, I want to be able to sort the got_inactive_variation, but what should I put in the right side of admin_order_field? -
Django form_valid not passing params to CreateView
In my django project, I'm trying create a 'submit post' page using CreateView. It works, but with a dropdown menu for the author of the post. I would like to have the author automatically added to the post. According to the (documentation)[https://docs.djangoproject.com/en/4.1/topics/class-based-views/generic-editing/], I should use a form_valid method to add the author to the form. This does not work, even though it's copied directly from the documentation. I've tried adding 'author' to the fields in the PostCreate class, and that only adds the author dropdown box to the form. Views.py: class PostCreate(LoginRequiredMixin, CreateView): model = Post fields = ['image', 'description'] success_url = '/' template_name: 'post_form.html' def form_valid(self, form): self.author = self.request.user return super().form_valid(form) changing to self.author = self.request.user.pk does not work, either. Models.py: class Post(models.Model): image = models.ImageField() description = models.TextField(null=True ) author = models.ForeignKey(User, on_delete=models.CASCADE) when looking at the debug error, I can see the author param is not passed, resulting in a NOT NULL constraint failed. -
Complex Django search engine
I want my Django search engine to be able to handle typos on the title of the item I would display. For example if the user does the search 'stacoverflow' I would search for 'stackoverflow'. I would then apply other filters I already have and could display the results. What would be the best way to do this and how could I do it? Consider some specific strings and then change their values, how? My Models: class Product(models.Model): author = models.ForeignKey(User, default=None, on_delete=models.CASCADE) category = models.ForeignKey(Category, default=None, on_delete=models.PROTECT) title = models.CharField(max_length=120, unique=True) # ... My views: def is_valid_queryparam(param): return param != '' and param is not None def FilterView(request): qs = Product.objects.all() categories = Category.objects.all() title_contains_query = request.GET.get('title_contains') id_exact_query = request.GET.get('title_exact') title_or_author_query = request.GET.get('title_or_author') view_count_min = request.GET.get('view_count_min') view_count_max = request.GET.get('view_count_max') date_min = request.GET.get('date_min') date_max = request.GET.get('date_max') category = request.GET.get('category') if is_valid_queryparam(title_contains_query): qs = qs.filter(title__icontains=title_contains_query) elif is_valid_queryparam(id_exact_query): qs = qs.filter(id=id_exact_query) elif is_valid_queryparam(title_or_author_query): qs = qs.filter(Q(title__icontains=title_or_author_query) | Q(author__username__icontains=title_or_author_query)).distinct() #... if is_valid_queryparam(category) and category != 'Choose...': qs = qs.filter(category__name=category) context = { 'queryset': qs, 'categories': categories } return render(request, 'search/filter_form.html', context) My templates: <form method="GET" action="."> <div> <input type="search" placeholder="Title contains..." name="title_contains"> </div> <div> <input type="search" placeholder="ID exact..." name="id_exact"/> </div> <div> <input type="search" … -
flush=True - Not working most of the time
so I thought that the flush=True function will force the print function to print information, however, most of the time it doesn't work. I'm using Django and I'm always going to the route, which contains these print functions, that are supposed to return the print function but nothings prints out.. any ideas? An example: def jsonresponse2(request, username): if request.method == 'GET': username = request.session['_auth_user_id'] Current_User = User.objects.get(id=username) #List of who this user follows followingList = Follower.objects.filter(follower=int(Current_User.id)) UsersInfo = [] for user in followingList: singleUser = User.objects.filter(username=user.following).values( 'username','bio', 'profile_image','id') print(f'This is singleUser {singleUser}',flush=True) UsersInfo += singleUser print(f'This is UsersInfo {UsersInfo}',flush=True) else: return JsonResponse({'Error':'Method Not Allowed!'}) return JsonResponse({'UsersInfo':list(UsersInfo)}) -
Django-leaflet: map getBounds returning [object Object]
I am using django-leaflet to display a map in a template, where the goal is to only display the coordinates of the visible area of the map when the user moves the map. For this I'm using the getBounds() method, but the function only returns [Object Object]. template.html: {% load leaflet_tags %} {% block extra_head %} {% leaflet_js %} {% leaflet_css %} {% endblock %} {% block body %} {% leaflet_map "extent" callback="map_init" %} {% endblock %} {% block extra_script %} <script> function map_init (map, options) { map.on('moveend', function() { alert(map.getBounds()); }); } </script> {% endblock %} Why is not showing the coordinates? -
No module named 'debug_toolbarnews'
I did the following to install django-debug-toolbars pip install django-debug-toolbar added to middleware classes: 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', "debug_toolbar.middleware.DebugToolbarMiddleware" ] Added INTERNAL_IPS: INTERNAL_IPS = [ "127.0.0.1", ] 4.Added debug_toolbar to installed apps Code in urls: urlpatterns = [ path('',include('news.urls')), path('admin/', admin.site.urls), ] if settings.DEBUG: urlpatterns = [ path('__debug__/', include('debug_toolbar.urls')) ] + urlpatterns i am getting "No module named 'debug_toolbarnews'" errors