Discussion:
Class Based Views tutorials
(too old to reply)
Brad Rice
2015-01-06 13:49:44 UTC
Permalink
Does anyone have a recommendation for intermediate reading to understand
Class Based Views? It seems most of the Django books were written when
function based views were prevalent. I'm still having trouble understanding
what the differences are between CreateView and UpdateView and what Meta is
as well as slug_field and pk. Perhaps my issue is understanding Object
oriented python? I wish there were some tutorials or cookbooks that offer
better understanding.
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7fac53a2-7ff6-488f-903f-ed46edf15deb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sergiy Khohlov
2015-01-06 14:39:25 UTC
Permalink
Diff is simple : UpdateView is using for changing already created object.
CreateView is using for creating new object.
I have few simpleast class for your request. But I have not commented
yet.

Many thanks,

Serge


+380 636150445
skype: skhohlov
Post by Brad Rice
Does anyone have a recommendation for intermediate reading to understand
Class Based Views? It seems most of the Django books were written when
function based views were prevalent. I'm still having trouble understanding
what the differences are between CreateView and UpdateView and what Meta is
as well as slug_field and pk. Perhaps my issue is understanding Object
oriented python? I wish there were some tutorials or cookbooks that offer
better understanding.
--
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
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/7fac53a2-7ff6-488f-903f-ed46edf15deb%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/7fac53a2-7ff6-488f-903f-ed46edf15deb%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADTRxJM1Y9DGN-w1-rmZe0_mLd%3Du1OFaQF9iW1NvGMaZ%3DChCXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Brad Rice
2015-01-06 16:45:37 UTC
Permalink
When I was working with formsets, it seemed to me best to just use a single
UpdateView with post and get functions defined rather than having a
separate CreateView class. Seemed to handle both create and update ok.
Post by Sergiy Khohlov
Diff is simple : UpdateView is using for changing already created object.
CreateView is using for creating new object.
I have few simpleast class for your request. But I have not commented
yet.
Many thanks,
Serge
+380 636150445
skype: skhohlov
Post by Brad Rice
Does anyone have a recommendation for intermediate reading to understand
Class Based Views? It seems most of the Django books were written when
function based views were prevalent. I'm still having trouble understanding
what the differences are between CreateView and UpdateView and what Meta is
as well as slug_field and pk. Perhaps my issue is understanding Object
oriented python? I wish there were some tutorials or cookbooks that offer
better understanding.
--
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
<javascript:>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/7fac53a2-7ff6-488f-903f-ed46edf15deb%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/7fac53a2-7ff6-488f-903f-ed46edf15deb%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/703f0448-2152-418a-9466-4e87e1226b62%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sergiy Khohlov
2015-01-06 20:39:04 UTC
Permalink
Add function get() and post() to the view class. Code is near to same not
class view
Post by Brad Rice
When I was working with formsets, it seemed to me best to just use a
single UpdateView with post and get functions defined rather than having a
separate CreateView class. Seemed to handle both create and update ok.
Post by Brad Rice
Post by Sergiy Khohlov
Diff is simple : UpdateView is using for changing already created
object. CreateView is using for creating new object.
Post by Brad Rice
Post by Sergiy Khohlov
I have few simpleast class for your request. But I have not commented
yet.
Post by Brad Rice
Post by Sergiy Khohlov
Many thanks,
Serge
+380 636150445
skype: skhohlov
Post by Brad Rice
Does anyone have a recommendation for intermediate reading to
understand Class Based Views? It seems most of the Django books were
written when function based views were prevalent. I'm still having trouble
understanding what the differences are between CreateView and UpdateView
and what Meta is as well as slug_field and pk. Perhaps my issue is
understanding Object oriented python? I wish there were some tutorials or
cookbooks that offer better understanding.
Post by Brad Rice
Post by Sergiy Khohlov
Post by Brad Rice
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
Post by Brad Rice
Post by Sergiy Khohlov
Post by Brad Rice
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/7fac53a2-7ff6-488f-903f-ed46edf15deb%40googlegroups.com
.
Post by Brad Rice
Post by Sergiy Khohlov
Post by Brad Rice
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
Post by Brad Rice
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/703f0448-2152-418a-9466-4e87e1226b62%40googlegroups.com
.
Post by Brad Rice
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADTRxJOJa74iiNge3F0vBbOkthafSAmhD13QSwJoT%3DYSLkF7Gw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Jim Wombles
2015-01-06 17:09:13 UTC
Permalink
Two Scoops of Django is definitely the book you are looking for. I don't know if it's out for 1.7 yet, but I purchased the book for Django 1.6 and it covers l of the best practices that you won't read about just from the Django docs.
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0c859a0a-a997-4c3e-aed0-0b93588b6a9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lachlan Musicman
2015-01-06 21:01:34 UTC
Permalink
To answer the unanswered q's:

Meta is where you define things about the class, but are not in the
class. If you can imagine a space created that *all* classes would
need, mine as well as yours, this is in Meta. It's "Meta". IE. How
does this class sort? Should a couple of fields be "unique together",
do you want it's table to have a particular name in the database -
things that have sensible defaults, are common across all classes, but
can be changed.

"pk" is also known as "id" and stands for "primary key". This is a
fundamental of relational databases - every tuple has an identifying
element, usually table name and pk/id.

In days gone by we used to have things UUID (universally unique id) or
GUID (Globally Unique Identifier) - and they tended to look like this
a603732f-2314-4a34-b06e-3f016dd7a54c

Django largely hides the pk away, so that you don't need to worry
about it, although it can be useful in day to day use if you don't
have a particular identifying need - the biggest problem with a long
string of hex is that it's hard to look at it and say "oh, that's
John's tuple".

the slug_field is an URL shortener that makes identifying an object
via URL easier.

eg: John's tuple:

(without slug, with ugly uuid)
http://myapp.com/a603732f-2314-4a34-b06e-3f016dd7a54c

or

(with slug = name)
http://myapp.com/john-smith

Originating from newspaper urls, it's why you now get the easier to recall:

http://boingboing.net/2014/11/16/band-releases-unplayable-glass.html

It's not only got a slug, but also the date - so should there ever be
the need for another article about unplayable glass master discs, it
can still be unique (via Meta)

I hope that helps.
Post by Brad Rice
Does anyone have a recommendation for intermediate reading to understand
Class Based Views? It seems most of the Django books were written when
function based views were prevalent. I'm still having trouble understanding
what the differences are between CreateView and UpdateView and what Meta is
as well as slug_field and pk. Perhaps my issue is understanding Object
oriented python? I wish there were some tutorials or cookbooks that offer
better understanding.
--
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
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/7fac53a2-7ff6-488f-903f-ed46edf15deb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
------
"We are at once both obnoxious and indispensable." - John Ngumi on the Kikuyu
in It's Our Turn To Eat, by Michela Wrong.
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGBeqiNTDSq3qenDad1oh9PqO9BuL8wGSNomc%3DvM%2BusJPAvL4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...