Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Using dal for AutocompleteFilter admin filter
I have a Category model which has a field that is self recursive to indicate parent Category. and I want to have an Autocomplete filter in the admin site where I can filter child categories that belong to the same parent. How can I used the module AutocompleteFilter from dal_admin_filters. this is my Model: class Category(models.Model): name = models.CharField(max_length=100) parent = models.ForeignKey( "self", on_delete=models.CASCADE, null=True, blank=True, related_name="childs" ) description = models.TextField(null=True, blank=True) picture = models.ImageField(null=True, blank=True) is_active = models.BooleanField(default=True) ordering = models.PositiveIntegerField(default=0) the model is registred in the admin.py : class CategoryAdmin(SortableAdminMixin, TranslationAdmin, admin.ModelAdmin): search_fields = ["name"] fieldsets = ( ( _("Details"), { "fields": ( "name", "parent", "description", "picture", ), }, ), ) list_display = ( "ordering", "name", "parent", ) readonly_fields = ("display_picture",) admin.site.register(Category, CategoryAdmin) -
Django + React + Redux Axios instance header conflict?
I have all my functions based views on django protected with @permission_classes([IsAuthenticated]) so I have to send a JWT as Bearer token on every request. In the first version I was using this code: import axios from 'axios'; import { decodeUserJWT } from '../../extras' const user = JSON.parse(localStorage.getItem("user")); var decoded = decodeUserJWT(user.access); var user_id = decoded.user_id const instance = axios.create({ baseURL: 'http://localhost:8000/api', headers: {Authorization: 'Bearer ' + user.access}, params: {userAuth: user_id} }); export default instance; Everything was working fine. But then I added interceptors so I could handle the refreshToken process: const setup = (store) => { axiosInstance.interceptors.request.use( (config) => { const token = TokenService.getLocalAccessToken(); if (token) { // const uid = await decodeUserJWT(token); config.headers["Authorization"] = 'Bearer ' + token; // config.headers["userAuth"] = uid; } return config; }, (error) => { return Promise.reject(error); } ); const { dispatch } = store; axiosInstance.interceptors.response.use( (res) => { return res; }, async (err) => { const originalConfig = err.config; if (originalConfig.url !== "/auth/token/obtain/" && err.response) { console.log("TOKEN INTERCEPTOR"); // Access Token was expired if (err.response.status === 401 && !originalConfig._retry) { originalConfig._retry = true; try { const rs = await axiosInstance.post("/auth/token/refresh/", { refresh: TokenService.getLocalRefreshToken(), }); const { access } = rs.data; dispatch(refreshToken(access)); TokenService.updateLocalAccessToken(access); return … -
django celery error: AttributeError: 'EntryPoint' object has no attribute 'module_name'
i am extremely new to django-celery, its doc have been confusing to me and i have been following tutorial, here is just a basic setup and i have encountered a untrackable error for me, the error is: AttributeError: 'EntryPoint' object has no attribute 'module_name' full traceback: Traceback (most recent call last): File "/home/muhammad/Desktop/celery/env/lib/python3.8/site-packages/celery/app/base.py", line 1250, in backend return self._local.backend AttributeError: '_thread._local' object has no attribute 'backend' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/muhammad/Desktop/celery/env/lib/python3.8/site-packages/celery/worker/worker.py", line 203, in start self.blueprint.start(self) File "/home/muhammad/Desktop/celery/env/lib/python3.8/site-packages/celery/bootsteps.py", line 112, in start self.on_start() File "/home/muhammad/Desktop/celery/env/lib/python3.8/site-packages/celery/apps/worker.py", line 136, in on_start self.emit_banner() File "/home/muhammad/Desktop/celery/env/lib/python3.8/site-packages/celery/apps/worker.py", line 170, in emit_banner ' \n', self.startup_info(artlines=not use_image))), File "/home/muhammad/Desktop/celery/env/lib/python3.8/site-packages/celery/apps/worker.py", line 232, in startup_info results=self.app.backend.as_uri(), File "/home/muhammad/Desktop/celery/env/lib/python3.8/site-packages/celery/app/base.py", line 1252, in backend self._local.backend = new_backend = self._get_backend() File "/home/muhammad/Desktop/celery/env/lib/python3.8/site-packages/celery/app/base.py", line 955, in _get_backend backend, url = backends.by_url( File "/home/muhammad/Desktop/celery/env/lib/python3.8/site-packages/celery/app/backends.py", line 69, in by_url return by_name(backend, loader), url File "/home/muhammad/Desktop/celery/env/lib/python3.8/site-packages/celery/app/backends.py", line 47, in by_name aliases.update(load_extension_class_names(extension_namespace)) File "/home/muhammad/Desktop/celery/env/lib/python3.8/site-packages/celery/utils/imports.py", line 146, in load_extension_class_names yield ep.name, ':'.join([ep.module_name, ep.attrs[0]]) AttributeError: 'EntryPoint' object has no attribute 'module_name' the celery.py, init.py and and task are just the basic: init.py: from __future__ import absolute_import, unicode_literals from .celery import app as celery_app __all__ = ('celery_app',) celery.py: from … -
ValueError at /admin
The view main.views.single_slug didn't return an HttpResponse object. It returned None instead. def single_slug(request, single_slug): categories = [c.category_slug for c in TutorialCategory.objects.all()] if single_slug in categories: matching_series = TutorialSeries.objects.filter(tutorial_category__category_slug=single_slug) series_urls = {} for m in matching_series.all(): part_one = Tutorial.objects.filter(tutorial_series__tutorial_series=m.tutorial_series).earliest("tutorial_published") series_urls[m] = part_one.tutorial_slug return render(request=request, template_name='main/category.html', context={"tutorial_series": matching_series, "part_ones": series_urls}) tutorials = [t.tutorial_slug for t in Tutorial.objects.all()] if single_slug in tutorials: this_tutorial = Tutorial.objects.get(tutorial_slug=single_slug) tutorials_from_series = Tutorial.objects.filter(tutorial_series__tutorial_series=this_tutorial.tutorial_series).order_by('tutorial_published') this_tutorial_idx = list(tutorials_from_series).index(this_tutorial) return render(request, 'main/tutorial.html', context={"tutorial": this_tutorial, "sidebar": tutorials_from_series, "this_tut_idx": this_tutorial_idx}) I have tried all the solutions I can find, but couldn't find any solution. Before writing this block of code I can access admin panel of website, but right now I am getting The view main.views.single_slug didn't return an HttpResponse object. It returned None instead. error I have looked on my code if I didn't returned any render but that was not the case, I also applied migrations but that also couldn't solve my problem, so I don't know what is the problem -
Django - Is there a way to send extra information to an exception handling middleware?
In Django, an exception handling middleware is a middleware which overrides the process_exception(request, exception) function. I was writting a middleware and would like to send extra information to this middleware. More specifically, my intention is to filter sensitive data, since I am implementing this middleware in order to log uncatched exceptions (I am not using the usual python logging) and send notification by email. The error reporting of Django does not seems to fit my needs, since I could not get the request body. However, I would like to create something like the @sensitive_variables or @sensitive_post_parameters decorators to send this extra information to my middleware. I implemented a filter on my middleware class to filter common sensitive data, such as password. I also took a look at Django's ExceptionReporter but it does not seem to fit my needs. Some helpful links: Django error reporting documentation Django Middleware documentation -
How to get all the objects in the database Django related to text field id using search engine , search not displaying anything
I have model called Item that takes images,patient id(textfield), image id(pk). I want to search by the patient id and get all the database related to this patient id note: i have multiple objects related to patient id not only one object Example : Name patient id (text) info like : images, date, imageid steve 18181 info 1 steve 18181 info2 senerio: i have search box that i should write in it patient id then it searches the database and get all the objects that have the same patient id with their info. the problem is I tried many times to achieve this but every time no results the page is empty no data is shown I tried Item.object.filter(), prefect, select_related, contains and icontains all the same result Models.py class Item(models.Model): Name = models.TextField(max_length=191) category = models.TextField(max_length=50) Date = models.TextField(max_length=500, null=False) image = models.ImageField(upload_to=user_directory_path, null=True, blank=True) patientid= models.TextField() imageid=models.BigAutoField(primary_key=True) Index.html <div> <br><br><br><br> <div class="flex-container text-center"> <form method="GET" value="{{request.GET.s}}"> <input type="text" name="s" size="80" value="{{ request.GET.s }}" placeholder="Search "/> <i class="fa fa-search" style="color: #5e9e9f;"><input style="background-color: #5e9e9f;" type="submit" name="submit" value="search"/></i> </form> </div> <div> {% if submit == 's' and request.GET.s != '' %} {% if context %} <br> {% for received_memo in context … -
How to log out of the previous logged in user in Django
I have a question, probably very session related. What if we log on to user1 and someone from another computer logs on to the same user1, can you set it by some global variable to immediately log out what was previously logged in to it? I've seen the Django User Sessions library, but won't use it. -
Cannot connect to Postgres docker container from Django container
services: db: image: postgres volumes: - ./data/db:/var/lib/postgresql/data environment: - POSTGRES_DB=psg - POSTGRES_USER=psg - POSTGRES_PASSWORD=psg ports: - "5432:5432" backend: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - "8000:8000" environment: - POSTGRES_NAME=psg - POSTGRES_USER=psg - POSTGRES_PASSWORD=psg depends_on: - db This is the docker config. The issue is backend(Django) is not able to connect to the postgres DB. I tried with DB host as localhost and it was not able to connect. could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? Then I changed host to the ip address of the db container but still no success, this time it was a timeout error. could not connect to server: Connection timed out Is the server running on host "172.11.0.2" and accepting TCP/IP connections on port 5432? Could someone help me on how to connect to Postgres container from Django's container? -
issue with saving search term to database
I'd like to save everything that users search through my search bar. I have a function that handles that properly but when I try to save it I just get the date and time of searched term. Other columns are NULL or 0(only in total_searches column). models.py class SearchQueryTracker(models.Model): id = models.AutoField(primary_key=True) user_email = models.ForeignKey(User, blank=True, null=True) total_searches = models.IntegerField(default=0) search_term = models.CharField(max_length=1000, blank=True, null=True) searched_on = models.DateTimeField('searched on', default=timezone.now) def __str__(self): return str(self.search_term) views.py @login_required def SearchViewFBV(request): query = request.GET.get('q') query_list = request.GET.get('q', None).split() query_list_count = len(query_list) search_tracker = SearchQueryTracker() if query_list is not None: search_tracker.save() article_list = Article.objects.filter(status=1).order_by('-publish') video_list = Video.objects.filter(status=1).order_by('-publish') queryset_chain = chain( article_list, video_list ) qs = sorted(queryset_chain, key=lambda instance: instance.pk, reverse=True) count = len(qs) context = { 'query': query, 'count': count, 'query_list': qs, } return render(request, 'search/search_items.html', context) QUESTION Basically, I want to pass query_list_count, query variables as well as time (searched_on column) and user email(user_email column) and save these data to the SearchQueryTracker database. -
Django and Ajax: django url is the loading in the console, but the view function is not working
Basically, i am encounting the similar probleb like here: django url is loading in the console ,but the function in the view is not working, but I still cant find the solution. Views.py (handler.py) def delete(request, project_id): fid = request.GET.get('fid', '') print("------------------", fid) Handler.objects.filter(id=fid, project_id=project_id).delete() return JsonResponse({'status': True}) def barchart_handler(request, project_id): """ get the total amount of schrotte and 'legierungen' for every handler """ # calculate the total amount of schrotte for every handler model_list = [Schnellstahlschrott_kobaltfrei, Tiefzieh_stanzabfaelle, Schnellstahlschrott_kobaltlegiert, Cr_17_Or_Cr_13, Cr_Ni_Schrott, Kaltarbeitsstahl, Warmarbeitsstahl, Cr_Ni_148xx] masse_sum_list = [] firma_name_list = [] for index, model in enumerate(model_list): # calculate the total amount of schrotte for every handler menge_sum = model.objects.values_list('spezifikation__handler__name').annotate(menge_masse_sum=Sum('Menge')) firma_name_list = [item[0] for item in menge_sum] masse_list = [float(item[1]) for item in menge_sum] masse_sum_list.append(masse_list) df = pd.DataFrame(masse_sum_list, columns=firma_name_list) df.loc['Total', :] = df.sum(axis=0) total_sum = df.loc['Total', :].values.tolist() if len(total_sum) > 0: context = { "status": True, "data": { "firma_name_list": firma_name_list, "total_sum": total_sum, } } return JsonResponse(context) else: return JsonResponse({'status': False, 'errors': 'No data found'}) html template and javascript code: {% extends 'layout/manage.html' %} {% load static %} {% block title %}Dashboard{% endblock %} {% block content %} <div class="container-fluid"> <div class="row head"> <div class="col-md-8"> <div class="card"> <div class="card-header"> <i class="fa-solid fa-chart-area"></i> Händler … -
How to sort finding index of the similar variable [closed]
x=[a,a,a,b,b,c,a] I want to get a=3,b=2,c=1,a=1 as per the contatined list. -
How to assemble the variable name to use data from JSONField inside the Template in django?
I'm trying to build a website for tv series using Django framework, I put in the models.py all kinds of details about that show and a JSONField (named 'episodes') to define the number seasons and episodes in each season. Example: { "1" : 15 , "2" : 25 , "3" : 23} where season 1 contains 15 episodes, 2 contains 25 and so on the problem starts when I tried making a dropdown in the template where the series is playing so the user can select the episode to watch: This Code is working: Season 1 {% with ''|center:show.episodes.1 as range %} {% for episode in range %} Episode {{forloop.counter}} {% endfor %} {% endwhile %} Season 2 {% with ''|center:show.episodes.2 as range %} {% for episode in range %} Episode {{forloop.counter}} {% endfor %} {% endwhile %} Season 3 {% with ''|center:show.episodes.3 as range %} {% for episode in range %} Episode {{forloop.counter}} {% endfor %} {% endwhile %} But surely this can be much cleaner if I could use 2 for loops inside each others one for the seasons and one for the episodes which sounds easy but for some reason I couldn't do it. I tried: {% … -
Djoser- override perform_create method of class UserViewSet
Need to override the Djoser class UserViewSet method perform_create. I don't know how to do that can anyone help me out. Method from UserViewSet def perform_update(self, serializer): super().perform_update(serializer) user = serializer.instance signals.user_updated.send( sender=self.__class__, user=user, request=self.request ) # should we send activation email after update? if settings.SEND_ACTIVATION_EMAIL and not user.is_active: context = {"user": user} to = [get_user_email(user)] settings.EMAIL.activation(self.request, context).send(to) My URL Patterns from django.urls import URLPattern, path, re_path, include from . import views from .views import MyTokenObtainPairView, GetUser, ReviewsView, GetReviewsByUser from rest_framework_simplejwt.views import ( TokenRefreshView, ) urlpatterns = [ path('', views.getRoutes), path('api/token/', MyTokenObtainPairView.as_view(), name='token_obtain_pair'), path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), path('api/auth/', include('djoser.urls')), path('api/user/', GetUser), path('api/user/<int:pk>/', GetReviewsByUser), path('api/reviews/', ReviewsView), ] -
How to integrate Python/React projects via workflow tools?
We have a business that sells products and our sales process has several steps. Our microservices are with DRF(Django Rest Framework) and our front_end is with react. We want to dynamic(low_code) our process with workflow tools under the .bpmn standard. We searched the internet but no explanation was found satisfying. This is the last StackOverflow post that we found. No complete examples of these tools (spiffworkflow or camunda) were found. We want to keep our process logic separate from the workflow engine. (just call our microservices) Can anyone introduce a powerful resource or best practice for our purpose? -
How do i get my likes count on my facebook's page using Django?
i want to be able to login to my web application through facebook and also get the user's amount of likes from the user's facebook page. I have tried Integrating the facebook library in Django but, i was unable to get the user's page likes. -
NameError: name 'users' is not defined in python django
Hi I'm sorry if this question has been repeatedly asked but I hope that you kindly help me to figure out what is the problem here. I'm following a python crash course book that uses old versions of Django. I've set up a app called 'users' in my setting so users can make accounts of their own. INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', #my apps 'learning_logs', 'users', ] and I've included the path in my urls file: from django.contrib import admin from django.urls import path, include app_name = 'learning_logs' urlpatterns = [ path('admin/', admin.site.urls), path('users/', users.urls), path('', include('learning_logs.urls')), ] and this is the error that I get: NameError: name 'users' is not defined and if I do it like this from django.contrib import admin from django.urls import path, include app_name = 'learning_logs' urlpatterns = [ path('admin/', admin.site.urls), path('users/', include('users.urls')), path('', include('learning_logs.urls')), ] I get the following error message: ModuleNotFoundError: No module named 'users.urls' thank you so much for your time and response! -
Comment wont Submit in Django Class Based View method
class PostDetailView(HitCountDetailView): model = Post template_name = 'blog/post_detail.html' context_object_name = 'post' slug_field = 'slug' # set to True to count the hit count_hit = True def get_context_data(self, **kwargs): context = super(PostDetailView, self).get_context_data(**kwargs) context.update({ 'popular_posts': Post.objects.order_by('-hit_count_generic__hits')[:3], }) liked = False likes_connected = get_object_or_404(Post, slug=self.kwargs['slug']) if likes_connected.likes.filter(id=self.request.user.id).exists(): liked = True context['number_of_likes'] = likes_connected.number_of_likes() context['post_is_liked'] = liked post = get_object_or_404(Post,slug=self.kwargs['slug']) comments = post.comments.filter(active=True) new_comment = None if self.request.method == 'POST': comment_form = CommentForm(data=self.request.POST) if comment_form.is_valid(): # Create Comment object but don't save to database yet new_comment = comment_form.save(commit=False) # Assign the current post to the comment new_comment.post = post # Save the comment to the database new_comment.save() else: comment_form = CommentForm() context['comment_form'] = comment_form context['post'] = post context['comments'] = comments context['new_comment'] = new_comment return context {% for comment in comments %} <div class="comments" style="padding: 10px;"> <p class="font-weight-bold"> {{ comment.name }} <span class=" text-muted font-weight-normal"> {{ comment.created_on }} </span> </p> {{ comment.body | linebreaks }} </div> {% endfor %} <div class="card-body"> {% if new_comment %} <div class="alert alert-success" role="alert"> Your comment is awaiting moderation </div> {% else %} <h3>Leave a comment</h3> <form method="post" style="margin-top: 1.3em;"> {% csrf_token %} {{ comment_form|crispy }} <button type="submit" class="btn btn-primary btn-lg">Submit</button> </form> {% endif %} </div> -
Django - fetching only related foreign key in UpdateView and View
Please take a look at this setup below. The Product form shows name field and category dropdown. However, the dropdown show all the categories from all users but I need to show user's own categories only e.g. filter(user=request.user) but I don't know where to place this check (in the form or model or in view) and how. # models.py class Product(models.Model): name = models.CharField(max_length=200, null=False) category = models.ForeignKey(ProductCategory, on_delete=models.CASCADE, null=True, blank=True) user = models.ForeignKey(User, on_delete=models.CASCADE) class Category(models.Model): name = models.CharField(max_length=200, null=False) user = models.ForeignKey(User, on_delete=models.CASCADE) # forms.py class ProductForm(forms.ModelForm): class Meta: model = Product fields = ['name', 'category'] # views.py class ProductsView(View): model = Product form_class = ProductForm initial = {} template_name = "products_list.html" def get(self, request, *args, **kwargs): category_id = kwargs['category_id'] #### I need to do this check in 4 other models, could you recommend a beter way? try: # Check if user is allowed to view this category category_obj = Category.objects.filter( user=self.request.user).get(pk=category_id) except Category.DoesNotExist: return redirect('homepage') # To add a new product form form = self.form_class(initial=self.initial) # There's another form on this page to add a category form_category = ProductCategoryForm return render(request, self.template_name, {'form': form, 'form_category': form_category, 'category': category_obj}) class ProductEditView(UpdateView): model = Product form_class = ProductForm template_name … -
How to merge dictonary values with the duplicates
In Django, I have two annotated results from two different models and combined them using itertools which I got these results. Initially I was successfully manage to get all the duplicates and add their value using values().annotate(), my problem now is, from this list of dictionary, how can I achieve the result below. Basically I just want to get all the same setting_type and add their values. Example: all 'bazel' should add the carat, quantity and salary except for the rate same with 'pave'. Thanks in advance. source_dict = [ {'setting_type': 'bazel', 'rate': 45, 'carat': 10.30, 'quantity': 10, 'salary': 450}, {'setting_type': 'pave', 'rate': 30, 'carat': 10.43, 'quantity': 10, 'salary': 300}, {'setting_type': 'center', 'rate': 10, 'carat': 3.35, 'quantity': 45, 'salary': 450}, {'setting_type': 'pave','rate': 30, 'carat': 4.10, 'quantity': 23, 'salary': 690}, {'setting_type': 'bazel', 'rate': 45, 'carat': 31.10, 'quantity': 50, 'salary': 2250} ] Derired Result: desired_result[ {'setting_type': 'bazel', 'rate': 45, 'carat': 41.40, 'quantity': 60, 'salary': 2700}, {'setting_type': 'pave', 'rate': 30, 'carat': 14.53, 'quantity': 33, 'salary': 990}, {'setting_type': 'center', 'rate': 10, 'carat': 3.35, 'quantity': 45, 'salary': 450} ] -
Query list index with django
i have a problem with django when i use these two arrays: institution_ids [(2,), (16,)] project_ids [(3,), (1,)] in this query: queryset = Patient.active.filter(tss_id__in=institution_ids, project_id__in = project_ids) it gives me back all the combinations, but I need this kind of result: queryset = Patient.active.filter(tss_id=institution_ids[0], project_id = project_ids[0]) queryset += Patient.active.filter(tss_id=institution_ids[1], project_id = project_ids[1]) how can i do? Thanks Giuseppe -
One big model vs small models with Foreign key relation - Django
Sorry for asking a silly question but I'm not able to figure out what should I use here. Also, I'm a noob into this. The database is a sort of profile page something like Wikipedia of a sports player in-general. Fields type 1 like name, team, DOB, role, country, total winnings, player of the match (times), and all these basic Char and Int fields. Fields type 2: Early Life, Career history, net worth, match history, and all these fields that requires Text-field (each one in a separate field of its own for re-usability in other places). And there are tens of fields including char and text for 1 person. And some of these fields like Career history, etc are going to have their own separate page. Approach 1: Keep all fields in one model (looking at admin page, it's very hard to manage and painful to even look at, performance good for a single profile page but am I wasting any resources when a page need only a set of fields in a page like name and career history. Also, on archive pages where only 10-20 people are going to display with just name and image). Approach 2: Create small … -
Data visualisation Platfrom
Good day, I'm very new to data visualisation and I was wondering If I can get guidance with what back-end and front-end languages will be best to achieve the following: We have data stored in Amazon S3 and we want to visualise this data with graphs on a web platform, we want to use Python as the main language. What I understand from researching are the following: Data in AWS-S3 will be transferred via Athena and Boto3 to the backend of Django, and then from the Django Database (Backend) it will be pulled into the website interface via React.js and displayed as graphs with help from JS Libraries such as react.vis, fusioncharts, reaviz. Are there any other languages that I should look into or I'm I on the right path? Thanks I've did research on Python and Django -
How to set base URL in Django 3.2.5
I would like to run Django from location https://www.example.com/abc/ so that I have the admin interface at https://www.example.com/abc/admin/. And web app login interface at https://www.example.com/abc/ Where can I set the base URL of Django to https://www.example.com/abc/? Django Version=3.2.5 Tried path('abc/', views.getLogin, name="Login Page"), path('abc/login', views.handeLogin, name="handleLogin"), But these are not working, while b below admin path is working fine. path('abc/admin/', admin.site.urls), -
Why dont I see the Comment form on my page
View Method: if self.request.method == 'POST': comment_form = CommentForm(data=self.request.POST) if comment_form.is_valid(): # Create Comment object but don't save to database yet new_comment = comment_form.save(commit=False) # Assign the current post to the comment new_comment.post = post # Save the comment to the database new_comment.save() comment_form = CommentForm() context['comment_form'] = comment_form context['post'] = post context['comments'] = comments context['new_comment'] = new_comment return context Template: {% for comment in comments %} <div class="comments" style="padding: 10px;"> <p class="font-weight-bold"> {{ comment.name }} <span class=" text-muted font-weight-normal"> {{ comment.created_on }} </span> </p> {{ comment.body | linebreaks }} </div> {% endfor %} <div class="card-body"> {% if new_comment %} <div class="alert alert-success" role="alert"> Your comment is awaiting moderation </div> {% else %} <h3>Leave a comment</h3> <form method="post" style="margin-top: 1.3em;"> {% csrf_token %} {{ comment_form.as_p }} <button type="submit" class="btn btn-primary btn-lg">Submit</button> </form> {% endif %} </div> -
Problem while profiling queries with django query profiler
question regarding django query profiler, https://github.com/django-query-profiler, When I add logs as shown, the duplicate query count is increased as shown below: While if I remove my logs, the duplicate count is decreased. I am not sure why is this happening as the log should have no effect on query count. question regarding django query profiler, https://github.com/django-query-profiler, When I add logs as shown, the duplicate query count is increased as shown below: While if I remove my logs, the duplicate count is decreased. I am not sure why is this happening as the log should have no effect on query count.