Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Why Request to an API takes too long time
Maybe this question already exits, if yes sorry When I was making registration the redirect to other page was almost simultaneously, but when I started to send (username,password) data to an api url in order to take token, the website started to load more longer. I am doing it in Django, and it is only me making request, I guess how long it will be if I launch this website. Why it is taking so much time to make request, if there a way to make it faster? -
Submitting a form using POST from a VueJS component to Django backend
I am looking for a method which would allow me to use my created form (found in a vue component) to submit or make a post request to my project's django backend. I am aware of an approach which involves creating a forms.py file and using django's form, however, this is not what I am after. Typically, when using a form of django's, people use the line bound_form = {a form they have imported}. How can this be done with a vue component form? Traditional approach I am trying to avoid: def post(self, request): task = json.loads(request.body) bound_form = TaskForm(task) if bound_form is_valid(): new task = bound_form.save return JsonResponse... Thank you! -
Unable to change Django default templates
I'm learning Django using W. Vincent's "Django for beginners". I got to the part where we have to customize the password change page (p. 186). According to the author: "Django already has created the views and URLs for us, we only need to change the templates." I created a new template password_change_form.html but when I start a local server and go to the localhost/accounts/password_change, I still see the old default page with the "Django Administration" header. Here is the code: {% extends "base.html" %} {% block title %}Password Change{% endblock title %} {% block content %} <h1>Password change</h1> <p>Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly.</p> <form method="POST"> {% csrf_token %} {{ form.as_p }} <input class="btn btn-success" type="submit" value="Change my password"> </form> {% endblock content %} I'm surprised because everything worked well up until this point, as I was able to successfully updated the login and signup pages' templates. What do you think might be going wrong? Thanks. -
Django SearchQuery and SearchRank not finding results when 1 word matches in a 2 word query
I have a list of articles and I want to do a search using the PostgreSQL SearchQuery and SearchRank functionality. Here is the pseudo code: from django.contrib.postgres.search import SearchVector, SearchQuery, SearchRank from .models import Article vector = SearchVector('title', weight='A') query = SearchQuery(value) results = Article.objects.annotate(rank=SearchRank(vector, query, cover_density=True).order_by('-rank') for r in results: print(r.rank, r.name) For example, if I search for only "computer" this is what I gets printed: 1 The most powerful computer in the world 0 This man built a plane for his family in his garden 0 Dogs can sense earthquakes before they happen As you can see it all works as expected with the article that contains "computer" in the title getting a rank of 1. But now if I search for something with 2 words "fast computer" the results will all show a rank of 0. 0 Dogs can sense earthquakes before they happen 0 The most powerful computer in the world 0 This man built a plane for his family in his garden According to the "SearchQuery" documentation: If search_type is 'plain', which is the default, the terms are treated as separate keywords So why is still not matching the article with "computer" in the title? … -
Pytest - Access to DB from inside setup_class method
I need to have access on creation from inside the setup_class method. F.e.: @pytest.mark.django_db class TestPerson: @classmethod def setup_class(cls): Person.objects.create(first_name='John', last_name='Snow') # here error happens def setup_method(self): Person.objects.create(first_name='John', last_name='Snow') def test_1(self): assert True It fails with error: RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it. For method setup_method it works fine. I did some research in pytest source code and found the place where usual class method setup_method becomes a pytest fixture. So I tried to implement the same approach: def make_setup_class_as_fixture(klass): old_setup_class = klass.setup_class @pytest.fixture(scope='class', autouse=True) def new_setup_class(cls): old_setup_class(cls) klass.setup_class = new_setup_class return klass @make_setup_class_as_fixture @pytest.mark.django_db class TestPerson: def setup_class(cls): Person.objects.create(first_name='John', last_name='Snow') def setup_method(self): Person.objects.create(first_name='John', last_name='Snow') def test_1(self): assert True But fail again with the same error. How to fix it? -
ModuleNotFoundError: No module named 'rest_framework' (tried many solutions but not working)
I have encountered this error. ModuleNotFoundError: No module named 'rest_framework' I have a virtual environment setted up and the rest framework is installed correctly. When I run pip3.10 show djangoframework, I get Name: djangorestframework Version: 3.14.0 Summary: Web APIs for Django, made easy. Home-page: https://www.django-rest-framework.org/ Author: Tom Christie Author-email: tom@tomchristie.com License: BSD Location: c:\users\chan\desktop\testpy\lib\site-packages Requires: django, pytz Required-by: My interpreter is Python 3.10.8 which is the same version and it is for the virtual environment. my VSCode shows my interpreter as Python 3.10.8 ("TESTPY":venv) .\Scripts\python.exe. I also have included the rest_framework in the INSTALLED_APPS in the settings.py INSTALLED_APPS = [ 'rest_framework', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] Below is the full error I get. (TESTPY) PS C:\Users\Chan\Desktop\TESTPY> python3 manage.py runserver Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\threading.py", line 1016, in _bootstrap_inner self.run() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "C:\Users\Chan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "C:\Users\Chan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run autoreload.raise_last_exception() File "C:\Users\Chan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception raise _exception[1] File "C:\Users\Chan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\django\core\management\__init__.py", line 398, in execute autoreload.check_errors(django.setup)() File "C:\Users\Chan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "C:\Users\Chan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\Chan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\django\apps\registry.py", … -
Django filter does not accept database fields
Using Django 4.1.2, filtering does not work for database fields. Given the following model: class Activities(models.Model): es_date = models.DateField(blank=True, null=True) ef_date = models.DateField(blank=True, null=True) ls_date = models.DateField(blank=True, null=True) lf_date = models.DateField(blank=True, null=True) Migration done and DB content can be retrieved, for instance it gives back all of them properly: >>>from mymodel.models import Activities >>>Activities.objects.all() <QuerySet [<Activities: Task 33>, <Activities: Task 30>...]> or requesting a particular item also works properly: >>>Activities.objects.get(id=1) <Activities: Task 1> although applying filter for a given field it drops "NameError" error >>>Activities.objects.all().filter(es_date>timezone.now()) Traceback (most recent call last): File "<console>", line 1, in <module> NameError: name 'es_date' is not defined What might be the error? -
Jinja Expression In Statement
I am wanting to include dynamic variables inside of an if statement. {% elif request.path == "/order/{{city}}" %} I have a database I can refer to, to get the city names I need out depending on the url but am having a hard time sending that info in through this if statement. (Everything works dynamically up until this point) Solutions? -
how to find number of patients and and hospitals in a city using values (group by) in django
I'm trying to find number of patients and and hospitals in a city: for example: patients : 13 , hospital : A , city : London patients : 20 , hospital : B , city : NewCastle here is my models.py class City(models.Model): name = models.CharField(max_length=150) def __str__(self): return self.name class Hospital(models.Model): name = models.CharField(max_length=150) city = models.ForeignKey(City, on_delete=models.CASCADE, related_name="hospital") def __str__(self): return self.name class Patient(models.Model): name = models.CharField(max_length=150) city = models.ForeignKey(City, on_delete=models.CASCADE, related_name="patients") hospital = models.ForeignKey(Hospital, on_delete=models.CASCADE, related_name="patients", blank=True, null=True) here is my query: City.objects.values('name').annotate(patients_no=Count('patients__pk'),hospitals_no=Count('hospital__pk')) but it sums number of patients with number of hospitals! is there away to achieve it please. i have to return number of hospitals in a city, and number of patients in a hospital, note: i dont care about the name of the hospital Thank you in advance. -
Do you query database data in model or view, Django
This is probably a dumb question here but bran new to Python/Django. I've worked with many other frameworks and how the MVC works is in the model is where you make all your queries and then you grab them from the controller to send to the view. In Django it's telling me to make these queries in the view.py file(a controller in other frameworks) Example: Models.py from django.db import models class Moves(models.Model): name = models.CharField(max_length=64) description = models.CharField(max_length=500) position_id = models.IntegerField() is_offence = models.BooleanField(default=True) views.py def half_guard_moves(request): half_guard_moves = Moves.objects.values().filter(position_id=2) return render(request, "moves/halfguardmoves.html", {'half_guard_moves': half_guard_moves}) This works but seems odd because I'm actually making the query in the views(controller) file not the model? Am I doing this correct or is there another way to make queries directly in the model? -
Saving data without using form in Django
I have one application that need save data without using form. The scenario will be a potential employee reserves available gag job offers. The problem is nothing saved. @login_required #here employee reserves that offered jobs on job list def reserve_shift(request, pk): shift = Shift.objects.get(id=pk) if request.method == 'POST': user=request.user reserve_shift.objects.save() return redirect('reserved_shifts') @login_required #the view to all shifts that employee reserved def reversed_shifts(request): user=request.user reserved_shifts=ShiftReservation.objects.all() context={'reserved_shifts':reserved_shifts,'user':user} return render(request,'reserved_shifts.html',context) here is the model that inherited from Shift class class ShiftReservation(Shift): user=models.ForeignKey(get_user_model(),on_delete=models.CASCADE) time_reserved = models.DateTimeField(auto_now_add=True) How should I do it? Thank you! -
Is it possible to dynamically set a field to the number of elements in the database in Django?
Let's say I have an example model: class Item(models.Model): name = models.CharField(max_length=100) Is it possible to add a field which would dynamically change based on number of elements in the database? For example, let's say we have following entries in the database: id name order 0 'Mark' 0 1 'John' 1 If I were to add another user from the Django Admin interface I only want to see options 0, 1 and 2. If I select 2 the new user would be added with that order, if I select 1 the new user would be added with order 1 and 'John' would get order 2. If there's a better way of doing this I'm all for it, I just need to be able to change order of the items from the Django Admin interface in an elegant way. -
The href and click event listeners should be executed sequentially
I'm working on a Django project in which I need to move to a specific URL and then toggle the sub dropdown menu, but the issue is that both things are happening at the same time. Here is my dropdown code <a href="{% url 'my_applications' %}" class="nav_link {% if request.resolver_match.url_name == "payroll_941_files" %}active{% endif %} dropdown-btn"><img src="{% static 'application/img/icon_doc.svg' %} "><span class="nav_name" >My Applications</span> </button> <div class="row dropdown-container "> <div class="col-md-2"> {% for company in companies %} <a href="{% url 'my_applications_id' company.id %}" class="company-row" >{{ company.name | title }}</a> {% endfor %} </div> </div> Here is my Javascript code var dropdown = document.getElementsByClassName("dropdown-btn"); for (var dropdown_size = 0; dropdown_size < dropdown.length; dropdown_size++) { dropdown[dropdown_size].addEventListener("click", function() { console.log(dropdown.length); this.classList.toggle("active"); var dropdownContent = this.nextElementSibling; if (dropdownContent.style.display === "block") { dropdownContent.style.display = "none"; } else { dropdownContent.style.display = "block"; } }); } Now when I click the My application dropdown section both href and toggle running simultaneously. -
django is not persisting session in cookies unless I concatenate a list
I am trying to build a session in django like so but the following does not lead to an updated session def index(request): if not request.user.is_authenticated: return render(request, "login.html", {"message": None}) if 'foo' not in request.session: request.session["foo"] = {} if request.method == 'POST': form = NewLineItemForm(request.POST) if form.is_valid(): item = Item.objects.create(name=name) request.session["foo"][item.id] = item.name context = { "foo": request.session['foo'], "form": NewLineItemForm() } return render(request, "index.html", context) However, when I add the following to another key on the session does the entire thing, including the original key (foo) update: def index(request): if not request.user.is_authenticated: return render(request, "login.html", {"message": None}) if 'foo' not in request.session: request.session["foo"] = {} if 'task' not in request.session: request.session['task'] = [] if request.method == 'POST': form = NewLineItemForm(request.POST) if form.is_valid(): item = Item.objects.create(name=name) request.session["foo"][item.id] = item.name request.session["task"] += ['baz'] context = { "foo": request.session['foo'], "form": NewLineItemForm() } return render(request, "index.html", context) I was wondering how I can keep what's intended in the first block without having to rely on the changes in the second block. Thank you. -
How to do infinite task in Django?
I tried to find this question and found that I need Celery django-background-task What I need to do: After an certain action is done(i.e. button is pressed) This button will start a view that in the end of it launches the other view This other view will be infinite times done every second for 30days from the moment when button was pressed, even if the user is offline this task is making on background and it's updating some information in the database. Views.py def starts_code() if "btn" in request.POST: #some code is making and here is launching other view return HttpResponse() The main things is that for every user is his infinitive task, and in database is this model: user_id, when infinite task starts, and that ends after 30days. I don't ask how to do it, but if it's possible some tips and how to do for every user his infinite task -
How to load a related Django Primary Key Object to render it on html in a loop
I have almost the same problem like this post in stackoverflowenter link description here. I did it like the example... it doesn't work. I have many Posts and some of them has Attachments. Each Post belongs to a Contact. class Post(models.Model): contact = models.ForeignKey(Contact, on_delete=models.CASCADE, verbose_name='Owner') content = models.TextField(verbose_name='Text') class Attachment(models.Model): post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name="post_attachments") file = models.FileField(upload_to=upload_location) filename = models.CharField(verbose_name='Filename', max_length=50, default='') views.py posts = contact.post_set.all().prefetch_related('post_attachments').order_by('-created_at') context = {'contact': contact, 'posts': posts,} return render(request, 'contact_feed.html', context) contact_feed.html {% for post in posts %} <div class="col">{{ post.content|safe }}</div> {% for attachment in post.post_attachments.all %} <div class="col">Dateianhänge {{ attachment.filename }}</div> {% endfor %} {% endfor %} This doesn't work. Where is the problem? Thanks! -
Django Firebase Phone Number Auth
i have already django project that completey woks fine with costum user model phone and password for register and sign up, here i need to add firebase phone number authentication to send sms to user befor register to my site prettier any help here . my custom user model ''' class MyUser(AbstractBaseUser): email = models.EmailField(blank=True,null=True, verbose_name='Email Address',max_length=255 ) name = models.CharField(max_length=100,verbose_name= 'Username', ) last_name = models.CharField(blank=True,max_length=100,verbose_name= 'Family Name') mobile = models.IntegerField(unique=True,verbose_name= 'Mobile Number') governorate = models.CharField(blank=True,null=True,verbose_name='Governorate',max_length=255) image =models.ImageField(blank=True,upload_to='profile_pics', default='profile_pics/avatar.png') Is_Banned = models.BooleanField(default=False) notification =models.BooleanField(default=False,verbose_name= 'Enable Notification') language_choices =( ("Arabic", "Arabic"), ("English", "English"), ("Kurdish", "Kurdish"), ) language = models.CharField( choices = language_choices,blank=True, default = 'Arabic',max_length=50,verbose_name= 'Language') is_admin = models.BooleanField(default=False) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) objects = MyUserManager() USERNAME_FIELD = 'mobile' REQUIRED_FIELDS = ['name','email'] def __str__(self): return self.name class Meta: verbose_name_plural='Users' def Adressess(self): return 'adressess' def has_perm(self, perm, obj=None): return self.is_admin def has_module_perms(self, app_label): return True @property def is_staff(self): return self.is_admin @property def first_name(self): return self.name '''i upload mysite here -
populate data in amchart django
models.py: class Order(models.Model): product = models.ForeignKey(Product, on_delete=models.CASCADE, null=True) order_quantity = models.PositiveIntegerField(null=True) date = models.DateTimeField(auto_now_add=True) class Product(models.Model): name = models.CharField(max_length=100, choices=PRODUCTS, null = True) rate = models.PositiveIntegerField(null = True) Views.py: def index(request): orders = Order.objects.all() context = { 'orders': orders, } return render(request,'index.html', context) Here I have multiple orders for samsung, apple etc. There should be only one data for samsung, apple and so on. How can I aggregate order_quantity for each product and send data as the format required for the data? I need the following data format to show data in amchart bar diagram. How can I achieve it? Format required for graph var data = [ { name: "Samsung", value: 35654, }, { name: "Apple", value: 65456, }, { name: "Xiomi", value: 45724, }, ]; -
AttributeError at /callback/ module 'zeep.client' has no attribute 'service'
when I want to use the zeep package in django for the payment gateway, I face an error. error image, code image callback function in views.py in shop app: # Callback function def callback(request): if request.GET.get('Status') == 'NOK': authority = request.GET.get('authority') invoice = get_object_or_404(models.Invoice, authority=authority) amount = 0 order = invoice.order order_items = models.OrderItem.objects.filter(order=order) for item in order_items: amount += item.product_cost result = client.service.PaymentVerification(MERCHANT, authority, amount) if result.Status == 100: return render(request, 'callback.html', {'invoice': invoice}) else: return HttpResponse('error ' + str(result.Status)) else: return HttpResponse('error ') -
How to use csrf token in javascript with django api
I wish to post data from javascript to an api implemented in django. But I cannot get beyond the csrf token settings.py ... CSRF_TRUSTED_ORIGINS = [ 'http://localhost:8888' ] ... MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sites.middleware.CurrentSiteMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', ... views.py class SaveArchive(View): ... @requires_csrf_token def post(self, request, params): ... *api.js ... async function sendDataToAPI(url, post_data) { let endpoint = `${process.env.API_DOMAIN}${url}/`; var getToken= new XMLHttpRequest(); getToken.open("POST", endpoint, true); getToken.setRequestHeader('Content-Type', 'application/json'); getToken.send(JSON.stringify(post_data)); return; ... I get the error on the django server Forbidden (CSRF cookie not set.): /api/save-archive/{...}/ What needs changing? -
Two ViewSet in one url
I'm trying to build urlpatterns using two viewset. Let's say I have: class ArticleViewSet(ModelViewSet): queryset = Article.objects.all() serializer_class = ArticleSerializer class CommentViewSet(ModelViewSet): queryset = Comment.objects.all() serializer_class = CommentSerializer permission_classes = [IsAuthenticated] and I would like to create url like this: /article/{article_id}/comments To simply add a lot of comments to selected article and e.g. to be able also delete comment by: /article/{article_id}/comments/{comment_id) How my urls.py should look? -
Django, how to create a path: <model_id>/<model_id>/template
The background to this question, is because I am trying to a find a way to build a 2 sided interface with 2 different user types. Users type 1 will be able to define certain actions to be performed by Users type 2 Users type 2 will have access to the tasks provided by user type 1.However, all users type 2 will not have access to all the tasks. User Type 2 A might have different actions than User Type 2 B. By setting up a path <model_id>/<model_id>/template, I thought it would be a good way to provide clarity in the url path and also filter access to data. Taking the example of a Model called Project, when looking to link to a single pk_id, I normally do something like this: #views.py def show_project(request, project_id): projects = Project.objects.get(pk=project_id) return render(request, 'main/show_project.html',{'projects':projects}) #url.py path('show_project/<project_id>',views.show_project,name="show-project"), #template.py (referrer) <a class="btn btn-outline-secondary" href="{% url 'show-project' project.id %}">{{project}}</a> Doing this allows me to obvioulsy filter what I want to show based on the ID of the model. I thought I could do something similar by adding another layer <model_id>/<model_id>/template. To stick to the example above: <user_id>/<project_id>/template. So I came up with the following, which visibly … -
GraphQL mutation Invalid payload
I have the following mutation mutation createFoo { createFoo(data: {title: "Test"}) { foo { id title } } } When I ran I got the error AssertionError: 'errors' unexpectedly found in ['errors', 'data'] : {'errors': [{'message': 'Invalid payload', 'locations': [{'line': 3, 'column': 17}], 'path': ['createFoo']}], 'data': {'createFoo': None}} What can be? -
Get queryset of same multiple id's of a model in django
here is my models .. class Log(models.Model): vehicle = models.ForeignKey(Vehicle, on_delete=models.CASCADE) date = models.DateField(default=timezone.now, blank=True, null=True) class Logsheet(models.Model): log = models.ForeignKey(Log, on_delete=models.CASCADE, related_name="logsheets") driver = models.ForeignKey(Driver, on_delete=models.CASCADE, blank=True, null=True) trip = models.IntegerField(blank=False, null=False) distance_from = models.FloatField(blank=True, null=True, default=0.0) distance_to = models.FloatField(blank=True, null=True, default=0.0) time_from = models.TimeField(blank=False, null=False ,default=timezone.now) time_to = models.TimeField(blank=False, null=False ,default=timezone.now) source = models.CharField(max_length=100, blank=True, null=True) destination = models.CharField(max_length=100, blank=True, null=True) doeking_km = models.FloatField(blank=True, null=True, default=0.0) And here is my views for creating logsheet def create_logsheet(request): drivers = Driver.objects.all() vehicles = Vehicle.objects.all() if request.method == "POST": vehicle_id = request.POST.get("vehicle") vehicle = Vehicle.objects.get(id=vehicle_id) date = request.POST.get("date") # logsheet data trip = request.POST.getlist("trip") time_from = request.POST.getlist("time_from") time_to = request.POST.getlist("time_to") source = request.POST.getlist("source") destination = request.POST.getlist("destination") distance_from = request.POST.getlist("distance_from") distance_to = request.POST.getlist("distance_to") driver_id = request.POST.getlist("driver") driver = Driver.objects.filter(id__in=driver_id) print(driver) #main logic if vehicle and driver and date: log = Log(vehicle=vehicle, date=date) log.save() data = zip(trip, driver, distance_from, distance_to,time_from, time_to, source, destination) for trip,driver, distance_from, distance_to, time_from, time_to, source, destination in data: if trip and driver and distance_from and distance_to and time_from and time_to and source and destination: logdetail = Logsheet( log=log, trip=trip, driver=driver, distance_from=distance_from, distance_to=distance_to, time_from=time_from, time_to=time_to, source=source, destination=destination, ) logdetail.save() return redirect("logsheet_list") Problem: When i want same driver fro multiple … -
How do I view the cookies a django Response is attempting to set?
My understanding is that when a server wants to send a client cookies, it sends them in the HTTP response in one (or multiple) Set-Cookie headers which contain the name-value pairs of a cookie in the form name=value. I am trying to view this header from a django HttpResponse object. I figured this would be available from the HttpResponse.headers attribute. However, when I print the response.headers, I don't see any Set-Cookie headers, even though I KNOW that cookies are being set on the client side (I am logging into and out of the django admin console, and I see in Google Chrome that the sessionid cookie is being set and cleared). How do I view the cookie values and the Set-Cookie headers from a django HttpResponse object? I know I can set cookies using HttpResponse.set_cookie(), but how do I view cookies that are already set? Why does it appear to be invisible?