Wednesday, June 29, 2016

"canonical" views.py in Django Unleashed book, Chapter 22

Although I love the book (so far) for its level of detail and addressing a LOT of issues I am currently dealing with, I have run across a problem. Specifically, the views.py and urls.py in the github repo are NOT the same as the snippets of views.py and urls.py in the book. Now, since I started in Chapter 20, because that's where my issues are, it is possible that all of this is explained and cleared up elsewhere, but a quick search in the online version of the book did not reveal same to me, so,as the author himself asks, I am posting here.

Github views.py

starting at line 128:
@class_login_required
class ProfileDetail(
ProfileGetObjectMixin, DetailView):
model = Profile


views.py book example 22.13
 26   from core.utils import UpdateView
...
134   @class_login_required
135   class ProfileUpdate(
136           ProfileGetObjectMixin, UpdateView)
:137       fields = ('about',)
138       model = Profile

There is no core.utils or UpdateView in the github version


views.py in book example 22.19
134   class PublicProfileDetail(DetailView):
135       model = Profile

There is no PublicProfileDetail in the github version


urls.py in book example 22.20
 10   from .views import (
11       ActivateAccount, CreateAccount,
12       DisableAccount, ProfileDetail, ProfileUpdate,
13       PublicProfileDetail, ResendActivationEmail)  .      
...
67   urlpatterns = [  .     
 ...
114       url(r'^(?P<slug>[\w\-]+)/$',
115           PublicProfileDetail.as_view(),
116           name='public_profile'),
117   ]

Again, there is no PublicProfileDetail in the github version, which stops at line 111

There may be more, but that's what I have right now. It does not make sense to me that the author would go to all this trouble to talk about Public Profiles and then omit them, especially since allowing users to both have them and edit them themselves makes so much sense. Now, I do have the code from the book, which is why I framed my question as the "canonical" version of these codes. Thanks.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cf3568a8-5190-4c92-8e9b-9c88b612e14a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment