Questions tagged [django-views]

Django views are MVC views; they control rendering (typically through templates), and the data displayed.

Django views are MVC views; they control rendering (typically through templates) and the data displayed.

It is possible to create generic views, which are specialised on various parameters (frequently model classes), which are simply paired with an appropriate template to create a complete page.

The separation from the template system also makes it very easy to create output in different formats, or use one view for several, quite different looking pages (usually with similar data).

There are two types of views: the Class based view (CBV for short) and Function based views (FBV). The use cases differ for each one and whilst later versions of Django advocate the use of Class based views the Function based views aren't fully deprecated.

CBV's enables better code reuse, inheritance and mixins. Further reading can be found here

An example of a Class based view:

from django.views.generic import UpdateView
from myapp.models import Author

class AuthorUpdate(UpdateView):
    model = Author
    fields = ['name']
    template_name_suffix = '_update_form'

An example of a Function based view:

def update_account_view(request, account_id):
    # Do some account stuff
    context = {'account': some_object, 'another_key': 'value'}
    return render_to_response('templates/account_update.html', 
                              context, 
                              context_instance=RequestContext(request))
24045 questions
44
votes
2 answers

Getting 'str' object has no attribute 'get' in Django

views.py def generate_xml(request, number): caller_id = 'x-x-x-x' resp = twilio.twiml.Response() with resp.dial(callerId=caller_id) as r: if number and re.search('[\d\(\)\- \+]+$', number): r.number(number) …
user3485393
  • 443
  • 1
  • 4
  • 5
44
votes
1 answer

Raise 404 and continue the URL chain

I've got a URLs pattern like this: urlpatterns = ( url(r'^$', list_titles, name='list'), url(r'^(?P[a-z\-0-9]+?)/$', list_titles, name='filtered-list'), url(r'^(?P\S+?)/$', show_title, name='title'), ) The filtered-list and…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/django-urls" class="post-tag grid--cell" title="show questions tagged 'django-urls'" rel="tag">django-urls</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> <a href="../../questions/tagged/django-signals" class="post-tag grid--cell" title="show questions tagged 'django-signals'" rel="tag">django-signals</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Aug 19 '09 at 12:46">asked Aug 19 '09 at 12:46</time> <a href="../../users/12870/oli" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/12870.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Oli" /> </a> <div class="s-user-card--info"> <a href="../../users/12870/oli" class="s-user-card--link">Oli</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">235,628</li> <li class="s-award-bling s-award-bling__gold" title="64 gold badges">64</li> <li class="s-award-bling s-award-bling__silver" title="220 silver badges">220</li> <li class="s-award-bling s-award-bling__bronze" title="299 bronze badges">299</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-2615042"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>43</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>3</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/2615042/how-do-i-use-logging-in-the-django-debug-toolbar" class="question-hyperlink">How do I use Logging in the Django Debug Toolbar?</a></h3> <div class="excerpt">I would like to output debug messages in my django app at different points in a view function. The docs for the django-debug-toolbar say it uses the build in python logging but I can't find any more information then that. I don't really want to log…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/debugging" class="post-tag grid--cell" title="show questions tagged 'debugging'" rel="tag">debugging</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Apr 10 '10 at 21:24">asked Apr 10 '10 at 21:24</time> <a href="../../users/339/reconbot" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/339.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="reconbot" /> </a> <div class="s-user-card--info"> <a href="../../users/339/reconbot" class="s-user-card--link">reconbot</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">5,138</li> <li class="s-award-bling s-award-bling__gold" title="6 gold badges">6</li> <li class="s-award-bling s-award-bling__silver" title="45 silver badges">45</li> <li class="s-award-bling s-award-bling__bronze" title="63 bronze badges">63</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-18702300"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>43</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/18702300/return-results-from-multiple-models-with-django-rest-framework" class="question-hyperlink">Return results from multiple models with Django REST Framework</a></h3> <div class="excerpt">I have three models — articles, authors and tweets. I'm ultimately needing to use Django REST Framework to construct a feed that aggregates all the objects using the Article and Tweet models into one reverse chronological feed. Any idea how I'd do…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/django-models" class="post-tag grid--cell" title="show questions tagged 'django-models'" rel="tag">django-models</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> <a href="../../questions/tagged/django-rest-framework" class="post-tag grid--cell" title="show questions tagged 'django-rest-framework'" rel="tag">django-rest-framework</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Sep 09 '13 at 15:58">asked Sep 09 '13 at 15:58</time> <a href="../../users/467760/aendra" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/467760.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="aendra" /> </a> <div class="s-user-card--info"> <a href="../../users/467760/aendra" class="s-user-card--link">aendra</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">5,286</li> <li class="s-award-bling s-award-bling__gold" title="3 gold badges">3</li> <li class="s-award-bling s-award-bling__silver" title="38 silver badges">38</li> <li class="s-award-bling s-award-bling__bronze" title="57 bronze badges">57</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-7763115"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>42</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/7763115/django-passing-data-between-views" class="question-hyperlink">Django Passing data between views</a></h3> <div class="excerpt">I was wondering what is the 'best' way of passing data between views. Is it better to create invisible fields and pass it using POST or should I encode it in my URLS? Or is there a better/easier way of doing this? Sorry if this question is stupid,…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Oct 14 '11 at 04:43">asked Oct 14 '11 at 04:43</time> <a href="../../users/388025/iman453" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/388025.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="iman453" /> </a> <div class="s-user-card--info"> <a href="../../users/388025/iman453" class="s-user-card--link">iman453</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">9,105</li> <li class="s-award-bling s-award-bling__gold" title="16 gold badges">16</li> <li class="s-award-bling s-award-bling__silver" title="54 silver badges">54</li> <li class="s-award-bling s-award-bling__bronze" title="70 bronze badges">70</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-20873625"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>42</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>6</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/20873625/pycharm-code-inspection-complains-template-file-not-found-how-to-fix" class="question-hyperlink">PyCharm code inspection complains template file not found, how to fix?</a></h3> <div class="excerpt">I'm new to PyCharm, and I'm trying to use it for Django development. My app is structured like this: bs3app/ ├── __init__.py ├── templates │   └── home.html ├── urls.py └── views.py In bs3app/views.py, I get a warning: Template file 'home.html'…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/django-templates" class="post-tag grid--cell" title="show questions tagged 'django-templates'" rel="tag">django-templates</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> <a href="../../questions/tagged/pycharm" class="post-tag grid--cell" title="show questions tagged 'pycharm'" rel="tag">pycharm</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jan 01 '14 at 21:46">asked Jan 01 '14 at 21:46</time> <a href="../../users/641955/janos" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/641955.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="janos" /> </a> <div class="s-user-card--info"> <a href="../../users/641955/janos" class="s-user-card--link">janos</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">120,954</li> <li class="s-award-bling s-award-bling__gold" title="29 gold badges">29</li> <li class="s-award-bling s-award-bling__silver" title="226 silver badges">226</li> <li class="s-award-bling s-award-bling__bronze" title="236 bronze badges">236</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-19986089"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>42</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>5</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/19986089/init-got-an-unexpected-keyword-argument-user" class="question-hyperlink">__init__() got an unexpected keyword argument 'user'</a></h3> <div class="excerpt">i am using Django to create a user and an object when the user is created. But there is an error __init__() got an unexpected keyword argument 'user' when calling the register() function in view.py. The function is: def register(request): …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/django-models" class="post-tag grid--cell" title="show questions tagged 'django-models'" rel="tag">django-models</a> <a href="../../questions/tagged/django-forms" class="post-tag grid--cell" title="show questions tagged 'django-forms'" rel="tag">django-forms</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Nov 14 '13 at 18:59">asked Nov 14 '13 at 18:59</time> <a href="../../users/2284861/noben" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2284861.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="noben" /> </a> <div class="s-user-card--info"> <a href="../../users/2284861/noben" class="s-user-card--link">noben</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">531</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="7 silver badge">7</li> <li class="s-award-bling s-award-bling__bronze" title="16 bronze badge">16</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-17192737"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>42</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>8</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/17192737/django-class-based-view-for-both-create-and-update" class="question-hyperlink">Django Class Based View for both Create and Update</a></h3> <div class="excerpt">Say I want to create a Class Based View which both updates and creates an object. From a previous question I worked out I could do one of the following things: 1) Use 2 generic views CreateView and UpdateView which I think would mean having two…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/django-models" class="post-tag grid--cell" title="show questions tagged 'django-models'" rel="tag">django-models</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> <a href="../../questions/tagged/django-class-based-views" class="post-tag grid--cell" title="show questions tagged 'django-class-based-views'" rel="tag">django-class-based-views</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 19 '13 at 13:38">asked Jun 19 '13 at 13:38</time> <a href="../../users/2299875/grantu" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2299875.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="GrantU" /> </a> <div class="s-user-card--info"> <a href="../../users/2299875/grantu" class="s-user-card--link">GrantU</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">6,325</li> <li class="s-award-bling s-award-bling__gold" title="16 gold badges">16</li> <li class="s-award-bling s-award-bling__silver" title="59 silver badges">59</li> <li class="s-award-bling s-award-bling__bronze" title="89 bronze badges">89</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-4313508"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>41</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>5</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/4313508/execute-code-in-django-after-response-has-been-sent-to-the-client" class="question-hyperlink">Execute code in Django after response has been sent to the client</a></h3> <div class="excerpt">In my Django application I want to keep track of whether a response has been sent to the client successfully. I am well aware that there is no "watertight" way in a connectionless protocol like HTTP to ensure the client has received (and displayed)…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/http" class="post-tag grid--cell" title="show questions tagged 'http'" rel="tag">http</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> <a href="../../questions/tagged/httpresponse" class="post-tag grid--cell" title="show questions tagged 'httpresponse'" rel="tag">httpresponse</a> <a href="../../questions/tagged/django-middleware" class="post-tag grid--cell" title="show questions tagged 'django-middleware'" rel="tag">django-middleware</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Nov 30 '10 at 12:04">asked Nov 30 '10 at 12:04</time> <a href="../../users/171579/florian-ledermann" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/171579.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Florian Ledermann" /> </a> <div class="s-user-card--info"> <a href="../../users/171579/florian-ledermann" class="s-user-card--link">Florian Ledermann</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">3,187</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="29 silver badge">29</li> <li class="s-award-bling s-award-bling__bronze" title="33 bronze badge">33</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-34438290"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>41</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>9</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/34438290/assertionerror-hyperlinkedidentityfield-requires-the-request-in-the-serializer" class="question-hyperlink">AssertionError: `HyperlinkedIdentityField` requires the request in the serializer context</a></h3> <div class="excerpt">I want to create a many-to-many relationship where one person can be in many clubs and one club can have many persons. I added the models.py and serializers.py for the following logic but when I try to serialize it in the command prompt, I get the…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> <a href="../../questions/tagged/django-rest-framework" class="post-tag grid--cell" title="show questions tagged 'django-rest-framework'" rel="tag">django-rest-framework</a> <a href="../../questions/tagged/django-serializer" class="post-tag grid--cell" title="show questions tagged 'django-serializer'" rel="tag">django-serializer</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 23 '15 at 14:54">asked Dec 23 '15 at 14:54</time> <a href="../../users/4966987/qwertp" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/4966987.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="qwertp" /> </a> <div class="s-user-card--info"> <a href="../../users/4966987/qwertp" class="s-user-card--link">qwertp</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">839</li> <li class="s-award-bling s-award-bling__gold" title="3 gold badges">3</li> <li class="s-award-bling s-award-bling__silver" title="11 silver badges">11</li> <li class="s-award-bling s-award-bling__bronze" title="16 bronze badges">16</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-3201018"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>41</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>5</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/3201018/django-internationalization-language-codes" class="question-hyperlink">Django internationalization language codes</a></h3> <div class="excerpt">Where can I find list of languages and language_code like this. (Swedish,sv) (English,en) </div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/internationalization" class="post-tag grid--cell" title="show questions tagged 'internationalization'" rel="tag">internationalization</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> <a href="../../questions/tagged/django-i18n" class="post-tag grid--cell" title="show questions tagged 'django-i18n'" rel="tag">django-i18n</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jul 08 '10 at 06:02">asked Jul 08 '10 at 06:02</time> <a href="../../users/221149/hulk" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/221149.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Hulk" /> </a> <div class="s-user-card--info"> <a href="../../users/221149/hulk" class="s-user-card--link">Hulk</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">32,860</li> <li class="s-award-bling s-award-bling__gold" title="62 gold badges">62</li> <li class="s-award-bling s-award-bling__silver" title="144 silver badges">144</li> <li class="s-award-bling s-award-bling__bronze" title="215 bronze badges">215</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-5219430"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>40</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/5219430/access-tuple-in-django-template" class="question-hyperlink">Access tuple in django template</a></h3> <div class="excerpt"> t=[] t.append(("a",1)) t.append(("b",2)) t.append(("c",3)) return render_to_response(t.html, context_instance=RequestContext(request, {'t':t})) How can I access a value of t in Django templates without using a for loop? I have tried the…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/django-models" class="post-tag grid--cell" title="show questions tagged 'django-models'" rel="tag">django-models</a> <a href="../../questions/tagged/django-templates" class="post-tag grid--cell" title="show questions tagged 'django-templates'" rel="tag">django-templates</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Mar 07 '11 at 11:58">asked Mar 07 '11 at 11:58</time> <a href="../../users/277603/rajeev" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/277603.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Rajeev" /> </a> <div class="s-user-card--info"> <a href="../../users/277603/rajeev" class="s-user-card--link">Rajeev</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">44,985</li> <li class="s-award-bling s-award-bling__gold" title="76 gold badges">76</li> <li class="s-award-bling s-award-bling__silver" title="186 silver badges">186</li> <li class="s-award-bling s-award-bling__bronze" title="285 bronze badges">285</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-9899113"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>39</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/9899113/get-request-session-from-a-class-based-generic-view" class="question-hyperlink">Get request.session from a class-based generic view</a></h3> <div class="excerpt">Is there a way to get request.session from inside a class-based view? For instance, I have from django.views.generic.edit import FormView class CreateProfileView(FormView): def form_valid(self, form): # --> would like to save form…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Mar 27 '12 at 23:22">asked Mar 27 '12 at 23:22</time> <a href="../../users/1161906/bcattle" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1161906.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="bcattle" /> </a> <div class="s-user-card--info"> <a href="../../users/1161906/bcattle" class="s-user-card--link">bcattle</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">12,115</li> <li class="s-award-bling s-award-bling__gold" title="6 gold badges">6</li> <li class="s-award-bling s-award-bling__silver" title="62 silver badges">62</li> <li class="s-award-bling s-award-bling__bronze" title="82 bronze badges">82</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-8541956"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>39</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>9</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/8541956/django-admin-add-extra-row-with-totals" class="question-hyperlink">django-admin: Add extra row with totals</a></h3> <div class="excerpt">I'm using the standard django admin module to display a list of rows. One of the columns is a numerical field. I'd like to display an extra 'totals' row that has most of the columns as blank, except for the numerical column, which should be the…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/django-admin" class="post-tag grid--cell" title="show questions tagged 'django-admin'" rel="tag">django-admin</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> <a href="../../questions/tagged/django-1.2" class="post-tag grid--cell" title="show questions tagged 'django-1.2'" rel="tag">django-1.2</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 17 '11 at 01:34">asked Dec 17 '11 at 01:34</time> <a href="../../users/15055/claudiu" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/15055.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Claudiu" /> </a> <div class="s-user-card--info"> <a href="../../users/15055/claudiu" class="s-user-card--link">Claudiu</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">224,032</li> <li class="s-award-bling s-award-bling__gold" title="165 gold badges">165</li> <li class="s-award-bling s-award-bling__silver" title="485 silver badges">485</li> <li class="s-award-bling s-award-bling__bronze" title="680 bronze badges">680</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-13544504"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>39</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/13544504/django-form-got-multiple-values-for-keyword-argument" class="question-hyperlink">django form got multiple values for keyword argument</a></h3> <div class="excerpt">I have a simple model as follows: RATING_CHOICES = zip(range(1, 6), range(1, 6)) class Rating(models.Model): value = models.IntegerField(choices=RATING_CHOICES) additional_note = models.TextField(null=True, blank=True) from_user =…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/django" class="post-tag grid--cell" title="show questions tagged 'django'" rel="tag">django</a> <a href="../../questions/tagged/django-forms" class="post-tag grid--cell" title="show questions tagged 'django-forms'" rel="tag">django-forms</a> <a href="../../questions/tagged/django-views" class="post-tag grid--cell" title="show questions tagged 'django-views'" rel="tag">django-views</a> <a href="../../questions/tagged/django-urls" class="post-tag grid--cell" title="show questions tagged 'django-urls'" rel="tag">django-urls</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Nov 24 '12 at 18:59">asked Nov 24 '12 at 18:59</time> <a href="../../users/648866/whatf" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/648866.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="whatf" /> </a> <div class="s-user-card--info"> <a href="../../users/648866/whatf" class="s-user-card--link">whatf</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">6,378</li> <li class="s-award-bling s-award-bling__gold" title="14 gold badges">14</li> <li class="s-award-bling s-award-bling__silver" title="49 silver badges">49</li> <li class="s-award-bling s-award-bling__bronze" title="78 bronze badges">78</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <a class="s-pagination--item" href="../../questions/tagged/django-views_page=5" rel="prev" title="Go to page 5">Prev </a> <a class="s-pagination--item" href="../../questions/tagged/django-views_page=1" rel="" title="Go to page 1">1</a> <a class="s-pagination--item" href="../../questions/tagged/django-views_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/django-views_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/django-views_page=99" rel="" title="Go to page 99">99</a> <a class="s-pagination--item" href="../../questions/tagged/django-views_page=100" rel="" title="Go to page 100">100</a> <a class="s-pagination--item" href="../../questions/tagged/django-views_page=7" rel="next" title="Go to page 7"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>