Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to assign random int to model variable while creating object in django?
I just started learing a django and have a that problem: I wrote a heroes creator. Each hero has a name, nickname, race, profession and the integers values like: strength, mana and HP. Code of model.py: class Hero(models.Model): def statsRandomizer(): str_random = random.randint(1,20) mana_random = random.randint(1,100) HP_random = random.randint(1,30) result = str_random return result RACES = { ("None", "None"), ("Human", "Human"), ("Elf", "Elf"), ("Dwarf", "Dwarf"), ("Ogre", "Ogre"), ("Hobbit", "Hobbit"), ("Gnome", "Gnome"), } user = models.ForeignKey(User, default=1, null=True, on_delete=models.SET_NULL) name = models.CharField(max_length=30) nickname = models.CharField(max_length=30) race = models.CharField(default=0, choices=RACES, max_length = 30) profession = models.CharField(max_length=30) #To do ogarnięcia bo nie działa. slug = models.SlugField(unique=True) strength = models.PositiveSmallIntegerField() mana = models.PositiveSmallIntegerField() HP = models.PositiveSmallIntegerField() level = models.PositiveSmallIntegerField(default = 0) def get_absolute_url(self): return f"/heroes/{self.slug}/" def get_edit_url(self): return f"/heroes/{self.slug}/edit/" def get_delete_url(self): return f"/heroes/{self.slug}/delete/" As u can see, I wrote a simple method to randomize value. It's returning only strength for a test. What's a problem? If I change my code to: strength = models.PositiveSmallIntegerField(default=statsRandomizer()) mana = models.PositiveSmallIntegerField(default=statsRandomizer()) HP = models.PositiveSmallIntegerField(default=statsRandomizer()) in form I see generated numbers, and I can create hero, but if I refresh it and want create second, I got same numbers. They are changed when I resave code in Atom. And … -
Django / HUEY -> Why does the 'periodic_task' blocks the view function from rendering a template
I have set up an instance of a periodic_task using HUEY (https://huey.readthedocs.io/en/latest/contrib.html#django). When the corresponding view is called, the function runs properly as intended. But somehow the template isn't rendered and the browser tries to load and load and load the requested URL. Why does the view not render the template? Somehow the HUEY instance is involded because it works just fine without the periodic_task. Settings.py: HUEY = { 'huey_class': 'huey.RedisHuey', # Huey implementation to use. 'name': DATABASES['default']['NAME'], # Use db name for huey. 'results': True, # Store return values of tasks. 'store_none': False, # If a task returns None, do not save to results. 'immediate': DEBUG, # If DEBUG=True, run synchronously. 'utc': True, # Use UTC for all times internally. 'blocking': True, # Perform blocking pop rather than poll Redis. 'connection': { 'host': 'localhost', 'port': 6379, 'db': 0, 'connection_pool': None, # Definitely you should use pooling! # ... tons of other options, see redis-py for details. # huey-specific connection parameters. 'read_timeout': 1, # If not polling (blocking pop), use timeout. 'url': None, # Allow Redis config via a DSN. }, 'consumer': { 'workers': 2, 'worker_type': 'thread', 'initial_delay': 0.1, # Smallest polling interval, same as -d. 'backoff': 1.15, # Exponential … -
Login and CRUD Django with github as provider
How can I build a CRUD application in Django, that allows a user to login using the Oauth protocol, with GitHub as the provider -
Crossbar vs 2 backends?
I’m starting to dig deep on crossbar and its functionalities and was wondering how flexible crossbar can actually be. If I have a project using django on the back end laying on top of a twisted server how does crossbar differs from javascripts frameworks like react or vue.js that need a nodejs backend to function? I’m interested in adding realtime functionality that obviously frameworks like react can provide, but they need to be on a separate nodejs backend aside from the django backend which I don’t really found flexible trying to set up just to make a framework to function. Therefore I came with the idea why not to use crossbar, since although I’m not really informed deeply yet on its functionality I feel like it can be useful and much flexible than using two backends. So, are there any differences? Can crossbar serve for my purpose and thus avoid javascript frameworks that depend on another backend? As far as I’m concerned, real-time frameworks are build based on an architecture of routing and event-driven programming. -
How to modify AJAX request so that the empty dependent drop-down is hidden when page loads?
I have a form that has a dependent drop-down. Currently, it displays the main drop-down and the dependent one when the page loads, and when you select a "Work Area" that does not have a "Station", then the station drop-down disappears from the page. What I'm trying to achieve is hiding the Station drop-down when the page first loads, and only have it show when a Work Area that does have Stations is selected. How could I modify the AJAX request (or the html tags, not sure where the change would have to occur) so that it is hidden from the beginning? enter_exit_area.html {% extends "base.html" %} {% block main %} <form id="warehouseForm" action="" method="POST" data-stations-url="{% url 'operations:ajax_load_stations' %}" novalidate > {% csrf_token %} <div> <div> <label>Employee</label> {{ form.employee_number }} </div> <div> <label>Work Area</label> {{ form.work_area }} </div> <div> <label>Station</label> {{ form.station_number }} </div> </div> <div> <div> <button type="submit" name="enter_area" value="Enter">Enter Area</button> <button type="submit" name="leave_area" value="Leave">Leave Area</button> </div> </div> </form> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script> $("#id_work_area").change(function () { var url = $("#warehouseForm").attr("data-stations-url"); var workAreaId = $(this).val(); $.ajax({ url: url, data: { 'work_area': workAreaId }, success: function (data) { $("#id_station_number").html(data); // Check the length of the options child elements of the select if … -
How to solve No such file or directory remote: #include <sql.h> when deploying in heroku?
Am trying to deploy a django app in heroku, but it tells me that while progressing! enter image description here What could be the solution? -
How do I access a model field from a different model? is this possible at all?
suppose I have two models class Project(models.Model): project_number = models.Charfield(primary_key=True, max_length=10) project_title = models.Charfield(max_length=100) total_cost = models.DecimalField(max_digits=8, decimal_places=2, blank=True, null=True) class FieldChangeOrder(models.Model): project = models.FoereignKey('Project', on_delete=models.CASCADE) funding_amount = models.DecimalField(max_digits=8, decimal_places=2, blank=True, null=True) percentage_of_funding = ( funding_amount / total_cost ) * 100 How do I access total_cost from Project model from FieldChangeOrder model to calculate the value for percentage_of_fundiing field? -
Business rules in Django models and admin
I have tried to find similar examples from Django tutorials/documentation but haven't found anything so far. Business rules I would like to have is: Each Sample has its own set of Batch'es Session has set of Samples and each sample can have only one batch in Session Example Samples: WineA (batch: 2016, 2017, 2018) WineB (batch: 2015, 2019) Example Session: Session1 WineA - batch 2017 WineA - batch 2018 WineB - batch 2015 The models look like this: class Sample(models.Model): sample_name = models.CharField(max_length=250, unique=True) def __str__(self): return self.sample_name class Batch(models.Model): batch_name = models.CharField(max_length=250) batch_sample = models.ForeignKey(Sample, on_delete=models.CASCADE) def __str__(self): return self.batch_name class Session(models.Model): survey_name = models.CharField(max_length=250, unique=True) survey_sample = models.ManyToManyField(Sample) But what I can't wrap my head around is whether I should define these business rules in the models or should views take care for that. The expected result would be that when I add a new Session in Django site admin, I can add Sample's (more than once to same session) and select or define a batch for each sample. -
Django - delete button is not redirecting to the correct path
I am following a tutorial to make a to-do list website. Upon trying to implement a delete button, I am encountering this error. Page not found (404) Request Method: GET Request URL: http://localhost:8000/%7B%25%20url%20'delete'%20things.id%20%25 Using the URLconf defined in todo.urls, Django tried these URL patterns, in this order: admin/ [name='home'] delete/"" [name='delete'] The current path, {% url 'delete' things.id %, didn't match any of these. Relevant code: views.py def delete(request, list_id): item = List.objects.get(pk=list_id) item.delete() messages.success(request, ('Item Has Been Deleted!')) return redirect('home') home.html <tr> <td>{{ things.item }}</td> <td><center>{{ things.completed }}</center></td> <td><center><a href = "{% url 'delete' things.id %}"> Delete</td></center> </tr> urls.py from django.urls import path from . import views urlpatterns = [ path('', views.home, name="home"), path('delete/<list_id>', views.delete, name="delete"), ] -
Back button stores previous data DJANGO
I am creating an app using django where an user can search for definition of some things. So f.e. he is inputing a word "security" to get definition of this. He gets results and then he is pushing back button. And then he gets a website, but the search-field still stores the old data/input "security". How can i fix this? -
Django application on cpanel - increase LSAPI_CHILDREN
I have a Django application in cpanel server, I got this error ” Reached max children process limit: 6, extra: 2, current: 8, busy: 2, please increase LSAPI_CHILDREN. ” What is this error? -
How to update a value in the database in Django?
I am creating a project using Python and Django in which I keeping track of all the products in my store, once I sell a particular product I need to update the number of units of that product remaining Here is my Models.py file from django.db import models class Product(models.Model): prod_name=models.CharField(max_length=100, blank=False) company=models.CharField(max_length=100, blank=False) quantity=models.IntegerField() price=models.IntegerField() prod_type=models.CharField(max_length=100) units=models.IntegerField() def __str__(self): return('Name:{0} Company: {1} Qty:{2} Price: {3} Type:{4} Units: {5}'.format(self.prod_name, self.company,self.quantity, self.price, self.prod_type, self.units)) Here is my views.py file from django.shortcuts import render, redirect, get_object_or_404 from .models import * from .forms import * def index(request): return render(request, 'index.html') def display_product(request): items=Product.objects.all() context={ 'items':items } return render(request, 'index.html', context) def add_product(request): if request.method == "POST": form = ProductForm(request.POST) if form.is_valid(): form.save() return redirect('index') else: form =ProductForm(request.POST) return render(request, 'add_new.html', {'form':form}) def edit_product(request, pk): item = get_object_or_404(Product, pk=pk) if request.method == 'POST': form = ProductForm(request.POST, instance=item) if form.is_valid(): form.save() return redirect('index') else: form = ProductForm(instance=item) return render(request, 'edit_product.html', {'form':form}) def sell_product(request, pk): item = get_object_or_404(Product, pk=pk) if request.method == 'POST': form = ProductForm(request.POST, instance=item) if form.is_valid(): form.save() return redirect('index') else: form = ProductForm(instance=item) return render(request, 'sell_product.html', {'form':form}) Here is my sell_product.html {% extends 'base.html' %} {% block body %} <div class="container"> <form method="POST"> … -
STATICFILES_DIRS setting makes my admin widget override disappear
I'm having trouble understanding how static files are handled in Django. I've read through the official Django documentation as well as multiple threads, including this wonderful one here: Differences between STATICFILES_DIR, STATIC_ROOT and MEDIA_ROOT Most people define the STATICFILES_DIRS list as a list of paths where django will search for additional static files aside from the app's static folder. I understand that, but what does this have to do with the formfields I'm overriding in my admin.py? I have overridden the default ManyToMany form to the FilteredSelectMultiple widget in a few of my admin models like so: from django.contrib.admin.widgets import FilteredSelectMultiple formfield_overrides = { models.ManyToManyField: {'widget': FilteredSelectMultiple("User Names", is_stacked=False)} } This works fine and produces the widget override I wanted: Functional Widget Screenshot However, when I define STATICFILES_DIRS in settings.py to include my root static folder like so: STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static/'), ) It breaks my override and defaults back to the original ManyToMany field form: Broken Widget Screenshot We do not have STATIC_ROOT defined in our settings.py as we don't plan on using the collect static feature. We plan on keeping/referencing our static files at the root static folder. Also in our settings.py we have: STATIC_URL = '/static/' … -
Django TestCase 302, expecting 200
I am testing a django project / Randomization app I try to test status code of the index template of Randomization app but it return 302 instead of 200 I found similar question in this forum and add the advices (create a client and a user in setup method) but it does not work in my case my user is created (controled with a print) but still have 302 thanks for advices from django.test import TestCase, Client from django.contrib.staticfiles.testing import StaticLiveServerTestCase from selenium.webdriver.firefox.webdriver import WebDriver from selenium.webdriver.common.keys import Keys from django.contrib.auth.models import User from .models import Preinclusion, Randomisation, Medicament, ListeRandomisation from django.urls import reverse # test de la page index du module randomization class IndexPageTestCase(TestCase): def setUp(self): self.client = Client() self.user = User.objects.create_user('Slater', 'slater@surfeur.com', 'mereva2019') def test_index_page(self): self.client.post('/accounts/login/?next=/randomization', {'username': 'Slater', 'password': 'mereva2019'}) response = self.client.get(reverse('randomization:index')) # print(response['location']) self.assertEquals(response.status_code,200) -
Django ORM Performance Issues
I am looping over 13,000 in-memory city names and generating queries to filter for something. I've encountered something I cannot explain... When the loop has a single line: cities = City.objects.filter(name__iexact=city) performance is almost 800 items/second When the loop measures the length of the returned set... cities = City.objects.filter(name__iexact=city) num_citles = len(cities) performance drops to 8 items/second I can't explain where the performance degradation occurrs. Obviously, I'm missing something... Why would counting the number of items on an in-memory array that is always between 0 and 3 items reducing performance by a factor of x100? -
Django server fails to start in Docker container
I have been trying to run an existing Wagtail/Vue implementation from https://github.com/hyshka/wagtail-vue-talk I have gotten as far as installing Docker and setting up the containers, but when I try to run a Django server from container, it spits out the following code: root@e7d407eba535:/app# django-admin.py runserver 0.0.0.0:8000 Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 316, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/runserver.py", line 60, in execute super().execute(*args, **options) File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 353, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/runserver.py", line 67, in handle if not settings.DEBUG and not settings.ALLOWED_HOSTS: File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 57, in __getattr__ self._setup(name) File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 44, in _setup self._wrapped = Settings(settings_module) File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 107, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 956, in … -
Django and Nginx - root page not open (403)
server { listen 80; server_name 193.88.95.120; charset utf-8; root /root/djangoprojects/megaproject; client_max_body_size 75M; location /media { alias /root/djangoprojects/media/; } location /static { alias /root/djangoprojects/megapproject/megaapp/static/; } location / { include /root/djangoprojects/megaproject/uwsgi_params; } } It is config nginx. Not open main page - error 403. Maybe I didn't specify any settings. -
Setting up Django App with Postgress and Database Results Backend
I'm using Django, SQS and Celery together. SQS does not have a results backend, so I'm trying to use the django-celery-results library. I followed the instructions in the Celery documentation and the django-celery-results documentation. The problem I have is that the migration works and it creates the table. However, the results are not being saved in the database with the exception of the 'celery.backend_cleanup'. It's not saving my periodic task. I'm not the only one with this issue: github. I've tried all the solutions on that page and I can't get it to work. I tried: Setting.py CELERY_ACCEPT_CONTENT = ['application/json'] CELERY_RESULT_SERIALIZER = 'json' CELERY_TASK_SERIALIZER = 'json' CELERY_DEFAULT_QUEUE = env('CELERY_DEFAULT_QUEUE') CELERY_RESULT_BACKEND = 'django-db' And: CELERY_RESULT_BACKEND = 'django-db' CELERY_RESULT_BACKEND_DB = 'db+'+env('DATABASE_URL') # DATABASE_URL = postgres://USER:PASSWORD@HOST:PORT/DataBaseName And following this format: DATABASE_URL = postgresql://USER:PASSWORD@HOST:PORT/DataBaseName And: CELERY_RESULT_BACKEND = 'db+postgres://django-db And: CELERY_BROKER_URL = "sqs://" CELERY_RESULT_BACKEND = 'django-db' CELERY_RESULT_BACKEND_DB = 'postgresql://..' I tried changing celery.py to: celery.py app = Celery('project', broker_url='sqs://') app.conf.update( result_backend='django-db' ) And: app.conf.update( result_backend='django-db', include='project' ) What am I missing? Why is is saving the cleanup job and not my periodic task? -
Django Autotask: How to handle "cannot serialize '_io.BufferedReader' object" error
I would like to use autotask for my Django driven web application to make API requests periodically. When I call the view I end up with this error: TypeError at /Quotes/ cannot serialize '_io.BufferedReader' object Request Method: GET Request URL: http://127.0.0.1:8000/Quotes/ Django Version: 2.2.6 Exception Type: TypeError Exception Value: cannot serialize '_io.BufferedReader' object Exception Location: C:\Users\Jonas\AppData\Local\Programs\Python\Python37-32\lib\site-packages\autotask\tasks.py in wrapper, line 112 Python Executable: C:\Users\Jonas\AppData\Local\Programs\Python\Python37-32\python.exe Python Version: 3.7.4 Python Path: ['C:\\Users\\Jonas\\Desktop\\dashex', 'C:\\Users\\Jonas ' '\\AppData\\Local\\Programs\\Python\\Python37-32\\python37.zip', 'C:\\Users\\Jonas ' '\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs', 'C:\\Users\\Jonas\\AppData\\Local\\Programs\\Python\\Python37-32\\lib', 'C:\\Users\\Jonas\\AppData\\Local\\Programs\\Python\\Python37-32', 'C:\\Users\\Jonas ' '\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages'] Server time: Tue, 12 Nov 2019 18:47:13 +0000 Traceback: Traceback: File "C:\Users\Jonas\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py" in inner 34. response = get_response(request) File "C:\Users\Jonas\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response 115. response = self.process_exception_by_middleware(e, request) File "C:\Users\Jonas\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response 113. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\Jonas\AppData\Local\Programs\Python\Python37-32\lib\site-packages\autotask\tasks.py" in wrapper 112. tq.arguments = pickle.dumps((args, kwargs)) Exception Type: TypeError at /Quotes/ Exception Value: cannot serialize '_io.BufferedReader' object Views.py: from .models import ratesEUR import json import requests from autotask.tasks import periodic_task @periodic_task(seconds=20, start_now=False) def fetchAPI(request): response = requests.get("http://data.fixer.io/api/latest?access_key=XXX&base=EUR") rates_EUR = json.loads(response.content.decode('utf-8')) timestamp = rates_EUR['timestamp'] base = rates_EUR['base'] date = rates_EUR['date'] rates = rates_EUR['rates'] id = 1 rates_new = ratesEUR(id=id, timestamp=timestamp, base=base, date=date, rates=rates) rates_new.save() return response(data={}) return render(request, template="Quotes_app/templates/Quotes_app/Quotes_app.html") I followed this docu to set it up: https://bitbucket.org/kbr/autotask/src/default/ Any idea what … -
Pickle/Unpickle more complicated objects
I'm having a more complicated object which also contains some inheritances and so on. I'd like to be able to pickle/unpickle it and save it as file in my git. But it only works while it's still in the memory. When I'm reading it as a file I can't convert it back properly. As long as I'm just using it within my python (Django) application it's fine: myPickle=pickle.dumps(reallyComplicatedObject, 0).decode() ... myObject = pickle.loads(myPickle.encode()) Now I'm saving it for further usage (I'm having to pretend it's a file as Django won't allow me to save a string as a file): fs = FileSystemStorage() notAFile = io.StringIO(pickle.dumps(reallyComplicatedObject, 0).decode()) filename = fs.save(filename, notAFile) return fs.url(filename) This did as it was supposed to. I'm having a file that looks more or less binary to me Now the unpickle: storage_class = get_storage_class(settings.STATICFILES_STORAGE) complicatedPickle = None with storage_class().open('TestFiles/Pickles/thatOneObject') as picklereads: complicatedPickle = picklereads.read() pick = pickle.loads(complicatedPickle) When I output complicatedPickle I'm getting a long string that does look binary to me. Here I wonder already as I expected a String - but it is: (Pdb) type(complicatedPickle) <class 'bytes'> pick is a String and encoding it just makes it binary again: (Pdb) type(pick) <class 'str'> (Pdb) type(pick.encode()) … -
How to point the Django library to the one virtual environment?
I just cloned a project from Heroku, it's a Django app that run with Docker. When I issue command 'docker-compose up --build' for the first time after cloning the project, the app is up and runs fine. However, when I use Visual Studio Code to add more features. I see there is a yellow line under import django, import bokeh, etc. showing that they can't find path to these packages. However, I believe these packages have already been installed in the virtual environment because at the beginning when I installed packages, I used this command: docker-compose exec web pipenv install Could you show me how to link the packages back to the virtual environment in Docker so I don't need to install these packages again in the local computer, which can create Pipfile.lock conflict? Thank you. Huy -
How to properly call a function/url from html using AJAX in Django?
I am trying to display a User's name on top of a box where they enter their Employee # in a form, without having to refresh the page. For example, they enter their # and then after they click/tab onto the next field, the page automatically renders their name on top of the text box, which comes from the database, so the user knows they've entered the correct info. This name is stored in a separate model, so I try to retrieve it using the "id/number" associated to them. I am not too familiar with AJAX but after reading a few similar questions it seems like an AJAX request would be the most appropriate way to achieve this. I tried to make a function get_employee_name that returns the name of the person based on the way I saw another ajax request worked, but I'm not sure how to implement this so it displays after the # is entered. My page currently loads, but when I check the network using F12, there is never a call to the function/url that searches for the name to display it on the page. I'm not sure where I might be missing the part that … -
how do I get all the four options with each question... like if i print question then how do i print all the four option of that particular question
from django.db import models class Questions(models.Model): question = models.CharField(max_length=50) choice1 = models.CharField("Choice1", max_length=50,default="option1") choice2 = models.CharField("Choice2", max_length=50,default="option2") choice3 = models.CharField("Choice3", max_length=50,default="option3") choice4 = models.CharField("Choice4", max_length=50,default="option4") choice = models.CharField("Choice", max_length=50,default="correct option") def __str__(self): return self.question This is a modal for creating a question and its options. now I want to show all four option with question. when i write Questions.objects.all() then I only get a question only now how do i get options with the question. -
NameError: name 'Address' is not defined (when using python shell), but it is in models.py
I am trying to access all objects from a class Address, but I have no idea why I get NameError: name 'Address' is not defined when Address is right there in models.py. Obviously I have run 'makemigrations' and 'migrate' (more than once). Has anyone got any idea of why this happens? Of course, if you need me to post any other screenshot just let me know it, as at the moment I don't know what else to show... -
Why are cookies visible in Django app browser dev tools but not via curl?
I am trying to use curl via bash script to store cookies using curl -c cookies.txt https://www.mydjangoapp.com/ so that I can use the CSRF token in subsequent curl requests (using the -b cookies.txt option in subsequent commands). However, when I run cat cookies.txt to view the contents, the file only contains the following: # Netscape HTTP Cookie File # https://curl.haxx.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. When I check the cookies returned via Chrome Developer Tools, I see all the cookies that I expect. I have verified that cookies.txt is populated with cookies when running the curl command against other endpoints. Any ideas about how this might happen? In particular, I'm trying to get the CSRF token, but this seems to be a more general cookie retrieval issue with curl and my Django application.