django app development memo

I learned django app development a little bit.
Compared with rails, django lacks considering development convironments.
When you want to prepare separate files for development, and production, you have to create your settings yourself.
And you have to create database in your terminal, of course that’s why you need to prepare local db environments as well.
In that way, I felt django cost higher to learn than rails.

These are what I think are important steps.

1. split

On default, django makes for you. But it is meant to be used in development environment.
When you deploy your app to production(like heroku, linode, amazon ec2,etc.), you might need to disable Debug mode, and switch database to production. On Rails,

$ ENV=production your action ....

it is enough. but in django, you need to tweak import.
In, you can add the following at the end of

    from #yourappname.settings_local import *
except ImportError:

This overrides setting entities. if you uses version control, it is better to exclude or ignore
You can name this file as you like. whatever you set for developemnt, it never affects deploment environments.

2. prepare templates

Django template system is not intuitive.

First, you have to specify template directory paths in These are absolute paths.
Second, you specify template file in your These are relative paths from paths you wrote in the first step.

The important point is that template dir is not associated with views. So you can put template dirs outside app, anywhere in your file system. It would be confusing for rails users.

3. python3

This is my preference :D. I know ecosystem in pytyon3 is much smaller than pytyon2.
But in the future, python2 will be deprecated. Obviously, pytyon3 dev is getting active in these days

So I recommend you to invest your time in learning pytyon3 in advance.

Now that Django supports pytyon3 officially, you can go for python3 whenever you want.

Leave a Reply

Your email address will not be published. Required fields are marked *