Thursday, June 30, 2016

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

1. I don't know if it makes any difference, but I don't have the physical book. I am reading it online thru my safarionline subscription.
2. Once I got to your repo, I just clicked around to go to views or urls or whatever. I didn't think of looking for different commits, because I assumed, wrongly, that there would only be one, final, 'canonical' version of the code.
3. Looking specifically at urls.py on githhub, I can now see that the link you pointed me to is at a different url and has a different commit than the one I had looked at. Compare

https://github.com/jambonrose/DjangoUnleashed-1.8/blob/a1d420b17a/user/urls.py
https://github.com/jambonrose/DjangoUnleashed-1.8/blob/83167965e86b82a86a25504c82285dccd79b9e32/user/urls.py

So that must be the issue. Not sure what you can do about that except put a lot of notes in the repo. Cloning the whole thing is probably a good idea.

For your marketing fyi, I found out about you and the book after looking at your DjangoCon talk about the request response cycle. It so happens I have an immediate need to swap out the default user, so those chapters were right on time for me.

Thanks.

On Wednesday, June 29, 2016 at 5:13:42 PM UTC-7, Malik Rumi wrote:
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/5c7186c9-6caf-42c4-a062-f9d58798a3e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment