<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>GoDjango Screencasts and Tutorials</title><link>https://godjango.com</link><description>Tutorials covering some topic about Django.</description><atom:link href="http://godjango.com/rss/main/" rel="self"></atom:link><language>en-us</language><lastBuildDate>Mon, 10 Jul 2017 15:00:00 +0000</lastBuildDate><item><title>Django 1.11+ django.contrib.auth Class Based Views - Part 2 - Password Change and Reset</title><link>http://godjango.com/144-django-111-djangocontribauth-class-based-views-part-1-password-change-and-reset/</link><description>Since we can log in and logout what about managing our password? Learn the power of using the builtin Generic Class Based Views now in django.contrib.auth. They are simple to use once you know about them.&lt;br /&gt;&lt;a href='https://godjango.com/144-django-111-djangocontribauth-class-based-views-part-1-password-change-and-reset/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 10 Jul 2017 15:00:00 +0000</pubDate><guid>http://godjango.com/144-django-111-djangocontribauth-class-based-views-part-1-password-change-and-reset/</guid></item><item><title>Django 1.11+ django.contrib.auth Class Based Views - Part 1 - Login &amp; Logout</title><link>http://godjango.com/143-django-111-djangocontribauth-class-based-views-part-1/</link><description>This is the first in a long series on creating a CryptoCurrency management site, but first we need to lock things down so people can't see all of our stuff. So we will start by setting up our app and logging in and out. We will do this with the new Class Based Views in django.contrib.auth system.&lt;br /&gt;&lt;a href='https://godjango.com/143-django-111-djangocontribauth-class-based-views-part-1/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 03 Jul 2017 21:00:00 +0000</pubDate><guid>http://godjango.com/143-django-111-djangocontribauth-class-based-views-part-1/</guid></item><item><title>Django 1.11 Release Notes a Reading</title><link>http://godjango.com/blog/django-111-release-notes-a-reading/</link><description>&lt;p&gt;Django 1.11 is released for the world to use. It comes with a lot of changes, which can take some time to read.&lt;/p&gt;
&lt;p&gt;In my last video I mentioned I would read these release notes if there was interest so here you go. I have read all of the release notes so you can just put on some headphones and hit play.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=O-aTMavulZU"&gt;Django 1.11 Release Notes a Reading&lt;/a&gt;&lt;/p&gt;
&lt;iframe width="1280" height="720" src="https://www.youtube.com/embed/O-aTMavulZU" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description><pubDate>Wed, 05 Apr 2017 15:00:00 +0000</pubDate><guid>http://godjango.com/blog/django-111-release-notes-a-reading/</guid></item><item><title>Django 1.11 Highlights</title><link>http://godjango.com/blog/django-111-highlights/</link><description>&lt;p&gt;You can't always, easily, keep up with the latest and greatest of what is coming out in django, so since we have a new release candidate for django 1.11 here are a few of the highlights.&lt;/p&gt;
&lt;p&gt;I would say there are some interesting things that are on the horizon for django, especially since this is the last 1.x release before we are on to 2.0.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=dVEz3RXPt1c"&gt;Django 1.11 Highlights&lt;/a&gt;&lt;/p&gt;
&lt;iframe width="1280" height="720" src="https://www.youtube.com/embed/dVEz3RXPt1c" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description><pubDate>Wed, 29 Mar 2017 15:00:00 +0000</pubDate><guid>http://godjango.com/blog/django-111-highlights/</guid></item><item><title>How Do I Start Learning Django</title><link>http://godjango.com/blog/how-do-i-start-learning-django/</link><description>&lt;p&gt;If you have done django for any amount of time you have probably gotten this question, and it can sometimes be hard to answer beyond start at the main django site.&lt;/p&gt;
&lt;p&gt;In this video I attempt to help by giving people a starting point, and some guidance on resources to and how to use.&lt;/p&gt;
&lt;p&gt;Give it a watch and offer any suggestions, and tweaks you think should be made.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=rso2q2RaTZA"&gt;How Do I Start Learning Django?&lt;/a&gt;&lt;/p&gt;
&lt;iframe width="1280" height="720" src="https://www.youtube.com/embed/rso2q2RaTZA" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description><pubDate>Tue, 14 Mar 2017 15:00:00 +0000</pubDate><guid>http://godjango.com/blog/how-do-i-start-learning-django/</guid></item><item><title>You Should do Weird Stuff in Django</title><link>http://godjango.com/blog/you-sould-do-weird-stuff-in-django/</link><description>&lt;p&gt;Out of the ordinary things are the times that we grow the most as developers. However, a lot of times we don't do enough weird things when we write our software.&lt;/p&gt;
&lt;p&gt;I would encourage you to try that odd idea that you have been messing with in your head that you aren't sure you can do. Ironically you will grow more as a developer from that than your day to day getting stuff done development&lt;/p&gt;
&lt;p&gt;I am not sure why I ever really thought about this, but give a watch to what keyed me in on this thought.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://youtu.be/GmyrnWgNdDk"&gt;You Should Do Weird Stuff in Django&lt;/a&gt;&lt;/p&gt;
&lt;iframe width="1280" height="720" src="https://www.youtube.com/embed/GmyrnWgNdDk" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description><pubDate>Mon, 27 Feb 2017 16:00:00 +0000</pubDate><guid>http://godjango.com/blog/you-sould-do-weird-stuff-in-django/</guid></item><item><title>Why You Should Pin Your Dependencies by My Mistakes</title><link>http://godjango.com/blog/why-you-should-pin-your-dependencies-by-my-mistake/</link><description>&lt;p&gt;Have you ever been bitten by not pinning your dependencies in your django project? If not be glad, and come learn from my problems.&lt;/p&gt;
&lt;p&gt;Pinning your dependencies is important to solve future unknown issues, better the devil you know and all that.&lt;/p&gt;
&lt;p&gt;In this weeks video I talk about 3 times I had issues. They are either not pinning my dependencies, a weird edge case with pinning and python, and not really understanding what I was doing with pinned dependencies.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=JYuFn1BOZDA"&gt;Why You Should Pin Your Dependencies&lt;/a&gt;&lt;/p&gt;
&lt;iframe width="1280" height="720" src="https://www.youtube.com/embed/JYuFn1BOZDA" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description><pubDate>Mon, 20 Feb 2017 16:00:00 +0000</pubDate><guid>http://godjango.com/blog/why-you-should-pin-your-dependencies-by-my-mistake/</guid></item><item><title>Different types of testing in Django</title><link>http://godjango.com/blog/different-ypes-of-testing-in-django/</link><description>&lt;p&gt;Testing is always one of those topics that can be interesting to talk about. There are a lot of different opinions on testing so it can be fun.&lt;/p&gt;
&lt;p&gt;Django comes with some great tools for testing, so this week we will talk a little bit about the different types of tests. Then expand on that with how that relates to Django.&lt;/p&gt;
&lt;p&gt;I also present to you a new type of test at the end of the video that I have been using, special thanks to a co-worker for coming up with the idea. It is really specific to django, and I haven't heard of others doing it.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://youtu.be/Afekl8kCFLo"&gt;Different Types of Tests with Django&lt;/a&gt;&lt;/p&gt;
&lt;iframe width="1280" height="720" src="https://www.youtube.com/embed/Afekl8kCFLo" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description><pubDate>Tue, 14 Feb 2017 16:00:00 +0000</pubDate><guid>http://godjango.com/blog/different-ypes-of-testing-in-django/</guid></item><item><title>5 Reasons to Use Class Based Views</title><link>http://godjango.com/blog/5-reasons-to-use-class-based-views/</link><description>&lt;p&gt;Anytime anyone brings up &lt;strong&gt;Class Based Views&lt;/strong&gt;, generic and otherwise, it is similar to the &lt;strong&gt;Vim vs Emacs&lt;/strong&gt; debate. So lets pile on a bit more.&lt;/p&gt;
&lt;p&gt;But not really. In actuality, I feel like there are good, solid, and &lt;strong&gt;legitimate reasons&lt;/strong&gt; to use Class Based Views which get &lt;strong&gt;passed over in the middle of arguments&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;In this weeks topic I talk about 5 of those reasons I think people should use Class Based Views. In reality there are more, but I wanted to keep the video short'ish.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://youtu.be/ZQX06V8wHdU"&gt;5 Reasons to Use Class Based Views&lt;/a&gt;&lt;/p&gt;
&lt;iframe width="1280" height="720" src="https://www.youtube.com/embed/ZQX06V8wHdU" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description><pubDate>Mon, 06 Feb 2017 16:00:00 +0000</pubDate><guid>http://godjango.com/blog/5-reasons-to-use-class-based-views/</guid></item><item><title>How to Vett Django Apps</title><link>http://godjango.com/blog/how-to-vett-django-apps/</link><description>&lt;p&gt;There are a lot of 3rd party django apps that people put out which makes our lives easier, but are they good?&lt;/p&gt;
&lt;p&gt;There are a lot of ways to evaluate them, mostly it seems a lot of people use intuition.&lt;/p&gt;
&lt;p&gt;In this weeks video I go over several ways of how I go about vetting projects before use in my projects.&lt;/p&gt;
&lt;p&gt;How to Vett Django Apps&lt;/p&gt;
&lt;iframe width="1280" height="720" src="https://www.youtube.com/embed/c1nQRImGNS4" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description><pubDate>Mon, 30 Jan 2017 16:00:00 +0000</pubDate><guid>http://godjango.com/blog/how-to-vett-django-apps/</guid></item><item><title>How I Deploy Django Day-to-Day</title><link>http://godjango.com/blog/how-i-deploy-django-day-to-day/</link><description>&lt;p&gt;There are &lt;strong&gt;a lot of ways to deploy Django&lt;/strong&gt; so I think it is one of those topics people are really curious about how other people do it. Generally, in all deploys you need to &lt;strong&gt;get the latest code, run migrations, collect your static files&lt;/strong&gt; and &lt;strong&gt;restart web server processes&lt;/strong&gt;. How yo do those steps, that is the interesting part.&lt;/p&gt;
&lt;p&gt;In todays video I go over &lt;a href="https://www.youtube.com/watch?v=43lIXCPMw_8"&gt;How I deploy Django day to day&lt;/a&gt;, followed by some other ways I have done it. This is definitely a topic you can make as easy or complicated as you want.&lt;/p&gt;
&lt;p&gt;Here is the link again: &lt;a href="https://www.youtube.com/watch?v=43lIXCPMw_8"&gt;https://www.youtube.com/watch?v=43lIXCPMw_8?vq=hd720&lt;/a&gt;&lt;/p&gt;
&lt;iframe width="1280" height="720" src="https://www.youtube.com/embed/43lIXCPMw_8" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description><pubDate>Wed, 18 Jan 2017 16:00:00 +0000</pubDate><guid>http://godjango.com/blog/how-i-deploy-django-day-to-day/</guid></item><item><title>5 Reasons I don't think you should use the django admin</title><link>http://godjango.com/blog/5-reasons-i-dont-think-you-shold-use-the-django-ad/</link><description>&lt;p&gt;Have you ever needed to quickly modify data or look it up. But while the task is simple the entire process of changing one value frustrates you?&lt;/p&gt;
&lt;p&gt;Well, this is very common to me, bad UX is annoying. I quite often have to either lookup, or edit, two disparate, yet related pieces of data, and sometimes it is an exercise in frustration.&lt;/p&gt;
&lt;p&gt;An all to common occurrence is I just needed to check the edit history of a "Company" our database. This is a simple process, go to the admin find the Company model, do a search and you have your answer.&lt;/p&gt;
&lt;p&gt;Except, it isn't that easy in reality. Lets run through what really happened.&lt;/p&gt;
&lt;p&gt;I went to "&lt;a href="http://superawesomesite.com/admin/"&gt;http://superawesomesite.com/admin/&lt;/a&gt;" and logged in.&lt;/p&gt;
&lt;p&gt;I then looked at how my model options extended well below the fold of my browser so I had to scroll. No problem I'll just hit "ctrl+f" and search for it. WTF!!! where is my company model?&lt;/p&gt;
&lt;p&gt;I then proceed to scroll down and finally find it only to remember it was pluralized. If I had searched for "Companies" I would have been good to go, grrrrr.&lt;/p&gt;
&lt;p&gt;I click into and see the list of companies available to me. I see that there is a search feature at the top so I do a search for the relevant information. Unfortunately, I don't know the company name that is what I am trying to find out.&lt;/p&gt;
&lt;p&gt;Except, we aren't filtering our search in the admin based on that field. So no results show up.&lt;/p&gt;
&lt;p&gt;No problem I can do a list filter on the side. So I set the correct filters and still no luck because someone didn't set all the metadata that was supposed to be set for the company. Again grrrrr.&lt;/p&gt;
&lt;p&gt;Finally, I abandoned the admin and opened up the django/python shell and did a query with the model, and in about 30 seconds had the record I needed. Took the id and plugged that into the django admin and I was good to go.&lt;/p&gt;
&lt;p&gt;This was an exercise in frustration because the 30 seconds that was taken during development to decide which fields should be filtered didn't let that person imagine the field I needed. Also the fact that whomever added the company didn't add all the correct information, made it almost impossible to find the data. In the end I had to go outside this system that is hailed as one of the greatest tools for django to get the information I needed.&lt;/p&gt;
&lt;p&gt;I propose we as a community reduce our reliance on the django admin, especially in production.&lt;/p&gt;
&lt;p&gt;I also created a Video on the &lt;a href="https://www.youtube.com/watch?v=WQ5EFFbUSV4"&gt;5 reasons we shouldn't use the django admin&lt;/a&gt;.&lt;/p&gt;
&lt;iframe width="1280" height="720" src="https://www.youtube.com/embed/WQ5EFFbUSV4?vq=hd720" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description><pubDate>Mon, 09 Jan 2017 16:00:00 +0000</pubDate><guid>http://godjango.com/blog/5-reasons-i-dont-think-you-shold-use-the-django-ad/</guid></item><item><title>Basics of Webpack</title><link>http://godjango.com/130-basics-of-webpack/</link><description>Webpack can be complicated, but it doesn't have to be. Learn some of the basics of webpack, and how you can get started with it while actually understanding it. In this video we start our journey to working with react and django, but first we need to build our javascript and that is where webpack comes in.&lt;br /&gt;&lt;a href='https://godjango.com/130-basics-of-webpack/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 21 Oct 2016 15:00:00 +0000</pubDate><guid>http://godjango.com/130-basics-of-webpack/</guid></item><item><title>Store Measurements Sanely with django-measurement</title><link>http://godjango.com/129-store-measurements-sanely-with-django-measurement/</link><description>Storing measurement data for multiple types of units is quite a frustrating task. Fortunately with django-measurement providing a good wrapper for python-measurement it makes this almost a non-issue. In this video get a quick overview of how to use django-measurement to store that pesky data.&lt;br /&gt;&lt;a href='https://godjango.com/129-store-measurements-sanely-with-django-measurement/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 30 Sep 2016 15:00:00 +0000</pubDate><guid>http://godjango.com/129-store-measurements-sanely-with-django-measurement/</guid></item><item><title>Setting up a Honey Pot with django-admin-honeypot</title><link>http://godjango.com/126-setting-up-a-honey-pot-with-django-admin-honeypot/</link><description>Security is something we often ignore until it is too late. However, there are some things you can do right now that are easy to increase your security. Using django-admin-honeypot is one of those things you can do. It is super easy and provides you with the means of tracking who is trying to access your site.&lt;br /&gt;&lt;a href='https://godjango.com/126-setting-up-a-honey-pot-with-django-admin-honeypot/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 05 Aug 2016 15:00:00 +0000</pubDate><guid>http://godjango.com/126-setting-up-a-honey-pot-with-django-admin-honeypot/</guid></item><item><title>Django with Bash for Windows</title><link>http://godjango.com/123-django-with-bash-for-windows/</link><description>Doing django development using "Bash for Windows" seems to work pretty well. See what it takes to set it up and get started.&lt;br /&gt;&lt;a href='https://godjango.com/123-django-with-bash-for-windows/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Thu, 23 Jun 2016 15:00:00 +0000</pubDate><guid>http://godjango.com/123-django-with-bash-for-windows/</guid></item><item><title>Custom python-social-auth Pipeline</title><link>http://godjango.com/122-custom-python-social-auth-pipeline/</link><description>Sometimes when you authenticate with a social service you need to do custom "stuff" in your code base beyond creating a user object. Learn how to get started simply adding a custom function do the python-social-auth pipeline.&lt;br /&gt;&lt;a href='https://godjango.com/122-custom-python-social-auth-pipeline/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 10 Jun 2016 15:00:00 +0000</pubDate><guid>http://godjango.com/122-custom-python-social-auth-pipeline/</guid></item><item><title>Create Cache Bustable Static Files</title><link>http://godjango.com/119-create-cache-bustable-static-files/</link><description>Dealing with static files like css and javascript and the cache can be annoying, and hard. Fortunately Django provides a way to solve this fairly easily. Learn how to add a hash in your static file names so caching can be easier.&lt;br /&gt;&lt;a href='https://godjango.com/119-create-cache-bustable-static-files/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 25 Mar 2016 15:00:00 +0000</pubDate><guid>http://godjango.com/119-create-cache-bustable-static-files/</guid></item><item><title>CSV Files - Read and Create</title><link>http://godjango.com/116-csv-files-read-and-create/</link><description>CSV files seem to be what some companies live by. Because of that we need to know how to work with them. In this video learn the basics of using csv reader, writer, DictReader, and DictWriter&lt;br /&gt;&lt;a href='https://godjango.com/116-csv-files-read-and-create/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Thu, 11 Feb 2016 16:00:00 +0000</pubDate><guid>http://godjango.com/116-csv-files-read-and-create/</guid></item><item><title>Django Model Inheritance - Multi-Table Inheritance</title><link>http://godjango.com/blog/django-abstract-base-class-multi-table-inheritance/</link><description>&lt;p&gt;In the last post we talked about Model Inheritance with regards to Abstract Model Classes, it was a great introduction into using OOP with your models to keep your code slim and tidy. You can read it at: &lt;a href="https://godjango.com/blog/django-abstract-base-class-model-inheritance/"&gt;Django Abstract Base Class - Model Inheritance&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In this post we are going to discuss Multi-Table Inheritance. We will create a base model, that is not an abstract model, and inherit from the model. Then we are going to show you how to get and reference data from that models inheritance.&lt;/p&gt;
&lt;h2&gt;Multi Table Inheritance&lt;/h2&gt;
&lt;p&gt;When we talk about multi-table inheritance we are referring to having a top level table with all the fields that are core to that context. Then we are going to have other tables with the more specific fields. You select from the table you want, and then do a join on a relationship to get the parent table data. Since Django does this through models and code, we will talk about it in those terms.&lt;/p&gt;
&lt;p&gt;In our example we are going to have a Ticket Model.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Ticket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;blank&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blank&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;blank&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This model is a good piece of code because no matter what type of ticket we ever have we are going to have a title, description, and name. This is normal for any OOP we would do as a base class. Since we have this base model we can subclass it to have more specific models with data associated with them.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;InternalTicket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Ticket&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ForeignKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;auth.User&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomerTicket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Ticket&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blank&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now we have 3 models available to us: &lt;code&gt;Ticket&lt;/code&gt;, &lt;code&gt;InternalTicket&lt;/code&gt;, and &lt;code&gt;CustomerTicket&lt;/code&gt;. Each one has a &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt; and &lt;code&gt;name&lt;/code&gt; as fields. However, &lt;code&gt;CustomerTicket&lt;/code&gt; does not have a &lt;code&gt;user&lt;/code&gt; field and &lt;code&gt;InternalTicket&lt;/code&gt; does not have &lt;code&gt;product&lt;/code&gt; field. Also both &lt;code&gt;InternalTicket&lt;/code&gt; and &lt;code&gt;CustomerTicket&lt;/code&gt; are stored in separate database table from &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt; and &lt;code&gt;name&lt;/code&gt;. So if you looked up the tables in the database you would see a FK reference to the ticket table, &lt;code&gt;id&lt;/code&gt; field and the field you declared. Everything else lives in the ticket table.&lt;/p&gt;
&lt;h2&gt;Getting and Creating Data&lt;/h2&gt;
&lt;p&gt;With all that said lets look at creating some data and getting it back out. Because that is really when it makes sense on how it works.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;In [1]: CustomerTicket.objects.create(product='Videos', title='Odd Playback', description='doesnt play back fast enough', name='Jane Smith')
Out[1]: &amp;lt;CustomerTicket: CustomerTicket object&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We have created a &lt;code&gt;CustomerTicket&lt;/code&gt; object with all of our fields set, and it succeeds. (Further proof it works)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;In [2]: Ticket.objects.all()
Out[2]: [&amp;lt;Ticket: Ticket object&amp;gt;]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we are getting all tickets from the ticket model, which is including our CustomerTicket we create above.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;In [3]: ticket = Ticket.objects.get()

In [4]: ticket.customerticket
Out[4]: &amp;lt;CustomerTicket: CustomerTicket object&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If we reference the &lt;code&gt;customerticket&lt;/code&gt; property, which is the related name, it will return back the model so we can get the data from the model. We can look at that in action.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;In [5]: ticket.customerticket.product
Out[5]: 'Videos'

In [6]: ticket.description
Out[6]: 'doesnt play back fast enough'&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, you can see the description is still on the ticket level and not the cutomerticket model.&lt;/p&gt;
&lt;h2&gt;How does it work&lt;/h2&gt;
&lt;p&gt;From the django docs:&lt;/p&gt;
&lt;blockquote&gt;
multi-table inheritance uses an implicit OneToOneField to link the child and the parent
&lt;/blockquote&gt;&lt;p&gt;This means there is a one-to-one relationship between the ticket record and the corresponding subclassed models. Django just handles the translation of it from multiple tables to a single model so you don't really notice it.&lt;/p&gt;
&lt;h2&gt;CustomerTicket object&lt;/h2&gt;
&lt;p&gt;As our final look we can look at how the &lt;code&gt;CustomerTicket&lt;/code&gt; object we created earlier references the ticket object.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;n [1]: customer = CustomerTicket.objects.get()

In [2]: customer.description
Out[2]: 'doesnt play back fast enough'&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see django just handles the fact that description is on the model, even though the description data is in the ticket table.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;In [3]: customer.ticket_ptr
Out[3]: &amp;lt;Ticket: Ticket object&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;.ticket_ptr&lt;/code&gt; property is the reference to the ticket object so if you need to actually use that model you can.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;In [4]: customer.ticket_ptr_id
Out[4]: 1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;ticket_ptr_id&lt;/code&gt; holds the id of the Ticket object in the database giving you another avenue for getting information out of the appropriate place.&lt;/p&gt;
&lt;h2&gt;Conslusion&lt;/h2&gt;
&lt;p&gt;You don't often need to use Multi-table inheritance, but when you do need to use it, it is nice that django makes it super simple to use. I have only seen a few instances where it makes sense, tickets being one, and social media posts as another. It provides great value in giving you core data, then when needed get the rest of the data. It does this while allowing you to use the models as separate models as if the inheritance didn't exist. Finally, another way to think of it is as data being used with polymorphism.&lt;/p&gt;
</description><pubDate>Thu, 21 Jan 2016 16:00:00 +0000</pubDate><guid>http://godjango.com/blog/django-abstract-base-class-multi-table-inheritance/</guid></item><item><title>Django and Angular - Setting up Base Angular App</title><link>http://godjango.com/112-django-and-angular-setting-up-base-angular-app/</link><description>Learn what it takes to get the basics of an angular app going with Django. See how simple it is to get started.&lt;br /&gt;&lt;a href='https://godjango.com/112-django-and-angular-setting-up-base-angular-app/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Thu, 07 Jan 2016 16:00:00 +0000</pubDate><guid>http://godjango.com/112-django-and-angular-setting-up-base-angular-app/</guid></item><item><title>reverse, lazy and resolve - Django url-resolvers</title><link>http://godjango.com/108-reverse-lazy-and-resolve-django-url-resolvers/</link><description>Working with urls is a core part of web development. The url-resolver utilities django provides makes working with them just that much easier. Look at using `reverse`, `reverse_lazy`, and `resolve` utility functions to write better idiomatic django.&lt;br /&gt;&lt;a href='https://godjango.com/108-reverse-lazy-and-resolve-django-url-resolvers/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 07 Dec 2015 16:00:00 +0000</pubDate><guid>http://godjango.com/108-reverse-lazy-and-resolve-django-url-resolvers/</guid></item><item><title>Django Abstract Base Class - Model Inheritance</title><link>http://godjango.com/blog/django-abstract-base-class-model-inheritance/</link><description>&lt;p&gt;Model inheritance is a very useful and powerful feature of django, but used incorrectly it can cause a lot of confusion. Lets go ahead and take a look at some of those.&lt;/p&gt;
&lt;p&gt;Have you ever been looking through other peoples code and seen a model &lt;code&gt;class Meta&lt;/code&gt; with &lt;code&gt;abstract = True&lt;/code&gt;? That is the first type of inheritance we are going to look at, abstract base models. There is also multi-table inheritance, proxy models, and multiple inheritance available.&lt;/p&gt;
&lt;h2&gt;Abstract Base Classes&lt;/h2&gt;
&lt;p&gt;In this post we are going to focus on Abstract base classes. This is the easiest type of model inheritance to really understand because it works very much like normal inheritance. In OOP when you inherit from another object you get all of its members plus your own. You can modify those members or leave them the same. Abstract base classes are the same.&lt;/p&gt;
&lt;p&gt;Here are two example classes&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EmailField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;purchase_history&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ForeignKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;cart.Invoice&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Staff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EmailField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;bio&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As you can see these two models are legitimate models with fields, but they do have common elements. In a lot of cases it is fine to leave them this way. However, if we use these same fields yet again it would be a good idea to use an abstract base class.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ConactInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EmailField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Meta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;abstract&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Customer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ContactInfo&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;purchase_history&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ForeignKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;cart.Invoice&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Staff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ContactInfo&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;bio&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;models&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CharField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_length&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We now have a &lt;code&gt;ConactInfo&lt;/code&gt; abstract base class because we added &lt;code&gt;abstract = True&lt;/code&gt; to its &lt;code&gt;Meta&lt;/code&gt;. This will tell django and the migration system this isn't a model we can use to store data with.&lt;/p&gt;
&lt;p&gt;However, we can inherit from it so that each model that we subclass with it has the fields, methods, and properties of the abstract model. At this point if you did ./manage.py makemigrations it would create a migration file creating only Customer and Staff tables in the database.&lt;/p&gt;
&lt;h2&gt;Will it Work with Existing Models?&lt;/h2&gt;
&lt;p&gt;Lets say you have several existing models in your code base you want to abstract into base classes. Will it "just work"? Yes it will. Once I found out about abstract classes I went and made several then ran a &lt;code&gt;makemigrations&lt;/code&gt; and nothing happened because to django nothing changed you just refactored you code.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Hopefully this gives you a place to start with doing model inheritance. It is very useful, but much like OOP don't go crazy with it and have a lot of abstract classes. You can be so abstract you have no idea what is going on.&lt;/p&gt;
&lt;p&gt;My rule of thumb, whether good or bad, is if I have more than 3 fields repeated in only 2 models I just leave them alone. If I need to add them to a third model I will evaluate if it makes sense to use an abstract model. If I can name the abstract model and it makes sense like &lt;code&gt;ContactInfo&lt;/code&gt; then there is enough context to create the new model, so I will. Otherwise I will put it off until the code is screaming for an abstract base class.&lt;/p&gt;
&lt;p&gt;Stay tuned for the next post on Multi-table inheritance. &lt;/p&gt;
&lt;p&gt;What has your experience been?&lt;/p&gt;
</description><pubDate>Thu, 03 Dec 2015 16:00:00 +0000</pubDate><guid>http://godjango.com/blog/django-abstract-base-class-model-inheritance/</guid></item><item><title>Installing Wagtail</title><link>http://godjango.com/107-installing-wagtail/</link><description>Wagtail has become a very popular CMS in the last year. Start with this video to see how to get it up and running for your project, and get content on the homepage.&lt;br /&gt;&lt;a href='https://godjango.com/107-installing-wagtail/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 20 Nov 2015 16:00:00 +0000</pubDate><guid>http://godjango.com/107-installing-wagtail/</guid></item><item><title>Understanding *args and **kwargs</title><link>http://godjango.com/105-understanding-args-and-kwargs/</link><description>args and kwargs are hard. They are confusing, and tricky when you are learning python. Even experienced developers can be tripped up by them. Learn how to expand and collapse lists and dictionaries for args and kwargs.&lt;br /&gt;&lt;a href='https://godjango.com/105-understanding-args-and-kwargs/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 30 Oct 2015 15:00:00 +0000</pubDate><guid>http://godjango.com/105-understanding-args-and-kwargs/</guid></item><item><title>Filter Your List of Objects in the Admin</title><link>http://godjango.com/102-filter-your-list-of-objects-in-the-admin/</link><description>Getting the data you need in the admin quickly is important. Learn how to filter not only based on fields, but add your own custom filter as well.&lt;br /&gt;&lt;a href='https://godjango.com/102-filter-your-list-of-objects-in-the-admin/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 25 Sep 2015 15:00:00 +0000</pubDate><guid>http://godjango.com/102-filter-your-list-of-objects-in-the-admin/</guid></item><item><title>Getting Started with Django Admin</title><link>http://godjango.com/99-getting-started-with-django-admin/</link><description>The admin is a very useful tool for developers to use when working with django. It is super easy to setup, and get your models registered with it so you can start CRUDing data.&lt;br /&gt;&lt;a href='https://godjango.com/99-getting-started-with-django-admin/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Thu, 20 Aug 2015 15:00:00 +0000</pubDate><guid>http://godjango.com/99-getting-started-with-django-admin/</guid></item><item><title>Working with Environment Variables in Python</title><link>http://godjango.com/blog/working-with-environment-variables-in-python/</link><description>&lt;p&gt;If you look at modern code deployment practices, like in the 12 factor app, environment variables are very important for keeping secret information secret, or server specific information set for that server. All while not having long crazy settings in a settings file for every single server and computer. It helps keep things slimmer in your code along with the following quoted from the 12factorapp site:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;    * Resource handles to the database, Memcached, and other backing services
    * Credentials to external services such as Amazon S3 or Twitter
    * Per-deploy values such as the canonical hostname for the deploy
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;What Are Environment Variables?&lt;/h2&gt;
&lt;p&gt;Environment variables are a key value pairs that can affect how a program runs. They need to be set at some point before a process is run so the process can read them in and act accordingly. A lot of times in production environments your database name and password are set as environment variables so that information does not end up in a code repository somewhere.&lt;/p&gt;
&lt;p&gt;By relying on an environment variable your code doesn't care what a setting is because you can set that at some other point. Actually working with environment variables is really simple. All you need to start is import os and you are off to the races.&lt;/p&gt;
&lt;h2&gt;Get Environment Variable with Python:&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;DATABASE_NAME&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;environ&lt;/code&gt; part of this call is like a dictionary of all the environment variables. So we just get the one we are after and go about our business. You might even see something like below for your database settings, in your django settings file. You are either getting the environment variable, or you are getting back an empty string.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;DATABASES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s"&gt;&amp;#39;default&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s"&gt;&amp;#39;ENGINE&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;django.db.backends.postgresql_psycopg2&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s"&gt;&amp;#39;NAME&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;DATABASE_NAME&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="s"&gt;&amp;#39;USER&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;DATABASE_USER&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="s"&gt;&amp;#39;PASSWORD&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;DATABASE_PASSWORD&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="s"&gt;&amp;#39;HOST&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;DATABASE_HOST&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="s"&gt;&amp;#39;PORT&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;DATABASE_PORT&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Running &lt;code&gt;django-admin.py/manage.py&lt;/code&gt; with environment variables&lt;/h2&gt;
&lt;p&gt;A common use of environment variables in django is the &lt;code&gt;DJANGO_SETTINGS_MODULE&lt;/code&gt;. It tells &lt;code&gt;django-admin.py&lt;/code&gt; what settings file to load for a project.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nv"&gt;DJANGO_SETTINGS_MODULES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;project.settings&amp;#39;&lt;/span&gt; django-admin.py
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code&gt;manage.py&lt;/code&gt; is basically a shortcut to this command. We are setting the location of our &lt;code&gt;settings.py&lt;/code&gt; file and running &lt;code&gt;django-admin.py&lt;/code&gt; command. There has been a lot debate about &lt;code&gt;manage.py&lt;/code&gt; since the above is all it really does. You can read and learn more on a ticket about it: &lt;a href="https://code.djangoproject.com/ticket/19737"&gt;Deprecate and then remove "shell" management command&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Set environment variable in bashrc&lt;/h2&gt;
&lt;p&gt;Finally, depending on your environment you might want to setup environment variables in your &lt;code&gt;bashrc&lt;/code&gt; or &lt;code&gt;bash_profile&lt;/code&gt; so every time you start a command line environment they are set. To do this add something like the following to your &lt;code&gt;bashrc&lt;/code&gt; or &lt;code&gt;bash_profile&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PROGRAMMING_FOLDER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/home/user/programming/&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The export command is built into shell and sets &lt;code&gt;PROGRAMMING_FOLDER&lt;/code&gt; to &lt;code&gt;/home/user/programming&lt;/code&gt; for the current environment. You can verify this running &lt;code&gt;env&lt;/code&gt; in your shell, or even &lt;code&gt;env | grep PROGRAMMING&lt;/code&gt; to get just that environment variable.&lt;/p&gt;
&lt;h2&gt;Common Places to Set Environment Variables in Production&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://supervisord.org/subprocess.html#subprocess-environment"&gt;supervisord&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://coderwall.com/p/93jakg/multiple-env-vars-with-uwsgi"&gt;uwsgi&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;First link is how to set environment variables with supervisord which is a recommended way to run your server side code, generally running gunicorn or uWSGI. uWSGI is linked to because a lot of people run it outside of supervisord. However, it is recommended if you use gunicorn to use supervisord so set environment variables inside that config.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Environment variables are extremely useful, but can be a huge pain to work with. I really suggest playing with them in different environments to get used to working with them. When I first started setting them in production environments it was tough to first learn how to set them, and run my code. However, once I got environment variables working locally in my dev environment, and in production it became super convenient. I am super glad I took the extra effort to learn a process to work with them, and I think you will too.&lt;/p&gt;
</description><pubDate>Thu, 06 Aug 2015 15:00:00 +0000</pubDate><guid>http://godjango.com/blog/working-with-environment-variables-in-python/</guid></item><item><title>Django and Python 3 How to Setup pyenv for Multiple Pythons</title><link>http://godjango.com/96-django-and-python-3-how-to-setup-pyenv-for-multiple-pythons/</link><description>We need to be doing Django development in Python 3. Unfortunately, we have a lot of projects still in Python 2.7 so switching between the 2 versions can be frustrating. Fortunately pyenv takes the guess work out of switching, and makes it super simple.&lt;br /&gt;&lt;a href='https://godjango.com/96-django-and-python-3-how-to-setup-pyenv-for-multiple-pythons/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Thu, 23 Jul 2015 15:00:00 +0000</pubDate><guid>http://godjango.com/96-django-and-python-3-how-to-setup-pyenv-for-multiple-pythons/</guid></item><item><title>Frontend Code Strategy with Django</title><link>http://godjango.com/blog/frontend-code-strategy-with-django/</link><description>&lt;p&gt;Web development is getting more and more focused on front-end development. This leads to a lot of questions on what is the best way to handle compiling css, javascript, coffeescirpt, stylus, etc. Having been involved with a project where the frontend deals with 100+ files between stylus files, coffeescirpt files, javascript, and css. This is kind of crazy to manage without a good strategy or even knowing how to accomplish it.&lt;/p&gt;
&lt;h2&gt;How Frontend Code Works in Django&lt;/h2&gt;
&lt;p&gt;When working with django you need to consider how the code is going to go from your code base to be displayed in the browser. The normal path it takes is to live in a static directory which you edit and run locally. Then in production you do a collectstatic command and it moves everything to a folder for your webserver to pull from. With that in mind as long as the above happens you can do almost anything you want for your frontend code. Lets take a look at the 3 most common ways you can do front-end development with django.&lt;/p&gt;
&lt;h2&gt;Three Popular Ways to Write Frontend Code&lt;/h2&gt;
&lt;h3&gt;Everything in the static folder&lt;/h3&gt;
&lt;p&gt;The most common way we start projects is to just stuff everything in a static file on the root of our project. We add img, css, and js folders to keep things organized. We then use the &lt;code&gt;staticfiles app&lt;/code&gt; to use template helpers for loading in our static files without having to hard code them. This will get us a long way, and for most sites is a good approach, because lets face it most sites don't move past hobby projects.&lt;/p&gt;
&lt;p&gt;To get this working about the only configuration you need is:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;INSTALLED_APPS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
    &lt;span class="s"&gt;&amp;#39;django.contrib.staticfiles&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;STATIC_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;/static/&amp;#39;&lt;/span&gt;
&lt;span class="n"&gt;STATICFILES_DIRS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BASE_DIR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;static&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;STATIC_ROOT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BASE_DIR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;static_final&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To see it in action you can watch a video here: &lt;a href="https://godjango.com/34-static-files-template-filters-and-commands/"&gt;Staticfiles, template filters, and commands&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Third Party Django Library&lt;/h3&gt;
&lt;p&gt;The next step people often move to is using a third party django app which kind of takes care of everything for you. You set in the settings what you want to use to compile and preprocess code. The django app then does all the processing, finally outputing the final information where we tell it, generally from the settings above. It is fairly simple and straight forward to use these libraries especially since they don't really break your workflow, and you get the addition of using the latest cool technologies.&lt;/p&gt;
&lt;p&gt;The two most populare packages I have seen is django-compressor and django-pipeline, a fork of compressor. Both are fairly simple to setup and configure, but they do have their limitations and oddities. I would recommend doing a side project with each to evaluate which one you like, to determine if it is right for you.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://django-compressor.readthedocs.org/en/latest/"&gt;django-compressor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://django-pipeline.readthedocs.org/en/latest/"&gt;django-pipeline&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you want to checkout a video for django-pipline go here: &lt;a href="https://godjango.com/49-compile-and-compress-assets-with-django-pipeline/"&gt;Compile and compress assets with django-pipline&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Front-end Build System&lt;/h3&gt;
&lt;p&gt;The final way most often seen for building front end code is to use an entire build system outside of django completely. You setup your static file locations like we did above, and then you tell the independent build system to output your files there. Generally you would use something like grunt, gulp or brunch to do this. This method gives you the most flexibility and freedom, but is the most time consuming to setup and learn. If you heavily rely on front end code then this is probably the best solution, especially for single page apps.&lt;/p&gt;
&lt;p&gt;Also by taking the time to learn some of these tools it helps you become a better all around developer through getting you involved in other things besides just django and python. Generally these build systems are completely custom, or based on something in the node.js world. Below are some of the more popular ones:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://gruntjs.com/"&gt;grunt.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://gulpjs.com/"&gt;gulp.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://brunch.io/"&gt;brunch&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There is also a video on this method as well using gulp check it out here: &lt;a href="https://godjango.com/77-use-gulpjs-to-manage-static-assets/"&gt;Use gulp.js to manage static assets&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Knowing what is the best way to build your assets is hard, I use all three methods in various projects. So I kind of take a tiered approach to know when to choose what method. If it is a small site where I am going to write it once and forget about it or maybe touch it a couple of times a year I don't worry about a build system at all, not worth the effort. If I am going to touch the code once a month on average I will generally use django-pipeline. However, if I am touching the code base 2+ times a month it means I am probably touching it more than that and I need to have the most flexibility, so I will use gulp.&lt;/p&gt;
&lt;p&gt;These are the rules I follow, but I suggest you take a look at these methods and find your own sweet spot.&lt;/p&gt;
</description><pubDate>Mon, 13 Jul 2015 15:00:00 +0000</pubDate><guid>http://godjango.com/blog/frontend-code-strategy-with-django/</guid></item><item><title>Wrapping Up CycleMento</title><link>http://godjango.com/93-wrapping-up-cyclemento/</link><description>in this video we wrap up the Building a Product series by doing an overview of topics we discussed in the previous 11 videos.&lt;br /&gt;&lt;a href='https://godjango.com/93-wrapping-up-cyclemento/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 23 Jun 2015 15:00:00 +0000</pubDate><guid>http://godjango.com/93-wrapping-up-cyclemento/</guid></item><item><title>Adding Maintenance Data pt 1</title><link>http://godjango.com/90-adding-maintenance-data-pt-1/</link><description>Join us as we continue building our product by starting to allow our users to add bike maintenance records to their bikes.&lt;br /&gt;&lt;a href='https://godjango.com/90-adding-maintenance-data-pt-1/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 15 May 2015 15:00:00 +0000</pubDate><guid>http://godjango.com/90-adding-maintenance-data-pt-1/</guid></item><item><title>Saving Data from Strava</title><link>http://godjango.com/87-saving-data-from-strava/</link><description>Getting data can be easy. Effectively saving it from one source to your database can be a pain. In this video we explore a way to get data from Strava and save it to our database with as little future trouble as possible.&lt;br /&gt;&lt;a href='https://godjango.com/87-saving-data-from-strava/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Wed, 08 Apr 2015 15:00:00 +0000</pubDate><guid>http://godjango.com/87-saving-data-from-strava/</guid></item><item><title>Informing Users with django.contrib.messages</title><link>http://godjango.com/84-informing-users-with-djangocontribmessages/</link><description>The messages framework can be bit confusing to wrap your head around at first. Learn the basics of setting successful and error messages and show them to users. See the default django way, then see how to do with django-braces.&lt;br /&gt;&lt;a href='https://godjango.com/84-informing-users-with-djangocontribmessages/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Thu, 26 Feb 2015 16:00:00 +0000</pubDate><guid>http://godjango.com/84-informing-users-with-djangocontribmessages/</guid></item><item><title>Account Control part 1</title><link>http://godjango.com/81-account-control-part-1/</link><description>This is the first in a series of videos on creating a product which utilizes other services to help your users stay informed. We start the series with getting our users setup with an account, and giving them the ability to log in and out.&lt;br /&gt;&lt;a href='https://godjango.com/81-account-control-part-1/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 30 Jan 2015 16:00:00 +0000</pubDate><guid>http://godjango.com/81-account-control-part-1/</guid></item><item><title>Custom Django Admin Actions</title><link>http://godjango.com/78-custom-django-admin-actions/</link><description>Doing bulk data actions in the admin is easy, if you know how to do it. In this video you will learn how to create your own custom admin actions so you can update a lot of data objects all at the same time.&lt;br /&gt;&lt;a href='https://godjango.com/78-custom-django-admin-actions/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Wed, 24 Dec 2014 16:00:00 +0000</pubDate><guid>http://godjango.com/78-custom-django-admin-actions/</guid></item><item><title>Project Templates with Cookiecutter</title><link>http://godjango.com/75-project-templates-with-cookiecutter/</link><description>When we start new projects we want to solve a problem, not write boilerplate. Cookiecutter helps you to stop writing boilerplate. In this video you will learn what cookiecutter is, and how to create templates so you can save yourself time and effort starting new projects.&lt;br /&gt;&lt;a href='https://godjango.com/75-project-templates-with-cookiecutter/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 24 Nov 2014 16:00:00 +0000</pubDate><guid>http://godjango.com/75-project-templates-with-cookiecutter/</guid></item><item><title>Using Arrow for Better Datetime</title><link>http://godjango.com/72-using-arrow-for-better-datetime/</link><description>Learn how to be better at dealing with dates and times in python in a few short minutes. Working with dates and times in python is a lot easier than other languages, but can be convoluted and confusing. Arrow provides a convenient api for working with and manipulating dates and times. See what it takes to get started.&lt;br /&gt;&lt;a href='https://godjango.com/72-using-arrow-for-better-datetime/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Wed, 29 Oct 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/72-using-arrow-for-better-datetime/</guid></item><item><title>The Class Based "View"</title><link>http://godjango.com/69-the-class-based-view/</link><description>People often find working with class based views hard, but they are simple... Once you spend time figuring them out. In this video start with the base of building blocks and work your way through completly understanding the base View of (generic) class based views.&lt;br /&gt;&lt;a href='https://godjango.com/69-the-class-based-view/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 29 Sep 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/69-the-class-based-view/</guid></item><item><title>Understanding get_absolute_url</title><link>http://godjango.com/67-understanding-get_absolute_url/</link><description>URL's can be a pain at times, but with get_absolute_url on your model it can make dealing with them on a per-object basis much simpler and cleaner across your entire site. Not to mention Django itself loves to use get_absolute_url, so it will make other tasks a lot easier.&lt;br /&gt;&lt;a href='https://godjango.com/67-understanding-get_absolute_url/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 09 Sep 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/67-understanding-get_absolute_url/</guid></item><item><title>Starting with django-allauth</title><link>http://godjango.com/65-starting-with-django-allauth/</link><description>There are a lot of ways to do authentication in django. You can do social authentication and/or django.contrib.auth authentication. Generally they are separate, but with django-allauth you can combine them both into one package. It even gives you a great jumping off place with plenty of other features. In this video learn how to start using django-allauth.&lt;br /&gt;&lt;a href='https://godjango.com/65-starting-with-django-allauth/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 11 Aug 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/65-starting-with-django-allauth/</guid></item><item><title>Deferred Tasks and Scheduled Jobs with Celery 3.1, Django 1.7 and Redis</title><link>http://godjango.com/63-deferred-tasks-and-scheduled-jobs-with-celery-31-django-17-and-redis/</link><description>Setting up celery with Django can be a pain, but it doesn't have to be. In this video learn what it takes to setup Celery for deferred tasks, and as your cron replacement. We will use Celery 3.1 and Django 1.7 both introduce changes you need to be aware of.&lt;br /&gt;&lt;a href='https://godjango.com/63-deferred-tasks-and-scheduled-jobs-with-celery-31-django-17-and-redis/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 14 Jul 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/63-deferred-tasks-and-scheduled-jobs-with-celery-31-django-17-and-redis/</guid></item><item><title>Using Chart.js with Django</title><link>http://godjango.com/blog/using-chartjs-with-django/</link><description>&lt;p&gt;&lt;img src="https://s3.amazonaws.com/godjango-media/chartjs-header.png" alt="Chart.js Header"&gt;&lt;/p&gt;
&lt;p&gt;Chart.js is the new kid on on the block for JavaScript charts. Learn how to use them here to chart out the number of user registrations for the last 30 days.&lt;/p&gt;
&lt;h2&gt;The View&lt;/h2&gt;
&lt;p&gt;This view builds an array of people that registered on the site daily for the last 30 days.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.views.generic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;TemplateView&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.contrib.auth.models&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;User&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;arrow&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AnalyticsIndexView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TemplateView&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;template_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;analytics/admin/index.html&amp;#39;&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_context_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;AnalyticsIndexView&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_context_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;30_day_registrations&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;thirty_day_registrations&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;thirty_day_registrations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;final_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

        &lt;span class="n"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;arrow&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;day&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;xrange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;days&lt;/span&gt;&lt;span class="o"&gt;=-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;User&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;date_joined__gte&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;day&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;date_joined__lte&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ceil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;day&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;final_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;final_data&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The method &lt;code&gt;thirty_day_registrations&lt;/code&gt; loops through from 1 to 30, and gets the count of registrations for that day. Then it returns that array back to the &lt;code&gt;get_context_data&lt;/code&gt; method and assigns it to 30_day_registrations which is what we will use in our template.&lt;/p&gt;
&lt;h2&gt;The Template&lt;/h2&gt;
&lt;p&gt;The template is very basic in that it has just enough data to generate a line chart.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;{% extends &amp;quot;base.html&amp;quot; %}

{% block extrahead %}
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;//cdnjs.cloudflare.com/ajax/libs/Chart.js/0.2.0/Chart.min.js&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt; &lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;labels&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;1&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;5&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;10&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;15&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;20&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;25&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;30&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="nx"&gt;datasets&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Site Registrations in the Last 30 Days&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nx"&gt;fillColor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rgba(220,220,220,0.2)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nx"&gt;strokeColor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rgba(220,220,220,1)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nx"&gt;pointColor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rgba(220,220,220,1)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nx"&gt;pointStrokeColor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;#fff&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nx"&gt;pointHighlightFill&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;#fff&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nx"&gt;pointHighlightStroke&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rgba(220,220,220,1)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="nx"&gt;_day_registrations&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;myChart&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;2d&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;myLineChart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Chart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;Line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
{% endblock %}

{% block content %}
&lt;span class="nt"&gt;&amp;lt;canvas&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;myChart&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;500&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;300&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/canvas&amp;gt;&lt;/span&gt;
{% endblock %}
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If we go line-by-line of the important parts this should make more sense.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nt"&gt;&amp;lt;canvas&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;myChart&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;500&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;300&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/canvas&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is where in the page your chart is going to show up its only real requirement is it has an id and is a canvas object.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;ctx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;myChart&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;2d&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This gets us the canvas element for us to feed data to so we can see our chart.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;myLineChart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Chart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;Line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We create a &lt;code&gt;Chart&lt;/code&gt; object and pass it our canvas element. Then we create our Line chart using a data object we are going to create.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;labels&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;1&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;5&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;10&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;15&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;20&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;25&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;30&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="nx"&gt;datasets&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Site Registrations in the Last 30 Days&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;fillColor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rgba(220,220,220,0.2)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;strokeColor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rgba(220,220,220,1)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;pointColor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rgba(220,220,220,1)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;pointStrokeColor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;#fff&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;pointHighlightFill&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;#fff&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;pointHighlightStroke&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rgba(220,220,220,1)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="nx"&gt;_day_registrations&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is an example data object to create a chart. Most of it is self-explanatory, but the keys parts are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;labels&lt;/strong&gt;: this is outside of the datasets object.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;datasets&lt;/strong&gt;: you can have multiple json objects in here for more lines in chart&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;data&lt;/strong&gt;: in this case it is just an array, which in this case we are generating in our view and outputting here.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Chart.js is a great library for doing charting, especially if your primary audience is using more modern browsers. I have been looking at charting libraries, but so far this has been one of the best ones of both paid and free ones. The best part is right now chart.js is free. So if you need to do some charting I would say give it a shot.&lt;/p&gt;
</description><pubDate>Mon, 07 Jul 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/blog/using-chartjs-with-django/</guid></item><item><title>Stripe, Webhooks and dj-stripe</title><link>http://godjango.com/61-stripe-webhooks-and-dj-stripe/</link><description>Stripe is great for working with payments. Webhooks and dj-stripe make it even better, in this video learn how to use stripe webhooks with your application to get the most out of your stripe integration.&lt;br /&gt;&lt;a href='https://godjango.com/61-stripe-webhooks-and-dj-stripe/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 23 Jun 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/61-stripe-webhooks-and-dj-stripe/</guid></item><item><title>Stripe and Starting dj-stripe</title><link>http://godjango.com/59-stripe-and-starting-dj-stripe/</link><description>Stripe is great, but using a library makes it even better. Dj-stripe is a great django library for working with stripe to get people to subscribe to your service. See how simple it is to start working with dj-stripe.&lt;br /&gt;&lt;a href='https://godjango.com/59-stripe-and-starting-dj-stripe/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Thu, 12 Jun 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/59-stripe-and-starting-dj-stripe/</guid></item><item><title>Starting with Stripe.js</title><link>http://godjango.com/57-starting-with-stripejs/</link><description>We all want to make money, so learn what it takes to start accepting money on your site with stripe. Learn the basics of have a user subscribe to your site in this first part of a multi-part stripe series.&lt;br /&gt;&lt;a href='https://godjango.com/57-starting-with-stripejs/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 23 May 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/57-starting-with-stripejs/</guid></item><item><title>Working with JSON and Django</title><link>http://godjango.com/blog/working-with-json-and-django/</link><description>&lt;p&gt;In this day and age of web development we work with json, a lot, especially with using web services. Unfortunately, sometimes you can forget what does what, when, and where when dealing with json. I know I have to look up the same thing over and over at times. This blog post is everything you need to deal with json "day-to-day" with Django.&lt;/p&gt;
&lt;h2&gt;JSON to Dict&lt;/h2&gt;
&lt;p&gt;One of the first things we, usually, do is convert json data that we get back from a web service call, or from a &lt;a href="https://godjango.com/55-webhooks-django-and-ngrok/"&gt;webhook&lt;/a&gt;, into a python datastructure.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;json&lt;/span&gt;

&lt;span class="n"&gt;json_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;{&amp;quot;hello&amp;quot;: &amp;quot;world&amp;quot;, &amp;quot;foo&amp;quot;: &amp;quot;bar&amp;quot;}&amp;#39;&lt;/span&gt; 

&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json_data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The key element from this is the json.loads which loads a string of json and converts the data to a python dict. From there you get to use it like normal.&lt;/p&gt;
&lt;h2&gt;Dict to JSON&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;json&lt;/span&gt;

&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;baz&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;goo&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;foo&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;bar&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;json_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Normally you want to get your data into json from your dict, or model, which is just as easy using json.dumps. It converts your dict to a string of json so you can return it to in a response.&lt;/p&gt;
&lt;h2&gt;HttpResponse with JSON&lt;/h2&gt;
&lt;p&gt;There are a couple of key parts to returning json properly. You need to have a string of json, and a proper content type.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.http&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HttpResponse&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fbview&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;foo&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;bar&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;hello&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;world&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;application/json&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;With this you will send back json properly formatted and with the proper content type so everyone knows what is going on with the data.&lt;/p&gt;
&lt;h2&gt;JSONRequestResponseMixin from django-braces&lt;/h2&gt;
&lt;p&gt;Finally, if you are working with class based views you can use a very convenient mixin in &lt;a href="https://github.com/brack3t/django-braces"&gt;django-braces&lt;/a&gt;. JSONRequestResponseMixin which gives you some built-in response methods to return your dicts and models back as json, and it handles everything else.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;APIView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CsrfExemptMixin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;JsonRequestResponseMixin&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;foo&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;bar&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;hello&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;world&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;render_json_response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As you can probably guess the render_json_response method does what the function based view above does by converting the dict to json and returning the proper response.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Hopefully this is a good primer and/or reminder of how you can work with json with python and django. This takes care of all your basics so you can get started with json, or do it better.&lt;/p&gt;
</description><pubDate>Mon, 28 Apr 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/blog/working-with-json-and-django/</guid></item><item><title>Webhooks, Django, and ngrok</title><link>http://godjango.com/55-webhooks-django-and-ngrok/</link><description>Working with webhooks can be a pain. In this video learn more of what they are and how to easily work with them in your local environment using ngrok.&lt;br /&gt;&lt;a href='https://godjango.com/55-webhooks-django-and-ngrok/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 25 Apr 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/55-webhooks-django-and-ngrok/</guid></item><item><title>Django 1.7 Migrations - An Introduction</title><link>http://godjango.com/53-django-17-migrations-an-introduction/</link><description>See what it takes to use the new migrations system that has been integrated into Django 1.7. This video walks you through how to create migrations, and run them. Along with a few other key points you might want to know.&lt;br /&gt;&lt;a href='https://godjango.com/53-django-17-migrations-an-introduction/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 08 Apr 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/53-django-17-migrations-an-introduction/</guid></item><item><title>Download CSV files via CSVResponseMixin</title><link>http://godjango.com/blog/download-csv-files-via-csvresponemixin/</link><description>&lt;iframe src="//embed.gettyimages.com/embed/88620938?et=gOGXtimjgkaCtnj8u2OB5w&amp;sig=hWnuyyuP5Q0-Pz_NwF9toAbStknOZrXNY-cG_h3fIDM=" width="478" height="428" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;p&gt;Providing csv files to people is annoying, but writing a custom mixin for use with your views can make it super easy. Often times we have to use a custom function, of some sort, and rejigger around how our views work to get a csv file, then set header information, and finally return a response.&lt;/p&gt;
&lt;h2&gt;There is a Better Way&lt;/h2&gt;
&lt;p&gt;Below is a custom mixin you can write, or use, to return a csv file based on a list of lists.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CSVResponseMixin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;object&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;csv_filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;csvfile.csv&amp;#39;&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_csv_filename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;csv_filename&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;render_to_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;text/csv&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;cd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;attachment; filename=&amp;quot;{0}&amp;quot;&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_csv_filename&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
        &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Content-Disposition&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cd&lt;/span&gt;

        &lt;span class="n"&gt;writer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writerow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The first few lines of code are simple. We are declaring the mixin, setting the filename, and returning the filename based on a method on the mixin. That leaves us with the render_to_csv method which takes a lsit of lists, and gives us a downloadable file.&lt;/p&gt;
&lt;h2&gt;Line by Line Explanation&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;text/csv&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We are creating a Django HttpResponse object which django returns, and we are setting the content type to a csv file so the browser knows what it is.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Content-Disposition&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;attachment; filename=&amp;quot;{0}&amp;quot;&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_csv_filename&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We are setting the content disposition to be an attachment so that it forces the browser to download the file. Otherwise the browser might render it out into the browser, as text. We also are setting the filename from the get_csv_filename method call instead of using the property for a couple of reasons. First, we can override it in our implementation to be more dynamic. Second, we can mock it out in our testing.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;writer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;writerow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally, we are creating a csv writer and using our response object. Then as we loop over our list of lists we write them out one at a time generating our csv data. From there we return our response object which causes the browser to download the csv file of data.&lt;/p&gt;
&lt;h2&gt;Example Implementation&lt;/h2&gt;
&lt;p&gt;A quick and dirty example of how to do this is quite simple. All you have to do is attach this to a url pattern, and you are good to go.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DataView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CSVResponseMixin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;View&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;hello&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;world&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;foo&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;bar&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;render_to_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The telling thing about this example is we are using the View class as our base class so it isn't some fancy generic class based view. This gives it simplicity people are after with function based views, but is more understandable and testable.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Just like with &lt;a href="https://godjango.com/blog/record-last-access-not-just-last-login/"&gt;LastAccessMixin&lt;/a&gt; we are leveraging good OOP practice to give us generic functionality we want to use. This one gives us a standard way to export data as a csv file in a consistent way. If you want to use this mixin plus many other useful ones checkout &lt;a href="https://github.com/brack3t/django-braces"&gt;django-braces&lt;/a&gt;. They currently have a lot of good ones, and this one will be coming in a future release.&lt;/p&gt;
</description><pubDate>Mon, 31 Mar 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/blog/download-csv-files-via-csvresponemixin/</guid></item><item><title>Better Models Through Custom Managers and QuerySets </title><link>http://godjango.com/51-better-models-through-custom-managers-and-querysets/</link><description>Learn what it takes to get common queries chain-able, and slimmer. This video goes over custom model managers and custom querysets so you can write better code, cleaner, code by harnessing the power of Django and OOP.&lt;br /&gt;&lt;a href='https://godjango.com/51-better-models-through-custom-managers-and-querysets/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 17 Mar 2014 15:00:00 +0000</pubDate><guid>http://godjango.com/51-better-models-through-custom-managers-and-querysets/</guid></item><item><title>Record Last Access Not Just Last Login</title><link>http://godjango.com/blog/record-last-access-not-just-last-login/</link><description>&lt;iframe src="//embed.gettyimages.com/embed/451358609?et=d48F9r4HdkqtcEeElcdaaw&amp;sig=xWFo3IaEClL38q7qjnVJ9ZoGs3EaVF4SSHQ5j5hRctc=" width="557" height="407" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;p&gt;Knowing when a person last logged in is great, except when it isn't. Sometimes you want to know when a user last actually used your app. Since you can stay continually logged in to Django sites we need an alternative way to know when a person was last on your site.&lt;/p&gt;
&lt;p&gt;If you are using class based views, and you should, then writing a mixin is a good way to go.&lt;/p&gt;
&lt;h2&gt;LastAccessMixin&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.utils&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LastAccessMixin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;object&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_authenticated&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;accessdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;last_access&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;accessdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;update_fields&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;last_access&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LastAccessMixin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;What Does this Code Do?&lt;/h2&gt;
&lt;p&gt;The first place class based views go is to the disatch method. This "dispatches" the request to the proper place. It determines what type of a request it is be it a GET, POST, HEAD etc. From there it goes to the appropriate method.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We are overriding the dispatch method because it is always called, and only once. We also want to use the dispatch method instead of say get because on some urls we might use a post method, then we wouldn't know the page was used.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;is_authenticated&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;accessdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;last_access&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;accessdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;update_fields&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;last_access&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the method, before it routes away, we are wanting to record the user accessed the page. So we are simply updating a model attached to the user model with the current time, then saving it. Nothing too complicated.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LastAccessMixin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Since we are done recording that the user hit a page we can call the rest of the dispatch so the request continues on properly.&lt;/p&gt;
&lt;h2&gt;Using LastAccessMixin&lt;/h2&gt;
&lt;p&gt;The best way to use this mixin is to include it in the declaration of your class based view similar to below:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;django.views.generic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;TemplateView&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;home.mixins&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LastAccessMixin&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;IndexView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LastAccessMixin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TemplateView&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;template_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;home/index.html&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now when a user visits the index page, and they are logged in, the time is logged. You can add this mixin to any class based view, and you are set.&lt;/p&gt;
&lt;h2&gt;Closing Thoughts&lt;/h2&gt;
&lt;p&gt;This is a quick implementation of this functionality. The mixin can be expanded to be much more robust, and universal. However, this is a good demonstration of the power of mixins, and an easy way to solve what could have been a complex problem.&lt;/p&gt;
&lt;p&gt;As a final note since all we want to really know is that users are using the site it is, probably, recommended to choose a few specific views to use this with, and not every single view.&lt;/p&gt;
&lt;p&gt;I would be curious if you know of other ways to accomplish this.&lt;/p&gt;
</description><pubDate>Fri, 07 Mar 2014 21:30:00 +0000</pubDate><guid>http://godjango.com/blog/record-last-access-not-just-last-login/</guid></item><item><title>Compile and Compress Assets with django-pipeline</title><link>http://godjango.com/49-compile-and-compress-assets-with-django-pipeline/</link><description>Using things like CoffeeScript, Stylus, Less, SASS/SCSS, etc... Is becoming a more and more core part of development, but the problem usually is compiling these assets for use on our site. With django-pipeline this process is now much easier in both development and production. Learn the few easy steps it takes to get started with it.&lt;br /&gt;&lt;a href='https://godjango.com/49-compile-and-compress-assets-with-django-pipeline/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Sat, 01 Mar 2014 21:00:00 +0000</pubDate><guid>http://godjango.com/49-compile-and-compress-assets-with-django-pipeline/</guid></item><item><title>django-storages and AmazonS3</title><link>http://godjango.com/47-django-storages-and-amazons3/</link><description>Saving files in the cloud, be it Amazon S3, Azure, or Rackspace, is very common now and almost a requirement. django-storages makes this seemless. This video shows you just how easy it is to get started.&lt;br /&gt;&lt;a href='https://godjango.com/47-django-storages-and-amazons3/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 03 Feb 2014 16:00:00 +0000</pubDate><guid>http://godjango.com/47-django-storages-and-amazons3/</guid></item><item><title>ViewSets and Routers - django-rest-framework part 3</title><link>http://godjango.com/45-viewsets-and-routers-django-rest-framework-part-3/</link><description>ViewSets and Routers are very useful for slimming up your code and providing a lot of default functionality out of the box. They are powerful features in django-rest-framework allowing a lot of flexibility in your code while keeping things clean.&lt;br /&gt;&lt;a href='https://godjango.com/45-viewsets-and-routers-django-rest-framework-part-3/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 20 Jan 2014 16:00:00 +0000</pubDate><guid>http://godjango.com/45-viewsets-and-routers-django-rest-framework-part-3/</guid></item><item><title>Permissions &amp; Authentication - django-rest-framework part 2</title><link>http://godjango.com/43-permissions-authentication-django-rest-framework-part-2/</link><description>Learn how to use basic authentication with your new API, and setup custom permissions to get fine grained precision of what can be done with data.&lt;br /&gt;&lt;a href='https://godjango.com/43-permissions-authentication-django-rest-framework-part-2/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Sun, 05 Jan 2014 00:00:00 +0000</pubDate><guid>http://godjango.com/43-permissions-authentication-django-rest-framework-part-2/</guid></item><item><title>Start Your API - django-rest-framework part 1</title><link>http://godjango.com/41-start-your-api-django-rest-framework-part-1/</link><description>In this video we start creating our API by learning what it takes to put data in our database, and retrieve it back doing all of our CRUD operations. django-rest-framework makes it very simple to accomplish with a minimal amount of effort.&lt;br /&gt;&lt;a href='https://godjango.com/41-start-your-api-django-rest-framework-part-1/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 16 Dec 2013 16:00:00 +0000</pubDate><guid>http://godjango.com/41-start-your-api-django-rest-framework-part-1/</guid></item><item><title>Be More Productive with django_extensions</title><link>http://godjango.com/39-be-more-productive-with-django_extensions/</link><description>Django provides a lot of really useful things by default, but there are a few things we do over and over again. Learn how django extensions help solve some of these, and enhances your ability to do others with this intro to django-extensions. We will show a few of the many many useful things it can do.&lt;br /&gt;&lt;a href='https://godjango.com/39-be-more-productive-with-django_extensions/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Thu, 28 Nov 2013 16:00:00 +0000</pubDate><guid>http://godjango.com/39-be-more-productive-with-django_extensions/</guid></item><item><title>Transform Images with django-imagekit</title><link>http://godjango.com/37-transform-images-with-django-imagekit/</link><description>In this video we will walk through a couple of easy ways to transform images as you need them. django-imagekit makes this fairly simple and straight forward. This video provides an introduction to using it.&lt;br /&gt;&lt;a href='https://godjango.com/37-transform-images-with-django-imagekit/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Sat, 16 Nov 2013 16:00:00 +0000</pubDate><guid>http://godjango.com/37-transform-images-with-django-imagekit/</guid></item><item><title>Upload Files</title><link>http://godjango.com/35-upload-files/</link><description>Learn how to use Django to let your users upload files. This uses only what is built into Django to get you started.&lt;br /&gt;&lt;a href='https://godjango.com/35-upload-files/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Wed, 30 Oct 2013 15:00:00 +0000</pubDate><guid>http://godjango.com/35-upload-files/</guid></item><item><title>Tagging with django-taggit</title><link>http://godjango.com/33-tagging-with-django-taggit/</link><description>In this video you will learn an easy way to add tags to your models, and on your site. Tags can be hard if you try to implement them yourself, so don't try and just use this library from the start.&lt;br /&gt;&lt;a href='https://godjango.com/33-tagging-with-django-taggit/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Wed, 09 Oct 2013 15:00:00 +0000</pubDate><guid>http://godjango.com/33-tagging-with-django-taggit/</guid></item><item><title>django-waffle</title><link>http://godjango.com/31-django-waffle/</link><description>Learn how to use this popular feature flipper for helping you to develop and test new features live instead of only in development.&lt;br /&gt;&lt;a href='https://godjango.com/31-django-waffle/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Wed, 25 Sep 2013 15:00:00 +0000</pubDate><guid>http://godjango.com/31-django-waffle/</guid></item><item><title>crispy-forms</title><link>http://godjango.com/29-crispy-forms/</link><description>Learn how to get started using the popular crispy forms django application to streamline rendering your templates by doing your layout in python.&lt;br /&gt;&lt;a href='https://godjango.com/29-crispy-forms/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 10 Sep 2013 15:00:00 +0000</pubDate><guid>http://godjango.com/29-crispy-forms/</guid></item><item><title>Activity Feed with Event Log</title><link>http://godjango.com/27-activity-feed-with-event-log/</link><description>Adding an activity feed is simple with the eventlog application. I show you how to get started with it by easily adding it to your project, and how use and administer it.&lt;br /&gt;&lt;a href='https://godjango.com/27-activity-feed-with-event-log/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 27 Aug 2013 15:00:00 +0000</pubDate><guid>http://godjango.com/27-activity-feed-with-event-log/</guid></item><item><title>Travis-CI and Coveralls</title><link>http://godjango.com/25-travis-ci-and-coveralls/</link><description>Continuous Integration and Code Coverage used to be hard. Now with Travis-CI and Coveralls life just got a lot easier, especially for open source projects. In this video we will go over setting up travis and coveralls for django applications.&lt;br /&gt;&lt;a href='https://godjango.com/25-travis-ci-and-coveralls/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Thu, 25 Jul 2013 03:00:00 +0000</pubDate><guid>http://godjango.com/25-travis-ci-and-coveralls/</guid></item><item><title>Robots and Sitemaps</title><link>http://godjango.com/23-robots-and-sitemaps/</link><description>Dealing with google site indexing from google and other search engines can be a pain, but fortunately django makes it easy with django.contrib.sitemaps and the django-robots app. In this video learn to create sitemap.xml and robots.txt quickly and easily.&lt;br /&gt;&lt;a href='https://godjango.com/23-robots-and-sitemaps/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 08 Jul 2013 14:00:00 +0000</pubDate><guid>http://godjango.com/23-robots-and-sitemaps/</guid></item><item><title>Starting Jinja2</title><link>http://godjango.com/21-starting-jinja2/</link><description>Jinja2 is a great templating language based on Django's templating engine. It has some great features, and is more performant. This video shows you how to get started with it in your projects today.&lt;br /&gt;&lt;a href='https://godjango.com/21-starting-jinja2/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Sun, 23 Jun 2013 03:30:00 +0000</pubDate><guid>http://godjango.com/21-starting-jinja2/</guid></item><item><title>Using Templates for Sending Emails</title><link>http://godjango.com/19-using-templates-for-sending-emails/</link><description>Sending nice pretty emails en-mass, or at regular intervals requires work so they look good. Fortunately Django's templates offers a great way to email uniform looking emails to your users. This video shows you how to do it, and keep it simple.&lt;br /&gt;&lt;a href='https://godjango.com/19-using-templates-for-sending-emails/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Wed, 05 Jun 2013 19:00:00 +0000</pubDate><guid>http://godjango.com/19-using-templates-for-sending-emails/</guid></item><item><title>Basic Ajax</title><link>http://godjango.com/18-basic-ajax/</link><description>Ajax is essential these days, and fortunately Django provides some good mechanism for doing AJAX well. This video goes over some of the basics you need to do and know when doing AJAX in Django.&lt;br /&gt;&lt;a href='https://godjango.com/18-basic-ajax/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Thu, 30 May 2013 03:00:00 +0000</pubDate><guid>http://godjango.com/18-basic-ajax/</guid></item><item><title>Class Based Views Part 3: DetailView and template_name Shortcut</title><link>http://godjango.com/17-class-based-views-part-3-detailview-and-template_name-shortcut/</link><description>The DetailView is an important class based view since it allows us to show off details of our data instead of just bits here and there. It is also very simple to use and will save you time. In this video you are also going to see a nice little shortcut with your templates to save you from writing a couple of extra lines.&lt;br /&gt;&lt;a href='https://godjango.com/17-class-based-views-part-3-detailview-and-template_name-shortcut/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 24 Apr 2012 20:00:00 +0000</pubDate><guid>http://godjango.com/17-class-based-views-part-3-detailview-and-template_name-shortcut/</guid></item><item><title>Class Based Views Part 2: ListView and FormView</title><link>http://godjango.com/16-class-based-views-part-2-listview-and-formview/</link><description>The ListView and FormView class based generic views are the first look we have at generic views with some power behind them which can really save us some code. The ListView is great for showing content and paginating said content with very little effort. While the FormView is great for dealing with class based forms without having to deal, to much, with the underlying request itself.&lt;br /&gt;&lt;a href='https://godjango.com/16-class-based-views-part-2-listview-and-formview/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 17 Apr 2012 22:32:53 +0000</pubDate><guid>http://godjango.com/16-class-based-views-part-2-listview-and-formview/</guid></item><item><title>Class Based Views Part 1: TemplateView and RedirectView</title><link>http://godjango.com/15-class-based-views-part-1-templateview-and-redirectview/</link><description>This is the first episode in a series of videos on Class Based generic Views. These are important to learn since the function based generic views are being deprecated, and Class Based generic Views will help to streamline things moving forward when dealing with views. This video goes over the most basic views, TemplateView and RedirectView. The video uses simple scenarios, but usable, to get you started.&lt;br /&gt;&lt;a href='https://godjango.com/15-class-based-views-part-1-templateview-and-redirectview/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Wed, 04 Apr 2012 20:45:00 +0000</pubDate><guid>http://godjango.com/15-class-based-views-part-1-templateview-and-redirectview/</guid></item><item><title>Using django.contrib.markup </title><link>http://godjango.com/14-using-djangocontribmarkup/</link><description>Having your users input data and outputting it in ways other than straight plain text can be complicated. However, using different markup languages like markdown can make things easier for you the developer and your users. This video goes over how to use markdown, textile and restructured text built right into Django.&lt;br /&gt;&lt;a href='https://godjango.com/14-using-djangocontribmarkup/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 27 Mar 2012 21:00:00 +0000</pubDate><guid>http://godjango.com/14-using-djangocontribmarkup/</guid></item><item><title>django-social-auth 101</title><link>http://godjango.com/13-django-social-auth-101/</link><description>Django-social-auth is probably the best, at the very least one of the best, Django applications for handling 3rd party authentication systems. It can handle everything from github, twitter, facebook to open-id and browser-id. It is very flexible and easy to setup. This video will show you how to setup it up to work with github and get you started using django-social-auth.&lt;br /&gt;&lt;a href='https://godjango.com/13-django-social-auth-101/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 20 Mar 2012 22:30:00 +0000</pubDate><guid>http://godjango.com/13-django-social-auth-101/</guid></item><item><title>Pagination</title><link>http://godjango.com/12-pagination/</link><description>When you have a lot of data to sift through pagination is one of the best ways we have to visually breakup data so it is not as daunting. In this video we will use the Paginator built right into Django. It is much simpler than it sounds like it might be.&lt;br /&gt;&lt;a href='https://godjango.com/12-pagination/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Thu, 15 Mar 2012 00:00:00 +0000</pubDate><guid>http://godjango.com/12-pagination/</guid></item><item><title>Browser ID</title><link>http://godjango.com/11-browser-id/</link><description>Browser ID is Mozillas new federated authentication system. This screencast walks you through using the django-browserid package to do your authentication, and attach it to the built in Django auth system&lt;br /&gt;&lt;a href='https://godjango.com/11-browser-id/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 21 Feb 2012 20:30:00 +0000</pubDate><guid>http://godjango.com/11-browser-id/</guid></item><item><title>Forms Part 5: Basic Form Validation</title><link>http://godjango.com/10-forms-part-5-basic-form-validation/</link><description>Forms are a big subject in Django. We have run through a lot when it comes to forms. We are concluding our series with Form Validation. This simple video will finalize everything we have done so far by allowing us to give feedback to our users when our form validation goes wrong.&lt;br /&gt;&lt;a href='https://godjango.com/10-forms-part-5-basic-form-validation/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 14 Feb 2012 21:45:00 +0000</pubDate><guid>http://godjango.com/10-forms-part-5-basic-form-validation/</guid></item><item><title>Forms Part 4: Formsets</title><link>http://godjango.com/9-forms-part-4-formsets/</link><description>Formsets make life easier when it comes to dealing with multiple forms of the same type on the same page. In this episode we will show you how to set them up, and the basics of how to save that data to the database. It is not much different from dealing with single forms. &lt;br /&gt;&lt;a href='https://godjango.com/9-forms-part-4-formsets/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 31 Jan 2012 21:00:00 +0000</pubDate><guid>http://godjango.com/9-forms-part-4-formsets/</guid></item><item><title>Forms Part 3: Model Based Forms</title><link>http://godjango.com/8-forms-part-3-model-based-forms/</link><description>Model forms really helps to show the power behind Django. When all it takes is to define a model and then attach the model object to a form object and poof you have a form, I call that winning. In this video we will go over using your models you already have to create forms to save you time, heartache, and code.&lt;br /&gt;&lt;a href='https://godjango.com/8-forms-part-3-model-based-forms/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 24 Jan 2012 22:30:00 +0000</pubDate><guid>http://godjango.com/8-forms-part-3-model-based-forms/</guid></item><item><title>Forms Part 2: Class Based Forms</title><link>http://godjango.com/7-forms-part-2-class-based-forms/</link><description>Forms are generally annoying to deal with. Fortunately Django offers some great ways to work with forms to make your life easier. In this our second part on forms we walk you through Class Based Forms in Django on our way to understanding the breadth of what you can do with forms in Django.&lt;br /&gt;&lt;a href='https://godjango.com/7-forms-part-2-class-based-forms/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 17 Jan 2012 20:00:00 +0000</pubDate><guid>http://godjango.com/7-forms-part-2-class-based-forms/</guid></item><item><title>Forms Part 1: Raw Forms</title><link>http://godjango.com/6-forms-part-1-raw-forms/</link><description>Forms are generally a pain to deal with when doing sites. This is the first video in a series to help make forms in django easier to do and understand. We start with doing raw forms and not using any of the django helpers so we can understand what the helpers are doing in the future.&lt;br /&gt;&lt;a href='https://godjango.com/6-forms-part-1-raw-forms/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Tue, 20 Dec 2011 01:37:51 +0000</pubDate><guid>http://godjango.com/6-forms-part-1-raw-forms/</guid></item><item><title>RSS With the Syndication Framework</title><link>http://godjango.com/5-rss-with-the-syndication-framework/</link><description>Getting our data out to others is very important with a world full of data. RSS is one of the best ways to do this, still. We go over how to create an RSS feed for your content as we continue to build out our demo blog. It is so simple it should be illegal, check it out.&lt;br /&gt;&lt;a href='https://godjango.com/5-rss-with-the-syndication-framework/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 12 Dec 2011 21:50:26 +0000</pubDate><guid>http://godjango.com/5-rss-with-the-syndication-framework/</guid></item><item><title>Deploying Django to Heroku</title><link>http://godjango.com/4-deploying-django-to-heroku/</link><description>Heroku makes life easier for those web developers that just want to deploy our code and it work. In this screencast we walk you through creating a heroku app, deploying your actual code, and running south migrations. This will make development and deployment easier for everyone.&lt;br /&gt;&lt;a href='https://godjango.com/4-deploying-django-to-heroku/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 05 Dec 2011 13:00:00 +0000</pubDate><guid>http://godjango.com/4-deploying-django-to-heroku/</guid></item><item><title>Introduction to South Migrations</title><link>http://godjango.com/3-introduction-to-south-migrations/</link><description>South Migrations are becoming the de-facto standard for those that need to use migrations in Django. They are also very useful as well. This video is an introduction to using south migrations in your projects whether starting a new application or adding it to an existing one. &lt;br /&gt;&lt;a href='https://godjango.com/3-introduction-to-south-migrations/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 28 Nov 2011 13:00:00 +0000</pubDate><guid>http://godjango.com/3-introduction-to-south-migrations/</guid></item><item><title>Adding CoffeeScript</title><link>http://godjango.com/2-adding-coffeescript/</link><description>With CoffeeScript becoming more and more popular it is time to start using it. This video is about how to get CoffeeScript added to your project so you can start developing with it.&lt;br /&gt;&lt;a href='https://godjango.com/2-adding-coffeescript/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Mon, 21 Nov 2011 23:18:12 +0000</pubDate><guid>http://godjango.com/2-adding-coffeescript/</guid></item><item><title>Getting Started with VirtualEnv</title><link>http://godjango.com/1-getting-started-with-virtualenv/</link><description>VirtualEnv is a great tool to allow you to create multiple distinct environments to prevent versioning issues of your dependencies, or to even use different versions of python by default for that environment. This screen cast walks you through the very basics of getting it going, and a bit of how it works.&lt;br /&gt;&lt;a href='https://godjango.com/1-getting-started-with-virtualenv/'&gt;Watch Now...&lt;/a&gt;</description><pubDate>Fri, 18 Nov 2011 07:13:07 +0000</pubDate><guid>http://godjango.com/1-getting-started-with-virtualenv/</guid></item></channel></rss>