Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
template tag is not working djaongo framework
I am currently working with Django framework and I am facing an issue with the template tag {{msg}}. It seems to not work when used within block comments. ` # views.py from django.shortcuts import render from django.http import HttpResponse # Create your views here. def projects(request): msg ='hello,you are on the projects page' return render(request,'my_project_1_app/my_project.html',{'msg':msg}) def project(request,pk): return render(request,'my_project_1_app/single_project.html') ` ` {% comment %} my_project.html {% endcomment %} {% extends 'main.html'%} {% block content%} {{msg}} <h1> my_project templates</h1> <p>hello iam from paragrap in my_project.html</p> {% endblock content%} `` Here is an example of how I am using it: {# Some comment #} {{msg}} But the {{msg}} tag is not rendering anything. Is there a way to make it work within block comments? -
have some issue in my script but not able to debug oit
i am implementing the auto complete search bar in my django project and below is my script for showing the suggestion the renderList function is not working. render result is working. i want showing data on front end for that my renderList function need to work but somehow it is not working.becz there is the format in which the data will be displayed. <div class="header-right"> <form action="{% url 'Search' %}"> <div id="mobile-autocomplete" class="autocomplete"> <input class="autocomplete-input" name="query" placeholder="Search" /> <ul class="autocomplete-result-list autocomplete-result- list-mobile" style="padding: 10px; max-height:842px;"></ul><hr> </div> </form> <script> new Autocomplete('#mobile-autocomplete', { search: input => { const url = `{% url 'search_address'%}?query=${input}`; return new Promise(resolve => { fetch(url) .then(response => response.json()) .then(data => { resolve(data.data || []); }) .catch(error => { console.error('Error fetching autocomplete results:', error); resolve([]); }); }); }, onSubmit: result => { const words = result.split(' '); const query = words.join(' '); window.location.assign(`/Search?query=${query}`); }, renderResult: (result, props) => { console.log('Rendering result:', result); const { name, image, url } = result; const item = document.createElement('div'); item.classList.add('autocomplete-item'); const imageContainer = document.createElement('div'); imageContainer.classList.add('autocomplete-image'); const img = document.createElement('img'); img.src = image; img.alt = name; imageContainer.appendChild(img); const nameContainer = document.createElement('div'); nameContainer.classList.add('autocomplete-name'); const link = document.createElement('a'); link.href = url; link.textContent = name; nameContainer.appendChild(link); item.appendChild(imageContainer); item.appendChild(nameContainer); … -
How can I conditionally pass a value to a with variable in Django template?
I'm looking to pass a value to a variable based on a condition in my code. Here's the pseudo code of what I'm trying to achieve: {% include "includes/template.html" with info=if condition: a else: b %} I'm wondering how I can accomplish this. Any suggestions or guidance would be greatly appreciated! -
While creating reviews getting error "Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x1032d5660>."
Here is my views.py code to create reviews for a movie: class ReviewCreate(generics.CreateAPIView): serializer_class = ReviewSerializer def get_queryset(self): return Review.objects.all() def perform_create(self, serializer): pk = self.kwargs.get('pk') watchlist_movie = watchlist.objects.get(pk=pk) review_user = self.request.user review_queryset = Review.objects.filter(watchlist=watchlist_movie, review_user=review_user) if review_queryset.exists(): raise ValidationError('You have already reviewed this movie.') if watchlist.number_ratings == 0: watchlist.avg_rating = serializer.validated_data['rating'] else: watchlist.avg_rating = (watchlist.avg_rating + serializer.validated_data['rating']) / 2 watchlist.number_ratings += 1 watchlist.save() serializer.save(watchlist=watchlist_movie, review_user=review_user) Here is my urls.py patterns: urlpatterns = [ path('list/', WatchList.as_view(), name='watchlist'), path('<int:pk>/', WatchListDetail.as_view(), name='watchlist-detail'), path('stream/', StreamPlatform.as_view(), name='streamplatform'), path('stream/<int:pk>/', StreamPlatformDetail.as_view(), name='streamplatform-detail'), path('<int:pk>/review-create/', ReviewCreate.as_view(), name='review-create'), path('<int:pk>/reviews/', ReviewList.as_view(), name='review-list'), path('review/<int:pk>/', ReviewDetail.as_view(), name='review-detail'), ] And my serializer file code for review serializer: class ReviewSerializer(serializers.ModelSerializer): review_user = serializers.StringRelatedField(read_only=True) class Meta: model = Review exclude = ('watchlist',) The code is intended to allow users to submit reviews for movies. However, the original code contained some errors, which I have corrected. I've also added indentation, formatted the code blocks, and included the appropriate markdown. -
in my new Django project my html file isn't rendering
When I have my index.html file inside the template folder alone, it renders fine. However, when I put my app name as a folder inside of the template folder, the page doesn't render. I am sure the file path is correct, and the html file is correct except for one line of h1. urls.py (entire project level) from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('', include('students.urls')), ] urls.py (students app level) from django.urls import path from . import views urlpatterns = [ path('', views.index, name='index'), ] views.py (students app level) from django.shortcuts import render def index(request): return render(request, 'students/index.html') -
Best practices for architecting a multi-tenancy web application on Azure
I am working on designing a multi-tenancy web application on Azure and I would like some guidance on the best architectural practices. I want to ensure scalability, security, cost-effective, and efficient resource utilization while accommodating multiple tenants on the same infrastructure. Here are some specific areas I'm looking for advice on: Tenant isolation: What are the recommended approaches for achieving isolation between tenants within the application? Are there any Azure services or features that can help with this? Database design: How should I structure the database to support multiple tenants? Should I use a separate database for each tenant or a shared database with tenant-specific schemas? Authentication and authorization: What strategies should I consider for managing user authentication and authorization across tenants? Are there any Azure services that can simplify this process? Scaling and resource allocation: How can I effectively scale the application to handle the increasing number of tenants and their demands? Are there any Azure services or patterns that can assist with auto-scaling and resource allocation? Monitoring and diagnostics: What tools and practices should I implement to monitor the performance and health of the multi-tenancy application? Are there any Azure services or third-party tools that can help with … -
Django 4.2.2 not respecting STORAGES['default']['BACKEND']
Using settings.py: STORAGES = { "staticfiles": { "BACKEND": "storages.backends.s3boto3.S3Boto3Storage", }, "mediafiles": { "BACKEND": "storages.backends.s3boto3.S3Boto3Storage", }, "default": { "BACKEND": "storages.backends.s3boto3.S3Boto3Storage", }, } and running: from django.conf import settings print('settings.DEFAULT_FILE_STORAGE', settings.DEFAULT_FILE_STORAGE) prints: settings.DEFAULT_FILE_STORAGE django.core.files.storage.FileSystemStorage Media is writing to local and not S3 and this must be why. Static, for some reason, writes to S3 no problem. Any help or ideas would be appreciated. The full codebase can be seen here: https://github.com/rkuykendall/Simplici7y -
Is Using Psycopg2 with Django Ok?
I prefer using Psycopg2 over Django's built-in database handling system. Are there any major disadvantages to this? Would this not work well with larger-scale projects? Are there any important features that I would be missing out on this way? -
Validate a model instance for unique drf
I am working on a "Recipes" model and I want to prevent the creation of duplicate models with the same fields. Specifically, I want to throw a validation error if a model instance already exists with the same field values. This is my current code: def validate_recipe(self, value): recipes = Recipe.objects.all().filter(author=self.context['request'].user) for rec in recipes: if rec._meta.fields == value._meta.fields: raise serializers.ValidationError( {'errors': 'Do you have this recipe!'} ) return value Here are the images of the output I am currently getting: enter image description here enter image description here -
Dynamically scheduled tasks
I successfully configured Celery on my Django app and tested it. The test run was successful, as shown by the following output: celery -A concentrApp call mytask 0016f381-ed04-4a44-8c7a-c091a66dce0a [2023-06-17 13:46:28,465: INFO/MainProcess] Task mytask[0016f381-ed04-4a44-8c7a-c091a66dce0a] received [2023-06-17 13:46:28,477: INFO/ForkPoolWorker-8] Task mytask[0016f381-ed04-4a44-8c7a-c091a66dce0a] succeeded in 0.009182458000005056s: None ` Now, I would like to take this a step further and make the task dynamic. My goal is to create an endpoint that accepts parameters such as time, and param, and then run the task every sunday-thursday in the given hour using the provided parameter. This will allow me to customize the task execution based on user input, and make it several times that the user want. Thank you -
مشکل ارور :Page not found (404) در جنگو
I wrote a program in Zang, but whatever I do, it gives this error: 404 Using the URLconf defined in storefront.urls, Django tried these URL patterns, in this order: admin/ The current path, contact/, did not match any of these. URLs.py code: from django.urls import path from .views import save_user urlpatterns = [ path('save-user/', save_user, name='save_user'), ] There is no error during execution, but when I enter the code: http://localhost:8000/myapp/save-user/ in the browser, it gives an error on that page. -
can't open the page "127.0.0.1:8000" because the server dropped the connection unexpectedly
I want to run a Django project via Docker. I wrote a Dockerfile and docker-compose, but when I run the Django project it says : "Safari can't open the page Safari can't open the page "127.0.0.1:8000" because the server dropped the connection unexpectedly. This problem sometimes occurs if the server is busy. Wait a few minutes and try again." Dockerfile FROM python:3.9-slim WORKDIR /app RUN pip3 install --upgrade pip wheel COPY . . ADD requirements.txt . RUN pip3 --no-cache-dir install -r requirements.txt CMD ["python3", "manage.py", "runserver", "127.0.0.1:8000"] docker-compose.yml version: '3.6' services: invite_service: container_name: invite_service build: dockerfile: Dockerfile context: . ports: - "8000:8000" ALLOWED_HOSTS in Django settings ALLOWED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0'] -
psycopg2.OperationalError triyng to connect postgres to django
i am getting this error when i try to runserver: `Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\db\backends\base\base.py", line 289, in ensure_connection self.connect() File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\db\backends\base\base.py", line 270, in connect self.connection = self.get_new_connection(conn_params) File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\db\backends\postgresql\base.py", line 275, in get_new_connection connection = self.Database.connect(**conn_params) File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\psycopg2_init_.py", line 122, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\Zhadi\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner self.run() File "C:\Users\Zhadi\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\core\management\commands\runserver.py", line 136, in inner_run self.check_migrations() File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\core\management\base.py", line 574, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\db\migrations\executor.py", line 18, in init self.loader = MigrationLoader(self.connection) File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\db\migrations\loader.py", line 58, in init self.build_graph() File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\db\migrations\loader.py", line 235, in build_graph self.applied_migrations = recorder.applied_migrations() File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\db\migrations\recorder.py", line 81, in applied_migrations if self.has_table(): File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\db\migrations\recorder.py", line 57, in has_table with self.connection.cursor() as cursor: File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\Users\Zhadi\Desktop\Coding\Python\bronKz\back\env\lib\site-packages\django\db\backends\base\base.py", line … -
DJANGO: I have genres in my database, and django doesnt display them in my page('shop.html') even though i used loop
I am trying to modify a Django website. One of the webpages lists video games. Each game has a genre property, and I want to allow the user to filter the games based on their genres. However, each game can have multiple genres. Therefore, I created a Genre model that has a "title" property, and each Game has a many-to-many relationship with genres. I have already created the Genre model and created a page that lists all the existing genres. Now I want to create a page that lists all the games that have a certain genre. Here is my code below: in models.py class Genre(models.Model): title = models.CharField(max_length=255, verbose_name='Название жанра') def __str__(self): return self.title in views.py def shop_page(request): return render(request, 'store/shop.html') def genre_page(request, pk): genre = Genre.objects.get(pk=pk) genres = Genre.objects.all() games = Game.objects.filter(genres=genre) context = { # 'genre': genre, 'genres': genres, 'games': games } return render(request, 'store/shop.html', context) in urls.py path('shop/', shop_page, name='shop_page'), path('genre/', genre_page, name='genre'), in shop.html <ul class="trending-filter"> <li> {% for genre in genres %} <a class="is_active" href="{% url 'genre' genre.pk %}" data-filter="*">{{ genre.title }}</a> {% endfor %} </li> </ul> -
How can I use skfuzzy in Django?
I have created a Django project and I want to implement a simple fuzzy logic with three inputs and one output. However, when I import "skfuzzy" in Django views and reload the page, I get a Gateway Timeout error after 2 minutes (even without any implementation, just importing "skfuzzy"). I have run "pip3 install scikit-fuzzy" in the project virtual environment, and everything seems to be working fine. The code runs without a problem in the terminal, but it doesn't work in the Django project. Why is this happening? -
Django filter a model in the template
I want to be able to filter a model in the template (or find a different solution to fix my problem). The relevant models look like this: class CommissionElection(models.Model): title = models.CharField(max_length=64) commission = models.ManyToManyField(Commissie, related_name="elections") class ElectablePerson(models.Model): commission = models.CharField(max_length=128) election = models.ManyToManyField(CommissionElection, related_name="electables") class Commissie(models.Model): commissie = models.CharField(max_length=64) Here Commissie is a model from a different app. I have created a page for a specific election, now I want on that page a list per commission which states all the ElectablePersons that stated themselves electable for that commission (and for that election). I tried the following in my template: {% for commission in election.commission.all %} {{ commission }} {% for electable in election.electables.filter(commission=commission) %} {{ electable}} {% endfor %} {% endfor %} This gives the error Could not parse the remainder: '(commission=commission)' from 'election.electables.filter(commission=commission)' Is there anyway I could filter the model in the template or is there a different way I could do this? -
How to add to card without login, without user authentication. Help in session method of Django
How to add to card without login, without user authentication. Help in session method of Django. I am stuck in this. How to modify this code, so I can easily implement add to card, add to wishlist without login and also connected with users. Models.py class Cart(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) product = models.ForeignKey(Product, on_delete=models.CASCADE) product_qty = models.IntegerField(null=False, blank=False) created_at = models.DateTimeField(auto_now_add=True) class Wishlist(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) product = models.ForeignKey(Product, on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) wishlist.py from django.http import JsonResponse from django.shortcuts import render, redirect from django.contrib import messages from buyjoi.models import Product, Cart, Wishlist from django.contrib.auth.decorators import login_required @login_required(login_url='loginpage') def wishlistpage(request): wishlistitem = Wishlist.objects.filter(user=request.user) context = {'wishlistitem':wishlistitem} return render(request, 'wishlist.html', context) def addtowishlist(request): if request.method == 'POST': if request.user.is_authenticated: prod_id = int(request.POST.get('product_id')) product_check = Product.objects.get(id=prod_id) if(product_check): if(Wishlist.objects.filter(user=request.user, product_id=prod_id)): return JsonResponse({'status':"Product already in wishlist"}) else: Wishlist.objects.create(user=request.user, product_id=prod_id) return JsonResponse({'status':"Product added to wishlist"}) else: return JsonResponse({'status':"No such product found"}) else: return JsonResponse({'status':"Login to continue"}) return redirect('/') def deletewishlistitem(request): if request.method == 'POST': if request.user.is_authenticated: prod_id = int(request.POST.get('product_id')) if(Wishlist.objects.filter(user=request.user, product_id=prod_id)): wishlistitem = Wishlist.objects.get(product_id=prod_id) wishlistitem.delete() return JsonResponse({'status':"Product removed from wishlist"}) else: Wishlist.objects.create(user=request.user, product_id=prod_id) return JsonResponse({'status':"Product not found in wishlist"}) else: return JsonResponse({'status':"Login to continue"}) return redirect('/') checkout.py from http.client import HTTPResponse from django.shortcuts … -
Is it possible to use update_state and progress_observer within a function executed by a Celery task instead of directly inside the task itself?
I am developing a Django app that browses a website, selects a comic, and downloads it in the background with Celery. In the task.py file, I have a download_comic() function decorated with @shared_task(). The function checks the URL's hostname and uses different child classes of the base class FileHost to download the file. The actual download is done inside the class method, not on the task function. I came across this article (https://buildwithdjango.com/blog/post/celery-progress-bars/) that suggested using task.update_state and progress_observer.set_progress for progress monitoring. However, I am not sure if I can use these functions inside a class method or not. Here's a snippet of the FileHost class and download() method for reference: class FileHost: def __init__(self, url): self.url = url r = requests.get(self.url) self.soup = BeautifulSoup(r.content, "html.parser") def download_file(self): # Implement the file download logic here raise NotImplementedError() def download(self, filename, direct_link): response = requests.get(direct_link, stream=True) temp_path = Path('/tmp') / filename if 'Content-Disposition' in response.headers: content_disposition = response.headers['Content-Disposition'] temp_path = Path('/tmp') / content_disposition.split("=", -1)[-1] if response.status_code == 200: total_size = int(response.headers.get('content-length', 0)) downloaded_size = 0 with open(temp_path, "wb") as file: for chunk in response.iter_content(chunk_size=4096): if chunk: file.write(chunk) downloaded_size += len(chunk) # Calculate the progress percentage progress = int((downloaded_size / total_size) * … -
django migrations error. I migrated model but changes not aplied
i added new field to model and deleted another field but not deleting old field and not adding new feld.I deleted all migration files and re migrate it problem is same not working migration. It was a message " No migrations to apply. here is result after migrate app here is my changed model -
how to update default status of any record using django rest framework
I have three buttons named start, stop and cancel in my project. There is a status field which is default registered. When the 'start' button is clicked, the status should update 'running'. When the 'close' button is clicked, the status should update 'closed'. When the 'cancel' button is clicked, the status should update 'cancelled'. @csrf_exempt def projectApi(request,id=0): if request.method=='GET': project = Project.objects.all() project_serializer = ProjectSerializer(project, many=True) return JsonResponse(project_serializer.data, safe=False) elif request.method=='POST': project_data = JSONParser().parse(request) project_serializer = ProjectSerializer(data=project_data) if project_serializer.is_valid(): project_serializer.save() return JsonResponse("Added Successfully!!", safe=False) return JsonResponse("Failed to Add",safe=False) This is my views.py file. -
Customizing Django viewflow url
I am using the django-viewflow application with a custom view representing a stock item record where there are a number of workflows that can be attached to the record (registering/ issuing/ disposing etc.). In the detail view of the record I want to have a list of all workflows attached to the item and to be able to list all the tasks related to that workflow. I am aiming for a url that looks like .../asset/3/ - for the detail view .../asset/3/register/93/ - for the register process (and subsequent tasks) .../asset/3/movement/1/ - for movement process (and subsequent tasks) etc My application url.py looks like: asset_urls = FlowViewSet(AssetFlow).urls movement_urls = FlowViewSet(MovementFlow).urls app_name = 'asset' workflowurlpatterns = [ # path('ajax/load-budget_lines/', views.load_budget_lines, name='ajax_load_budget_lines'), path('viewflow/', include((asset_urls, 'asset'))), path('movement/', include((movement_urls, 'movement'))), # path('', views.Detail.as_view(), name='detail'), ] urlpatterns = [ path('', views.List.as_view(), name='assets'), path('<int:asset_pk>/', views.Detail.as_view(), name='detail'), path('<int:asset_pk>/', include((workflowurlpatterns))) ] The issue is that all the urls generated by the template tag {% flowurl task user=request.user as task_url %} fail with a NoReverseMatch error. Is there a clever way to pass the asset_id so that the urls work (or another solution)? -
unsupported format character '_' (0x5f)
models.py class ChangingDocument(PrivateCommentMixin, models.Model): # Список изменяющих документов. treaty = models.ForeignKey("treaties.Treaty", on_delete=models.CASCADE, blank=False, null=False, related_name="%(app_label)s_%(class)s_related", related_query_name="%(app_label)s_%(class)ss", ) changing_document = models.ForeignKey("treaties.Treaty", on_delete=models.CASCADE, blank=False, null=False, related_name="%(app_label)s_%(class)_changing_documents_related", related_query_name="%(app_label)s_%(class)ss_changing_documents", ) def __str__(self): return str(self.changing_document) Stack trace (venv) michael@michael:/media/michael/750/Programming/treaty_outer/treaty_project$ python manage.py makemigrations Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/media/michael/750/Programming/treaty_outer/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line utility.execute() File "/media/michael/750/Programming/treaty_outer/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 416, in execute django.setup() File "/media/michael/750/Programming/treaty_outer/venv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/media/michael/750/Programming/treaty_outer/venv/lib/python3.8/site-packages/django/apps/registry.py", line 116, in populate app_config.import_models() File "/media/michael/750/Programming/treaty_outer/venv/lib/python3.8/site-packages/django/apps/config.py", line 269, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 848, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/media/michael/750/Programming/treaty_outer/treaty_project/changing_documents/models.py", line 6, in <module> class ChangingDocument(PrivateCommentMixin, File "/media/michael/750/Programming/treaty_outer/venv/lib/python3.8/site-packages/django/db/models/base.py", line 194, in __new__ new_class.add_to_class(obj_name, obj) File "/media/michael/750/Programming/treaty_outer/venv/lib/python3.8/site-packages/django/db/models/base.py", line 371, in add_to_class value.contribute_to_class(cls, name) File "/media/michael/750/Programming/treaty_outer/venv/lib/python3.8/site-packages/django/db/models/fields/related.py", line 866, in contribute_to_class super().contribute_to_class(cls, name, private_only=private_only, **kwargs) File "/media/michael/750/Programming/treaty_outer/venv/lib/python3.8/site-packages/django/db/models/fields/related.py", line 357, in contribute_to_class related_name %= { ValueError: unsupported format character '_' (0x5f) at index 22 Problem I have … -
How upload Django web application using React JS?
Anybody knows how should I upload my Django web application using font-end React JS on Cpanel? -
Not able to override unittest `startTest` and `stopTest` isn’t working correctly in custom test runner when using with –parallel
I have override startTest and stopTest from unittest TextTestResult class and used it in my custom test runner. It’s working correctly in normal scenario but not working correctly when using with --parallel flag. I tried to debug and found the time elapsed b/w startTest and stopTest is coming very very small. Like 4.8000000000492093e-05 which is incorrect. Would someone please tell me is it the right hooks for --parallel flag or I have to use some another hook? -
Reorder models in admin
Could you tell me how to organise an arbitrary order in the admin site> Maybe something ready to use from here https://djangopackages.org/grids/g/admin-interface/ There exists django-modeladmin-reorder But it's a long time since it has been updated. Could you recommend something to me instead of that?