Ticket 19239 - Examples for Django Date based CBVs #517

Closed
wants to merge 12 commits into
from

Conversation

Projects
None yet
3 participants
Contributor

pydanny commented Nov 14, 2012

Provides: Working, tested examples for all Django Date based CBVs

Issue: git config just isn't working on my laptop. This always happens, even if I follow documentation exactly. Submitting anyway and will get physically with person with git experience to hammer out this issue going forward.

@@ -108,6 +149,64 @@ YearArchiveView
**Notes**
* Uses a default ``template_name_suffix`` of ``_archive_year``.
+
+ ArchiveView's use :doc:`date-based mixins</ref/class-based-views/mixins-date-based>`. and uses the
@timgraham

timgraham Nov 16, 2012

Owner

did some text get lost here? there's a period then a fragment

@pydanny

pydanny Nov 17, 2012

Contributor

I beieve this would be better handled in the mixins-date-based reference so taking it out.

@@ -30,11 +46,36 @@ ArchiveIndexView
**Notes**
* Uses a default ``context_object_name`` of ``latest``.
- * Uses a default ``template_name_suffix`` of ``_archive``.
+ * Uses a default ``template_name_suffix`` of ``_archive.html``.
@timgraham

timgraham Nov 16, 2012

Owner

Don't think this should be changed to be consistent with the rest of the docs

+
+ urlpatterns = patterns('',
+ url(r'^(?P<year>\d{4})/$',
+ ArticleYearArchiveView.as_view(),
@timgraham

timgraham Nov 16, 2012

Owner

indent 4 spaces?

+ urlpatterns = patterns('',
+ # Example: /2012/week/23/
+ url(r'^(?P<year>\d{4})/week/(?P<week>\d+)/$',
+ ArticleWeekArchiveView.as_view(),
@timgraham

timgraham Nov 16, 2012

Owner

indent 4 spaces?

+ begins on a Monday. The ``'%W'`` format is the same in both the
+ :func:`~time.strftime` and the :tfilter:`date`.
+
+ However, the :tfilter:`date` template filter does not have an equvilant output
@timgraham

timgraham Nov 16, 2012

Owner

typo: equivalent

+
+ However, the :tfilter:`date` template filter does not have an equvilant output
+ format that supports the US based week system. The :tfilter:`date`
+ filter ``'%U'`` outputs the number of seconds since the unix epoch.
@timgraham

timgraham Nov 16, 2012

Owner

capitalize Unix

+ urlpatterns = patterns('',
+ # Example: /2012/nov/10/
+ url(r'^(?P<year>\d{4})/(?P<month>[-\w]+)/(?P<day>\d+)/$',
+ ArticleDayArchiveView.as_view(),
@timgraham

timgraham Nov 16, 2012

Owner

indent 4 spaces?

+
+ urlpatterns = patterns('',
+ url(r'^today/$',
+ ArticleTodayArchiveView.as_view(),
@timgraham

timgraham Nov 16, 2012

Owner

indent 4 spaces?

@@ -289,6 +551,45 @@ TodayArchiveView
* :class:`django.views.generic.dates.DateMixin`
* :class:`django.views.generic.base.View`
+ **Notes**
+
+ * Uses a default template name of ``<model>_archive_today.html``.
@timgraham

timgraham Nov 16, 2012

Owner

use same style as previous examples: "Uses a default template_name_suffix of _archive_today.

@@ -333,4 +634,29 @@ DateDetailView
.. class:: BaseDateDetailView
+ **Context**
+
+ * Includes the single object associated with the ``model`` specified in the ``DateDetailView``.
@timgraham

timgraham Nov 16, 2012

Owner

line wrapping

+
+**Notes**
+
+* Uses a default template name of ``<app_name>/<model>_detail.html``.
@timgraham

timgraham Nov 16, 2012

Owner

same as noted earlier

@@ -333,4 +634,29 @@ DateDetailView
.. class:: BaseDateDetailView
+ **Context**
@timgraham

timgraham Nov 16, 2012

Owner

this renders inside the "note" box, not sure that's desired?

@pydanny

pydanny Nov 17, 2012

Contributor

I did that to reinforce the concept of code reuse which pervades CBVs. Since all but one of the previous examples had new templates and this was the exception I wanted to highlight said 'exception'.

Owner

timgraham commented Nov 16, 2012

Thanks for this guys, looks solid. The other comment I have overall is that there some switching between using code-block and double-colon for highlighting. It'd be nice to stick with one or the other. My vote would be double-colon.

Contributor

pydanny commented Nov 17, 2012

Tim,

Thank you so much for this exacting review. We'll revise this and resubmit
shortly.

On core Django normally I use double-colon, but for personal work I use
code-block. I let that habit get into the wrong project. ;-)

On Fri, Nov 16, 2012 at 3:09 PM, Tim Graham notifications@github.comwrote:

Thanks for this guys, looks solid. The other comment I have overall is
that there some switching between using code-block and double-colon for
highlighting. It'd be nice to stick with one or the other. My vote would be
double-colon.


Reply to this email directly or view it on GitHubhttps://github.com/django/django/pull/517#issuecomment-10465945.

'Knowledge is Power'
Daniel Greenfeld
http://pydanny.com

Owner

timgraham commented Nov 28, 2012

Made a few more edits and merged this. Thank-you Danny and Scott!

@timgraham timgraham closed this Nov 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment