django-views Questions
4
How do you cache a paginated Django queryset, specifically in a ListView?
I noticed one query was taking a long time to run, so I'm attempting to cache it. The queryset is huge (over 100k records)...
Merna asked 13/1, 2014 at 4:9
2
Solved
I need to select several objects to be deleted from my database in django using a webpage. There is no category to select from so I can't delete from all of them like that. Do I have to implement m...
Gardant asked 4/2, 2012 at 18:24
1
I am using Djoser to create an authentication backend. I want the following to happen:
User registers at http://localhost:8000/auth/users/ with email, username, password, and re_password
User rece...
Noiseless asked 15/7, 2021 at 22:13
3
Solved
I keep receiving the error Could not import movies.views. Error was: No module named models
Here is my traceback:
Environment:
Request Method: GET
Request URL: http://localhost:8000/movies/a...
Clarence asked 6/11, 2012 at 19:16
9
Solved
When I tried to relate an attribute with another one which has an M to M relation I received this error:
get() returned more than one topic -- it returned 2!
Can you guys tell me what that mea...
Hoicks asked 27/2, 2014 at 9:6
5
Suppose the parameter I want to pass is called printdata, and printdata=['a', 'b', 'c'].
I use "input type="hidden" name="alist" value={{printdata}}>" to pass
the parameter. However, when I try...
Solubilize asked 2/1, 2011 at 23:28
4
Solved
Suppose I have a url that has php style parameters, that is:
http://example.com/blah?param1=val1&param2=val2
And, I want to place their values into the generated HTML of the template.
How do I...
Peck asked 3/6, 2011 at 9:11
10
Solved
This is related to this question: Django return json and html depending on client python
I have a command line Python API for a Django app. When I access the app through the API it should return...
Prieto asked 13/2, 2012 at 14:36
5
Solved
If I have a class based view, like this,
class SomeView (View):
response_template='some_template.html'
var1 = 0
var2 = 1
def get(self, request, *args, **kwargs):
return render_to_response(s...
Headstall asked 14/8, 2013 at 13:18
5
Solved
My models.py
class Order(models.Model):
user = models.ForeignKey(User, blank=True, null=True, on_delete=models.PROTECT)
customer_email = models.EmailField(blank=True, null=True, default=None)
c...
Gifted asked 12/2, 2019 at 17:39
3
Solved
I have deployed a Django project using Apache2, everything is working fine except for weazyprint which creates PDF file for forms. The pdf was working fine in testing and local host.
Now everytime ...
Smearcase asked 10/8, 2021 at 2:41
16
Solved
I am trying to process a form in django/python using the following code.
home.html:
<form action="{% url 'home:submit' %}" method='post'>
views.py:
def submit(request):
a = requ...
Godavari asked 26/1, 2017 at 21:25
4
I am trying to use a for loop in my template but I am getting an error.
Here is the Jinja:
{% for i in range(1,10) %}
<h2>{{i}}</h2>
{% endfor %}
Here is the error:
django.template.e...
Alphonsa asked 6/2, 2018 at 7:0
7
Solved
I'm trying to get the next and previous objects of a comic book issue. Simply changing the id number or filtering through date added is not going to work because I don't add the issues sequentially...
Lustre asked 16/5, 2011 at 18:28
4
I am working on a chat app that has Rooms. Each room has two users. A user can be in multiple rooms i.e, a user has multiple rooms. And now he is chatting in one room. But he receives a message in ...
Indulge asked 30/7, 2018 at 17:21
4
Solved
I have a venue, this venue has many events happening there. My models look like this:
class Venue(models.Model):
title = models.CharField(max_length=200)
date_published = models.DateTimeField('pu...
Malfunction asked 9/3, 2013 at 3:43
10
How can I get information about the logged-in user in a Django application?
For example:
I need to know the username of the logged-in user to say who posted a Review:
<form id='formulario' metho...
Determine asked 3/6, 2013 at 21:57
6
Solved
I'm trying to create a middleware to optionally pass a kwarg to every view that meets a condition.
The problem is that I cannot find an example of how to set up the middleware. I have seen classes ...
Wallen asked 19/8, 2013 at 20:10
3
Solved
I have a pretty simply utility function that gets an open web order if their is a session key called 'orderId', and will create one if there is no session key, and the parameter 'createIfNotFound' ...
Scapegrace asked 12/9, 2016 at 19:22
3
Solved
I have a model
class Survey(models.Model):
created_by = models.ForeignKey(User)
question = models.CharField(max_length=150)
active = models.NullBooleanField()
def __unicode__(self):
return s...
Tahr asked 16/12, 2012 at 12:21
5
Solved
Say I have a form that looks like this:
forms.py
class CreateASomethingForm(ModelForm):
class Meta:
model = Something
fields = ['field2', 'field3', 'field4']
I want the form to have these th...
Omit asked 15/6, 2013 at 19:7
1
I could set the cookies with response.set_cookie() and response.cookies[] as shown below. *I use Django 4.2.1:
# "my_app1/views.py"
from django.http import HttpResponse
def test(request...
Houseraising asked 4/7, 2023 at 19:22
6
Solved
I want to set a cookie inside a view and then have that view render a template. As I understand it, this is the way to set a cookie:
def index(request):
response = HttpResponse('blah')
response.s...
Jacktar asked 12/6, 2013 at 4:10
3
Solved
I'm building an application in Django which allows the end-user to retrieve information which is sensitive to the time of day (12 am to 12 am) on a given day. I store this information in my databas...
Rouault asked 29/12, 2017 at 19:33
4
Solved
I have a project with two apps with their respective views, but I want to create a views.py in django project directory for some generic pages such as about, login... It is correct to place the vie...
Memorial asked 1/12, 2016 at 15:31
© 2022 - 2024 — McMap. All rights reserved.