I have been wanting to put this together for over a year now. This is a collection of great blogs, tips, tricks, tutorials, how-to-s that helped me go from an absolute Django noob to setting up a full fledged website (solely depending on them).
I have benefited tremendously from open source software as a student and as a professional. Here is a very small effort to acknowledge everything that helped me on, as the title suggests, my Django journey.
This post is for noobs, first time users and/or developers who are considering Django among their options to set up a website.
<On a side note, I have always questioned the use(lessness) of taglines for marketing, but Django comes with a beautiful tagline, ‘For Perfectionists with Deadlines’. I really couldn’t resist checking Django out after that 🙂 >
First off, if you are a web developer and in the decision phase for choosing the framework/stack that you want to use, IBM has an excellent overview of Django. This will give you a quick view of the backend code, the code structure and a few tools that you would have to dabble in from start to finish, without having to do any experimentation of your own. This link is meant for developers and for somebody who has requisite technical knowledge to judge a framework on technical grounds.
However, don’t get worried if you don’t find yourself in that category. If you are an absolute noob who finds oneself in the situation of having to set up a cool website, there is no need to worry at all. You can kickstart on the right foot by completing this great MOOC on Udacity: Web Development.This will require some good time investment but its totally worth it.
If you have decided on Django, then dive in:
This is the best and most succinct page I have ever come across on starting a Django project. It is an absolute MUST FOLLOW. Even if there is nothing else in this post that you read or use, this one link can take you very far in doing things the ‘right’ way. A recent update for Django 1.6 from the same author is here.
- Top this up with a thorough reading of the official Django tutorial.
At this stage you should have a good idea of everything that you need in terms of software components and the major milestones you will have to accomplish to get your website up and running.
While the Django tutorial allows you to do away with the hassles of databases and servers, obviously, real life is not like that. Which is why Link (1) is so important as it outlines steps to make real life hassle free.
I will go ahead and emphasize something more here. It is quite common to not think of servers and deployment in the initial stages. That is not such a good idea. You should think of deployment from day zero for 2 reasons. 1) You will focus on designing your code for deployment and that will make life easy towards the completion of your project. 2) If you deploy your code early, you can have a good idea of how the website will look to the world and also demonstrate your progress to others during development itself. In that spirit here are 2 links:
- Top 10 tips for a new Django Developer– You will/should keep coming back to this page during development to make your project as portable as possible and for smooth transition between servers, etc.
- Deploying Django with Fabric – This is something I wish I had done.
If all this is too much for you (tl;dr, didn’t understand etc), there is atleast one tip that I highly recommend. It worked great for me, even during development: A BASE_URL Template Variable in Django.
Enough of deployment (for now). Lets get back to the actual tools.
Link (1) covers this tool but I will mention it again because it was of tremendous help to me during development. I could manage my database and schema growth smoothly with this tool, which otherwise can be quite nightmarish during development. They also have some very nice and brief tutorials to get you up and running in a matter of minutes here. Again an absolute MUST HAVE.
(For starters you will never face this irritating error ever).
I chose to go with postgresql for the database and set it up using this short bunch of steps. I cannot find this cool blog online anymore so I have uploaded a pdf of the saved page. A few more helpful (almost MUST-KNOW) links for postgresql:
- Talking to a PostgreSQL database with psql
- 15 Practical PostgreSQL DBA commands
- 15 Advanced PostgreSQL DBA commands
For the server, I chose to go with Apache. Some helpful links:
- Quick Configuration Guide for mod_wsgi -Important for the initial setup of the application
- Start/Restart/Stop Apache web server – 3 simple commands but very handy as you will be using them every few seconds while developing.
Some obvious Apache questions (who’s answers are, well, not that obvious):
- Location of Apache Log files – Very useful for debugging
- Find out what user Apache is running as – Knowing this small thing can save you a few painful hours
- Disable access to Root directory
I am excited about this section. Some cool developer tips that made things really efficient and less annoying:
- How to keep your ssh session from timing out
- How to enable root user and How to login as root (so that you dont have to worry about any kind of system permissions ever!)
- Git Immersion – The awesomest git tutorial I have found on the web
Although the django documentation is extensive and helpful, it is lacking w.r.t these specific tasks, which can be quite confusing for a newbie:
- File Uploading
- A simple introduction to Django Forms
- Multi-step Forms in Django and Django FormWizard-Passing Data between Forms (*)
UI/UX- Using django-widget-tweaks made my life easier
Finally deployment- I chose to go with Linode. Read this blog + comprehensive guides of Linode and you should be good to go.
If you have made it this far into the post, then here are a few bonus pointers:
- How to set IDLE as the default editor of Python scripts Ubuntu
- Add an awesome color theme to IDLE
- How to avoid Django’s admin pages missing error
So well, without much ado, I will end this post now.
If you are wondering, where is the website that I worked on? I used Django to make an online game to simulate a financial environment for the students of London Business School. I am currently working to release this game under a GNU GPL license. If that goes through, I will update this post with the link and would be happy to receive some reviews. In the meanwhile, I hope these links will help someone as much as they helped me.
(*)- In my experience I have not found Django’s FormWizard to be very helpful. After trying it once I stuck to designing and coding in multi-step forms on my own.
One thought on “My Django Journey”
Great tutorial. I think learning a framework that uses the MVC architecture(such as Django, Grails, CakePhP, RoR etc), is immensely useful. There are many frameworks both server side and client side(such as Backbone, Angular etc ) that use this pattern with slight modifications in many languages.
Most applications these days both in academic and non-academic circles tend to be developed over the web platform to leverage the reach of the internet. Using frameworks such as Django will help you setup your application with ease without having to write much boilerplate code. This will allow you to spend most of your time focusing on the application logic.