Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django ModuleNotFoundError: No module named 'asgiref'
I have a Django service we are trying to schedule in conjunction with the main application that runs periodically to send automated emails via a batch script. The Django application itself starts up fine, but when I try running the batch script, I get the following traceback: Traceback (most recent call last): File "C:\Program Files\compuweather\compuweather\webapp\management\commands\send_all_clients.py", line 2, in <module> from django.core.management.base import BaseCommand File "C:\ProgramData\Anaconda3\lib\site-packages\django-3.2- py3.8.egg\django\core\management\__init__.py", line 13, in <module> from django.apps import apps File "C:\ProgramData\Anaconda3\lib\site-packages\django-3.2-py3.8.egg\django\apps\__init__.py", line 1, in <module> from .config import AppConfig File "C:\ProgramData\Anaconda3\lib\site-packages\django-3.2-py3.8.egg\django\apps\config.py", line 7, in <module> from django.utils.deprecation import RemovedInDjango41Warning File "C:\ProgramData\Anaconda3\lib\site-packages\django-3.2-py3.8.egg\django\utils\deprecation.py", line 5, in <module> from asgiref.sync import sync_to_async ModuleNotFoundError: No module named asgiref I find that odd considering I have the batch file set to run from an anaconda environment that has Asgiref installed. I can verify this with pip freeze. Here are the versions of the packages I'm using: asgiref==3.3.1 Django==3.1.6 I saw a similar issue here, that was due to the Django and asgiref packages being outdated. I've tried updating both asgiref and Django to the latest versions (those listed), but that also didn't help. My best guess after looking through the traceback is either something is trying to use a deprecated … -
STRIPE KEYS not being detected. Can someone tell me why? Thank you! Django [closed]
The stripe keys are not being detected correctly but I don't know where is wrong. It is programmed in Django. STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY, "sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") STRIPE_PUBLIC_KEY = os.environ.get("STRIPE_PUBLIC_KEY", "pk_live_xxxxxxxxxxx") STRIPE_TEST_SECRET_KEY = STRIPE_SECRET_KEY STRIPE_TEST_PUBLIC_KEY = STRIPE_PUBLIC_KEY STRIPE_LIVE_MODE = False DJSTRIPE_WEBHOOK_SECRET = os.environ.get("STRIPE_WEBHOOK_SECRET") -
Django for loop only catching the last iteration on button click
I am building a Django movie app which makes use of the TMDB API. The way I have it set up currently is that I have a function in my main.js which is run when the page is loaded which makes the call to the API based on which media_id is clicked from the search results, which saves to local storage. This works fine in this regard. I implemented a review functionality where logged in users are able to leave reviews on whichever title they wish and it saves to the DB, and then on the user account page I have a list displayed of all the reviews a logged in user has left. Up till here everything works as intended but this is where my error lies. Next to each review in the users account page I have a button I want to take the user to the page in which they left the review, however I can only seem to get it to link me to the final title in the list of reviews. The code I have in my account.html file is as follows: <tbody> {% for review in reviews %} <script type="text/javascript"> function resetValues() { localStorage.setItem('movieId', … -
OSError: [WinError 127] The specified procedure could not be found
Context: I've been trying to create a spatial database for a geolocation-based app using GEOS/GIS/GDAL. First I had an issue saying windows could not find GDAL, so I followed these steps https://stackoverflow.com/a/49159195/9660287 which kind of worked but it now raises a WinError127. I checked for multiple versions of python on my system but I only have 1, version 3.9.1. Traceback (most recent call last): File "D:\health\manage.py", line 22, in <module> main() File "D:\health\manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\Python\lib\site-packages\django-3.1.5-py3.9.egg\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "C:\Python\lib\site-packages\django-3.1.5-py3.9.egg\django\core\management\__init__.py", line 377, in execute django.setup() File "C:\Python\lib\site-packages\django-3.1.5-py3.9.egg\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Python\lib\site-packages\django-3.1.5-py3.9.egg\django\apps\registry.py", line 114, in populate app_config.import_models() File "C:\Python\lib\site-packages\django-3.1.5-py3.9.egg\django\apps\config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "C:\Python\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 790, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "D:\health\facility\models.py", line 1, in <module> from django.contrib.gis.db import models File "C:\Python\lib\site-packages\django-3.1.5-py3.9.egg\django\contrib\gis\db\models\__init__.py", line 3, in <module> import django.contrib.gis.db.models.functions # NOQA File "C:\Python\lib\site-packages\django-3.1.5-py3.9.egg\django\contrib\gis\db\models\functions.py", line 3, in <module> from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField File "C:\Python\lib\site-packages\django-3.1.5-py3.9.egg\django\contrib\gis\db\models\fields.py", … -
i send my django project to my client and on his laptop it gives him error
Although I use python version 3and he use python version 3.8. and also he download database sqlite3 browser. the error is -
Celery shared_task hangs on task call
I have a simple celery task with print statement. The problem is in shared_task decorator, because if I change the decorator to app.task it works fine. @shared_task def generate_pdf(): print('Just to test if its working') But calling this task from a view or django shell just stucks until i hit Ctrl+C. Here is the traceback after keyboard interupt when celery hangs. ^CTraceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/kombu/utils/objects.py", line 41, in __get__ return obj.__dict__[self.__name__] KeyError: 'tasks' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/kombu/utils/objects.py", line 41, in __get__ return obj.__dict__[self.__name__] KeyError: 'data' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/kombu/utils/objects.py", line 41, in __get__ return obj.__dict__[self.__name__] KeyError: 'tasks' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/local/lib/python3.8/site-packages/celery/local.py", line 143, in __getattr__ return getattr(self._get_current_object(), name) File "/usr/local/lib/python3.8/site-packages/celery/local.py", line 105, in _get_current_object return loc(*self.__args, **self.__kwargs) File "/usr/local/lib/python3.8/site-packages/celery/app/__init__.py", line 69, in task_by_cons return app.tasks[ File "/usr/local/lib/python3.8/site-packages/kombu/utils/objects.py", line 43, in __get__ value = obj.__dict__[self.__name__] = self.__get(obj) File "/usr/local/lib/python3.8/site-packages/celery/app/base.py", line 1259, in tasks self.finalize(auto=True) File "/usr/local/lib/python3.8/site-packages/celery/app/base.py", line 511, in finalize _announce_app_finalized(self) File "/usr/local/lib/python3.8/site-packages/celery/_state.py", line 52, in … -
in django model foreign key not retrieving actual value
in django i defined two tables 1. country 2.state while i am trying to print country_id from State table its retriving like "State object (1)" i am expectin number alone like 1 ,2 3 # location lookup class Country(models.Model): country_id=models.AutoField(auto_created=True,primary_key=True) country_name=models.CharField(max_length=50) country_code=models.CharField(max_length=50,null=True,blank=True) # state lookup class State(models.Model): state_id=models.AutoField(auto_created=True,primary_key=True) state_name=models.CharField(max_length=50) country_id=models.ForeignKey(Country, on_delete=models.CASCADE,db_column='country_id') -
Django-Run a function in the background forever
In my case,I need to process something in the background indefinitely and as often as possible. Tools like Celery,RQ,etc have minimum limit as 1 second to run something periodically. But what I need is a way to run a function in the background without blocking the Django server from running. I tried while loop.But it blocks the server. I need something like below def call_me_once_and_run_forever_as_often_as_possible(): print("I am running here indefinitely without affecting serving of Web requests") call_me_once_and_run_forever_as_often_as_possible() I read about async.But can't quite understand how to run it forever. Any small snippet would be of great help. Thanks for helping -
NoReverseMatch at /listings/ Reverse for 'listing' not found. 'listing' is not a valid view function or pattern name
So I'm getting this error when I visit the page, I'm trying to use paginator and I don't know where i'm wrong, index function handles the page I'm talking about views.py def index(request): listings = Listing.objects.all() paginator = Paginator(listings, 3) page = request.GET.get('page') paged_listings = paginator.get_page(page) params = {'listings':paged_listings} return render(request, 'listings/listings.html', params) def listing(request, listing_id): return render(request, 'listings/listing.html') def search(request): return render(request, 'listings/search.html') listings.html {% extends 'base.html' %} {% block content %} {% load humanize %} <!-- Breadcrumb --> <section id="bc" class="mt-3"> <div class="container"> <nav aria-label="breadcrumb"> <ol class="breadcrumb"> <li class="breadcrumb-item"> <a href="{% url 'index' %}"> <i class="fas fa-home"></i> Home</a> </li> <li class="breadcrumb-item active"> Browse Listings</li> </ol> </nav> </div> </section> <!-- Listings --> <section id="listings" class="py-4"> <div class="container"> <div class="row"> {% if listings %} {% for listing in listings %} <div class="col-md-6 col-lg-4 mb-4"> <div class="card listing-preview"> <img class="card-img-top" src="{{ listing.photo_main.url }}" alt=""> <div class="card-img-overlay"> <h2> <span class="badge badge-secondary text-white">${{ listing.price | intcomma}}</span> </h2> </div> <div class="card-body"> <div class="listing-heading text-center"> <h4 class="text-primary">{{ listing.title }}</h4> <p> <i class="fas fa-map-marker text-secondary"></i>{{ listing.city }} {{ listing.state }}, {{ listing.zipcode }}</p> </div> <hr> <div class="row py-2 text-secondary"> <div class="col-6"> <i class="fas fa-th-large"></i>Sqfit: {{ listing.sqft }}</div> <div class="col-6"> <i class="fas fa-car"></i>Garage: {{ listing.garage }}</div> </div> … -
django url parameter creating in the process
I have no idea how to solve this problem: I have a django webshop project. At the end of the order I would like to redirect the user to a new page about the confirmation. urls.py: `path('confirmation/<str:order_id>/', views.confirmation,` name="confirmation"), views.py: def confirmation(request, order_id): items = OrderItem.objects.filter(order__id = order_id) context = {'items':items} return render(request, 'store/pages/confirmation.html', context) I have a javascript part another view where I do a POST method. If it is successfully done I would like to navigate to the confirmation page. In the data I get back the order_id. var url = '/process_order/' fetch(url,{ method: 'POST', headers: { 'Content-Type':'application/json', 'X-CSRFToken':csrftoken, }, body: JSON.stringify({'myForm':myFormData}) }) .then((response) => response.json()) .then((data) => { window.location.href = "{% url 'confirmation' data %}" }) I guess the problem is that in the very beginning of the execution there is no value of the data, because it is creating in the process. So the view can not render because of the parameter. (But my problem is that the order_id is creating after the POST method). (The Exception Value: Reverse for 'confirmation' with arguments '('',)' not found. 1 pattern(s) tried: ['confirmation/(?P<order_id>[^/]+)/$'] ) What would be the good solution of this situation? -
Problem with pytest. Queryset in my model
I have problem with pytest. In file tests.py I have got this code @pytest.mark.django_db def test_AddCompany(client): response = client.post('/add-company/', {'name': 'Test Company', 'description': 'test description', 'contact': 'testingmail@mail.pl', 'services': '', 'city': '', 'have_stationary': ''}) assert Company.objects.filter(name='Test') And I got this error E + where <QuerySet []> = <bound method BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_method of <django.db.models.manager.Manager object at 0x000002ACF3AD6C70>>(name='Test') E + where <bound method BaseManager._get_queryset_methods.<locals>.create_method.<locals>.manager_method of <django.db.models.manager.Manager object at 0x000002ACF3AD6C70>> = <django.db.models.manager.Manager object at 0x0 00002ACF3AD6C70>.filter E + where <django.db.models.manager.Manager object at 0x000002ACF3AD6C70> = Company.objects services, city and have_stationary its foreign key. -
Django how make makemigrations and migrate when making changes at models
Whenever I make changes to the models (and subsequently to the views) when I do makemigrations or migration, I always run into problems. Sometimes running makemigrations django notices the changes, but then when I run the command migrate django writes that there are no changes to be made. Other times, dozens of exceptions are generated during makemigrations. Django writes that he does not find certain tables or certain fields but I read that the errors report the names before my changes. The only solution to all this is to delete content of: _pycache_ views.py sql3.db3 database Leave only models.py. At this point I can proceed with the makemigrations and migrate commands. The question: is there an easier way? What am I wrong? -
Event handlers fires multiple times when triggered [duplicate]
For some reasons unbeknownst to me, the events for elements I created dynamically fires multiple times (mulitplying itself by three each time). Those, I added manually fire only ones. As you can see, I have some console.log() which I use to track if the function was called multiple times or it was the event handler that fired multiple times. Also added event.stopPropagation(), still fires. here is my html code {% extends "mail/layout.html" %} {% load static %} {% block body %} <h2>{{ request.user.email }}</h2> <button class="btn btn-sm btn-outline-primary" id="inbox">Inbox</button> <button class="btn btn-sm btn-outline-primary" id="compose">Compose</button> <button class="btn btn-sm btn-outline-primary" id="sent">Sent</button> <button class="btn btn-sm btn-outline-primary" id="archived">Archived</button> <a class="btn btn-sm btn-outline-primary" href="{% url 'logout' %}">Log Out</a> <hr> <div id="emails-view"> </div> <div id="mail-template"> </div> <div id="compose-view"> <h3>New Email</h3> <form id="compose-form" action="#"> <div class="form-group"> From: <input disabled class="form-control" value="{{ request.user.email }}"> </div> <div class="form-group"> To: <input id="compose-recipients" class="form-control" placeholder="Recipient"> </div> <div class="form-group"> <input class="form-control" id="compose-subject" placeholder="Subject" value="HOMES"> </div> <p><textarea class="form-control" id="compose-body" placeholder="Body"></textarea></p> <p><input value="Send" type="submit" class="btn btn-primary" id='compose-submit'/></p> <!--<p><button class="btn btn-primary" id="compose-submit">Send</button></p>--> </form> </div> {% endblock %} {% block script %} <script src="{% static 'mail/index.js' %}" type='text/javascript'></script> {% endblock %} here is my Javascript file function check_parent(e){ return e.id || e.parentNode.id || e.parentNode.parentNode.id; } function … -
Prevent redirection in Django template form
Currently, my application is rendering an Django Template model form wherein some images are referred from another model. In order to delete and add images for the other model, I am handling it with a button with an overriden formaction that points to a DRF-based REST endpoint which deals with the images. However, whenever the service is invoked, it redirects the app to API response page. I would like to if it is possible to prevent redirection after formaction for button or input html elements -
Fetch with same path, sometimes failed
StackOverflow Got an issue with fetch in js + Django document.addEventListener("DOMContentLoaded", function () { // Use buttons to toggle between views document .querySelector("#inbox") .addEventListener("click", () => load_mailbox("inbox")); document .querySelector("#sent") .addEventListener("click", () => load_mailbox("sent")); document .querySelector("#archived") .addEventListener("click", () => load_mailbox("archive")); document.querySelector("#compose").addEventListener("click", compose_email); // By default, load the inbox load_mailbox("inbox"); console.log("again loaded INBOX____________") // check is the compose submitted document.querySelector("#compose-form").onsubmit = function () { fetch("/emails", { method: "POST", body: JSON.stringify({ recipients: document.querySelector("#compose-recipients").value, subject: document.querySelector("#compose-subject").value, body: document.querySelector("#compose-body").value, }), }) .then((response) => response.json()) .then((result) => { // Print result console.log(result); load_mailbox("sent"); }); }; }); Inbox, Sent and Archive they are my buttons, which I used to navigate when it clicked, neededd div will be shown, others will be hidden. function load_mailbox(mailbox) { // Show the mailbox and hide other views document.querySelector("#emails-view").style.display = "block"; document.querySelector("#compose-view").style.display = "none"; document.querySelector("#email-click-view").style.display = "none"; // Show the mailbox name document.querySelector("#emails-view").innerHTML = `<h3>${ mailbox.charAt(0).toUpperCase() + mailbox.slice(1) }</h3>`; if (mailbox === "inbox") { fetch_mail_by_folder("inbox") } if (mailbox === "sent") { fetch_mail_by_folder("sent") } if (mailbox === "archive") { fetch_mail_by_folder("archive") } } Load mailbox will call other function, which will fetch the data for the page function fetch_mail_by_folder(folder) { fetch(`/emails/${folder}`) .then((response) => response.json()) .then((emails) => { // Print emails emails.forEach(email => { const … -
Library for developing datagrid?
I am about to develope a data management webapplication and I need a datagrid like airtable. What is the fast way to build a datagrid like that? What tecknology framework is he best choise? Is it a ready to go product with the compoment I need? Please help 🙌 -
allow users view own objects in django admin
i want give access to users to admin panel i have a table : class Todo(models.Model): user = models.ForeignKey(User,on_delete=models.CASCADE) title = models.CharField(max_length=100) date = models.DateTimeField() def __str__(self): return self.title i want just allow users to see,edit,add and delete their own objects in admin panel not others. i wrote this: class TodoAdmin(admin.ModelAdmin): def queryset(self, request): queryset = super(TodoAdmin, self).queryset(request) queryset = queryset.filter(user = request.user) return queryset but didnt work. how can i do that? -
Npm server not available after docker compose
I'm fairly new to docker. I was trying to separate my web app on modules for backend (django), frontend (react) and with some postgres db. Here is my docker-compose.yml : version: "3.8" services: db: image: postgres container_name: postgres environment: - POSTGRES_DB=postgres - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres volumes: - ./private/posgtesql/data/data:/var/lib/postgresql/data app: build: . container_name: app working_dir: /app/label_it command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/app ports: - "8000:8000" depends_on: - db front: build: context: ./label_it dockerfile: Dockerfile container_name: front command: npm run dev working_dir: /app/label_it/front volumes: - ./label_it/front:/app/label_it/front - ./label_it/front/node-modules:/app/./label_it/front/node_modules ports: - "8001:8000" depends_on: - app Django side runs like dream, browsing 127.0.0.1:8000 responses with server site. BUT. There is nothing on 127.0.0.1:8001. Correct me if I'm wrong, but I should be getting both servers for django AND for react on respecting ports?? Searched whole internet looking for solution. All I found was to check if node server actually runs on 0.0.0.0:8001 and it does according to : CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES baa18d3bfa73 labeling-lab-platform_front "docker-entrypoint.s…" 24 minutes ago Up 24 minutes 3000/tcp, 0.0.0.0:8001->8000/tcp front 6a76ba3a901b labeling-lab-platform_app "python manage.py ru…" About an hour ago Up 24 minutes 0.0.0.0:8000->8000/tcp app c0d1d27ed930 postgres "docker-entrypoint.s…" About an hour ago Up 24 minutes … -
Django POST-test for registering user
I want to test a user registering view in Django. The following test def test_view_register_redirects_to_homepage(self): response = self.client.post(reverse('register'), {'username': 'normal@user.com', 'password1': '3Zu!!44l', 'password2': '3Zu!44l'}) self.assertRedirects(response, '/') returns the following error message: AssertionError: 200!=302 Response didn't redirect as expected: Response code was 200 (expected 302). However, if I actually run the server, I see that it should work, hence, I'll guess there is something wrong with my test. My view looks like this def registerView(request): if request.method == "GET": return render( request, "accounts/register.html", {"form": CustomUserCreationForm} ) elif request.method == "POST": form = CustomUserCreationForm(request.POST) if form.is_valid(): user = form.save() login(request, user) return redirect('/') return render(request, 'accounts/register.html', {'form': form}) whereas my form looks like class CustomUserCreationForm(UserCreationForm): class Meta(UserCreationForm.Meta): model = CustomUser fields = ('email',) and my custom user model looks like class CustomUser(AbstractBaseUser, PermissionsMixin): email = models.EmailField(_('email address'), unique=True) is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=True) date_joined = models.DateTimeField(default=timezone.now) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email Any help would be appreciated. P.S: I already tried to use 'email': instead of 'username': in the test code but the result stays the same. -
Django UniqueConstraint usecase
I have the model users and Address with the Address model containing the user as a Foreign key. Is it possible to handle this use case with constraints that in case of multiple users addresses a user can have one default address? Here is a sample code. Thank you. class User(models.Model): name = models.CharField(max_length=10) class Address(models.Model): address = models.CharField(max_length=10) active=models.BooleanField(default=False) user = models.ForeignKey( User, blank=False, null=False, related_name="user_address", on_delete=models.CASCADE) class Meta: constraints = [ models.UniqueConstraint(fields=['user', 'active'], condition=models.Q(active=True), name='user default address.') ] -
My model's field are not showing in admin panels
My models are not showing in admin panel. My models.py class Cart(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE), product = models.ForeignKey(Product, on_delete=models.CASCADE), quantity = models.PositiveIntegerField(default=1), def __str__(self): return str(self.id) admin.py: @admin.register(Cart) class CartModelAdmin(admin.ModelAdmin): list_display = ['id', 'user', 'product', 'quantity'] I had also tried this: admin.site.register(Cart) -
HINT: No operator matches the given name and argument types. You might need to add explicit type casts. in Django
I'm wondering why this error display and I've been using Postgresql and I have been observed this error occurs when I use IntegerField on my models like this one b2_sacnumber_id = models.IntegerField(blank=True, null=True). Is there any solution to get the value even I used IntergerFiled in my models? Error LINE 1: ...sac_forms" WHERE "b2_sac_forms"."b2_sacnumber_id" IN (31718,... ^ HINT: No operator matches the given name and argument types. You might need to add explicit type casts. query views.py sample = ['31718','47060'] Sac_forms = list(B2SacForms.objects.using('matchy_data').values_list('b2_id', flat=True).filter(b2_sacnumber_id__in=sample)) What I tried changing the value sample like this one sample = ['31718','47060'] or sample = ["31718","47060"] and even I tried sample = [31718,47060] but still the error occurs -
Why django_migrations table is created even though router does not allow migrations?
I have 'default' and 'secondary' databases. Why, even though it is stated: makemigrations always creates migrations for model changes, but if allow_migrate() returns False, any migration operations for the model_name will be silently skipped when running migrate on the db. Changing the behavior of allow_migrate() for models that already have migrations may result in broken foreign keys, extra tables, or missing tables. When makemigrations verifies the migration history, it skips databases where no app is allowed to migrate. when running ./manage.py migrate --database=secondary I receive all the migrations listed as OK and django_migrations table existing in the 'secondary' database, instead of no migrations and no trace for them. Is it a Django design decision or I messed up the routing? class PrimaryRouter: """Primary router allowing ORM operations only on default database""" # NOTE: https://docs.djangoproject.com/en/3.1/topics/db/multi-db/#an-example def db_for_read(self, model, **hints): return 'default' def db_for_write(self, model, **hints): return 'default' def allow_relation(self, obj1, obj2, **hints): """ Relations between objects are allowed if both objects are in the primary/replica pool. """ db_set = {'default'} if obj1._state.db in db_set and obj2._state.db in db_set: return True return None def allow_migrate(self, db, app_label, model_name=None, **hints): """ All non-auth models end up in this pool. """ return db == … -
I want to save the current user when it delete a record in django
Suppose i have a DeleteView in django which succesfully delete the particular record but i also want to save which user delete the record for security purpose. I can save current user in CreateView,UpdateView but i don't know how to record current user when it delete a particular record. class PostDelete(DeleteView): model = Post template_name = 'post/confirm_delete.html' success_url = reverse_lazy('post-delete') Thanks -
Run django server in single thread only for one single url endpoint
By default django runserver runs in multiple thread, to stop multithreading there is an option for --nothreading, but by using this all requests are handled in a single thread which impacts in server performance. I need to run an selected url endpoint with single thread and all other endpoints can execute in parallel with multiple threads. My main motive is to handle multiple request within this endpoint in a sequence.