Loading AUTHORS +3 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,7 @@ answer newbie questions, and generally made Django that much better: J. Clifford Dyer <jcd@sdf.lonestar.org> Clint Ecker Nick Efford <nick@efford.org> Marc Egli <frog32@me.com> eibaan@gmail.com David Eklund Julia Elman Loading @@ -221,6 +222,7 @@ answer newbie questions, and generally made Django that much better: Stefane Fermgier <sf@fermigier.com> J. Pablo Fernandez <pupeno@pupeno.com> Maciej Fijalkowski Leandra Finger <leandra.finger@gmail.com> Juan Pedro Fisanotti <fisadev@gmail.com> Ben Firshman <ben@firshman.co.uk> Matthew Flanagan <http://wadofstuff.blogspot.com> Loading Loading @@ -531,6 +533,7 @@ answer newbie questions, and generally made Django that much better: Don Spaulding <donspauldingii@gmail.com> Calvin Spealman <ironfroggy@gmail.com> Dane Springmeyer Silvan Spross <silvan.spross@gmail.com> Bjørn Stabell <bjorn@exoweb.net> Georgi Stanojevski <glisha@gmail.com> starrynight <cmorgh@gmail.com> Loading docs/intro/overview.txt +4 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ representing your models -- so far, it's been solving two years' worth of database-schema problems. Here's a quick example, which might be saved in the file ``mysite/news/models.py``:: from django.db import models class Reporter(models.Model): full_name = models.CharField(max_length=70) Loading Loading @@ -214,6 +216,8 @@ Generally, a view retrieves data according to the parameters, loads a template and renders the template with the retrieved data. Here's an example view for ``year_archive`` from above:: from django.shortcuts import render_to_response def year_archive(request, year): a_list = Article.objects.filter(pub_date__year=year) return render_to_response('news/year_archive.html', {'year': year, 'article_list': a_list}) Loading docs/intro/tutorial01.txt +2 −0 Original line number Diff line number Diff line Loading @@ -582,6 +582,8 @@ of this object. Let's fix that by editing the polls model (in the ``Choice``. On Python 3, simply replace ``__unicode__`` by ``__str__`` in the following example:: from django.db import models class Poll(models.Model): # ... def __unicode__(self): # Python 3: def __str__(self): Loading docs/intro/tutorial02.txt +16 −0 Original line number Diff line number Diff line Loading @@ -158,6 +158,9 @@ you want when you register the object. Let's see how this works by re-ordering the fields on the edit form. Replace the ``admin.site.register(Poll)`` line with:: from django.contrib import admin from polls.models import Poll class PollAdmin(admin.ModelAdmin): fields = ['pub_date', 'question'] Loading @@ -179,6 +182,9 @@ of fields, choosing an intuitive order is an important usability detail. And speaking of forms with dozens of fields, you might want to split the form up into fieldsets:: from django.contrib import admin from polls.models import Poll class PollAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['question']}), Loading @@ -198,6 +204,9 @@ You can assign arbitrary HTML classes to each fieldset. Django provides a This is useful when you have a long form that contains a number of fields that aren't commonly used:: from django.contrib import admin from polls.models import Poll class PollAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['question']}), Loading @@ -218,6 +227,7 @@ Yet. There are two ways to solve this problem. The first is to register ``Choice`` with the admin just as we did with ``Poll``. That's easy:: from django.contrib import admin from polls.models import Choice admin.site.register(Choice) Loading Loading @@ -342,6 +352,12 @@ representation of the output. You can improve that by giving that method (in :file:`polls/models.py`) a few attributes, as follows:: import datetime from django.utils import timezone from django.db import models from polls.models import Poll class Poll(models.Model): # ... def was_published_recently(self): Loading docs/intro/tutorial03.txt +5 −0 Original line number Diff line number Diff line Loading @@ -393,6 +393,9 @@ Now, let's tackle the poll detail view -- the page that displays the question for a given poll. Here's the view:: from django.http import Http404 from django.shortcuts import render from polls.models import Poll # ... def detail(request, poll_id): try: Loading Loading @@ -420,6 +423,8 @@ and raise :exc:`~django.http.Http404` if the object doesn't exist. Django provides a shortcut. Here's the ``detail()`` view, rewritten:: from django.shortcuts import render, get_object_or_404 from polls.models import Poll # ... def detail(request, poll_id): poll = get_object_or_404(Poll, pk=poll_id) Loading Loading
AUTHORS +3 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,7 @@ answer newbie questions, and generally made Django that much better: J. Clifford Dyer <jcd@sdf.lonestar.org> Clint Ecker Nick Efford <nick@efford.org> Marc Egli <frog32@me.com> eibaan@gmail.com David Eklund Julia Elman Loading @@ -221,6 +222,7 @@ answer newbie questions, and generally made Django that much better: Stefane Fermgier <sf@fermigier.com> J. Pablo Fernandez <pupeno@pupeno.com> Maciej Fijalkowski Leandra Finger <leandra.finger@gmail.com> Juan Pedro Fisanotti <fisadev@gmail.com> Ben Firshman <ben@firshman.co.uk> Matthew Flanagan <http://wadofstuff.blogspot.com> Loading Loading @@ -531,6 +533,7 @@ answer newbie questions, and generally made Django that much better: Don Spaulding <donspauldingii@gmail.com> Calvin Spealman <ironfroggy@gmail.com> Dane Springmeyer Silvan Spross <silvan.spross@gmail.com> Bjørn Stabell <bjorn@exoweb.net> Georgi Stanojevski <glisha@gmail.com> starrynight <cmorgh@gmail.com> Loading
docs/intro/overview.txt +4 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ representing your models -- so far, it's been solving two years' worth of database-schema problems. Here's a quick example, which might be saved in the file ``mysite/news/models.py``:: from django.db import models class Reporter(models.Model): full_name = models.CharField(max_length=70) Loading Loading @@ -214,6 +216,8 @@ Generally, a view retrieves data according to the parameters, loads a template and renders the template with the retrieved data. Here's an example view for ``year_archive`` from above:: from django.shortcuts import render_to_response def year_archive(request, year): a_list = Article.objects.filter(pub_date__year=year) return render_to_response('news/year_archive.html', {'year': year, 'article_list': a_list}) Loading
docs/intro/tutorial01.txt +2 −0 Original line number Diff line number Diff line Loading @@ -582,6 +582,8 @@ of this object. Let's fix that by editing the polls model (in the ``Choice``. On Python 3, simply replace ``__unicode__`` by ``__str__`` in the following example:: from django.db import models class Poll(models.Model): # ... def __unicode__(self): # Python 3: def __str__(self): Loading
docs/intro/tutorial02.txt +16 −0 Original line number Diff line number Diff line Loading @@ -158,6 +158,9 @@ you want when you register the object. Let's see how this works by re-ordering the fields on the edit form. Replace the ``admin.site.register(Poll)`` line with:: from django.contrib import admin from polls.models import Poll class PollAdmin(admin.ModelAdmin): fields = ['pub_date', 'question'] Loading @@ -179,6 +182,9 @@ of fields, choosing an intuitive order is an important usability detail. And speaking of forms with dozens of fields, you might want to split the form up into fieldsets:: from django.contrib import admin from polls.models import Poll class PollAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['question']}), Loading @@ -198,6 +204,9 @@ You can assign arbitrary HTML classes to each fieldset. Django provides a This is useful when you have a long form that contains a number of fields that aren't commonly used:: from django.contrib import admin from polls.models import Poll class PollAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['question']}), Loading @@ -218,6 +227,7 @@ Yet. There are two ways to solve this problem. The first is to register ``Choice`` with the admin just as we did with ``Poll``. That's easy:: from django.contrib import admin from polls.models import Choice admin.site.register(Choice) Loading Loading @@ -342,6 +352,12 @@ representation of the output. You can improve that by giving that method (in :file:`polls/models.py`) a few attributes, as follows:: import datetime from django.utils import timezone from django.db import models from polls.models import Poll class Poll(models.Model): # ... def was_published_recently(self): Loading
docs/intro/tutorial03.txt +5 −0 Original line number Diff line number Diff line Loading @@ -393,6 +393,9 @@ Now, let's tackle the poll detail view -- the page that displays the question for a given poll. Here's the view:: from django.http import Http404 from django.shortcuts import render from polls.models import Poll # ... def detail(request, poll_id): try: Loading Loading @@ -420,6 +423,8 @@ and raise :exc:`~django.http.Http404` if the object doesn't exist. Django provides a shortcut. Here's the ``detail()`` view, rewritten:: from django.shortcuts import render, get_object_or_404 from polls.models import Poll # ... def detail(request, poll_id): poll = get_object_or_404(Poll, pk=poll_id) Loading