Questions about templates from a novice - Question #1

29 views
Skip to first unread message

jim_anderson

unread,
Dec 1, 2016, 1:39:19 PM12/1/16
to Django users
Hi,

A few intro words first. I am an experienced programmer and worked on a few python projects for maybe 3 years around 2000. Most of my other programming has been in c, c++, and java - maybe too many years. My current project is a web based project using Python 3.5.2 and Django 1.9.7. I have gotten to the point where I'm feeling pretty comfortable with python again, but I'm still getting a handle on django, so I'll classify myself as being intermediate in my python knowledge and mid-novice with django. I am writing a bit of code for the project and in parallel, I am experimenting with a django project that I call 'testDjangoProject' (I'm not too original). My current objective in the test project is to get a working template environment and a working knowledge so that I can write and templates, template tags and template filters.

I have a few questions, but I'm going enter each question as a separate thread in this group.

So, question number 1:

I have created a view class that is derived from generic.ListView, which inherits from a few other classes both directly and indirectly. My class, called TagView, overrides 2 methods get_query_set() and get(). I basically did this to mimic what I saw in some tutorials. When I run my test case, the get() method is called. There are a number of other derived methods that could also have been overriden. What are the deciding factors that django uses to determine which view class method to call?

BTW, my 'tag' model has 2 entries in a sqlite3 db.

Jim Anderson

Dan Tagg

unread,
Dec 1, 2016, 2:59:58 PM12/1/16
to django...@googlegroups.com
Hi Jim,

I would really recommend looking at https://ccbv.co.uk/projects/Django/1.9/

There are diagrams to show the hierarchy of inheritance and mixins, plus all the properties and methods are there to see and explore. 

The place to start is the dispatch method, as_view is called first but you can backtrack to that later. Have a look, you'll see dispatch gets the request's method tries to call a method with that name if it is a valid HTTP method and returns a HTTP 405 if either the method is not defined.

Dan 

--
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...@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/ce1e5ebf-725f-4c44-8a91-2e742061c764%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jim_anderson

unread,
Dec 2, 2016, 10:36:12 AM12/2/16
to Django users

Hi Dan,

Thank you, much, for the pointer. I was totally unaware of the ccbv website. I looked over the 1.9 area this morning and after about 30 minutes I think I have a good feel for how the methods are being called. I believe I can use the classes and methods without going 'under the hood'.

Jim
Reply all
Reply to author
Forward
0 new messages