Thursday, June 30, 2016

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

p.s. -

I did have a couple of other questions, if you don't mind:

1. You end 22.6 by saying

In an actual website, you likely won't interact with the auth in the way we have. You'll rely on third-party apps to provide object-level permissions or else on authentication with other services such as Twitter and Facebook.

I found that surprising, but then I'm somewhat isolated so don't claim to know what other folks are doing. Why is this the common practice? Just to save time because the tools are available?

2. In 22.5, you recommended a static url for profile pages.  Quite apart from how often people may update their pages, I didn't understand why you suggest that for an otherwise dynamic website. I guess I just assumed static urls and static (or 'flat'. as Django likes to call them) pages go together, like About Us, and that such pages would be the exception. Was this just to make the profiles easy to find and/or bookmark for end users?

Thanks again.




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/b9f5f11e-c6b5-4c2d-b0fe-097005294486%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment