I have decided to go through the installation of the Django framework on my Windows machine. I am doing the same thing simultaneously on my Linux machine, but am currently only documenting the process on Windows. There are many reasons for this, mainly because doing anything with Python on a Windows machine is categorically more difficult than doing just about anything on a Linux machine. In other words, if you are running Linux, you don't need a tutorial on installing and working with the Django framework. (More or less).
Basically, I just opened up a terminal/console and typed in:
$ pip install Django==1.9.4
Then, for good measure, I typed the following, to make sure everything is working:
$ python -c "import django; print(django.get_version())"
This is all easy to find information on the Django project website. I'm just following the basic tutorials. The real reason I am doing this is not just to show how to install Django. It has more to do with the fact that I want to look at the way Django sets up projects.
In essence, I want to look at the directory structure and basic files of a "skinned down", "bare-bones" Django project. I plan to begin developing apps in Django, and will be doing it on Github, in Github repositories. I really want to get down to the fundamentals of the structure of a Django project. I decided to do this by documenting the entire process from start to finish. So this may just be the first post in a series of posts on the topic.
Now that Django is installed, I go onto the next command. First, I want to make sure that I start my first Django project in the right directory. It doesn't really matter where I stick the project, but I have a special folder called "Refcards" where I am doing most of my development. So I will "cd" into that directory, to create the Django project I will be starting following the tutorial (all on the Django project website, accessible to anyone with a web browser and an Internet connection).
Once I am in the proper directory, I type this in the console:
$ django-admin startproject mysite
This creates/generates the basic "scaffolding" for my Django app.
In essence, this is what my last command generated, this directory structure with these files:
mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py
We will stop there for now and come back to this directory structure and these files, to see what they all mean.
I will quote directly from the Django project website, where I found this basic tutorial to build your first Django app:
These files are:
The outer mysite/ root directory is just a container for your project. Its name doesn’t matter to Django; you can rename it to anything you like.
manage.py: A command-line utility that lets you interact with this Django project in various ways. You can read all the details about manage.py in django-admin and manage.py.
The inner mysite/ directory is the actual Python package for your project. Its name is the Python package name you’ll need to use to import anything inside it (e.g. mysite.urls).
mysite/__init__.py: An empty file that tells Python that this directory should be considered a Python package. (Read more about packages in the official Python docs if you’re a Python beginner.)
mysite/settings.py: Settings/configuration for this Django project. Django settings will tell you all about how settings work.
mysite/urls.py: The URL declarations for this Django project; a “table of contents” of your Django-powered site. You can read more about URLs in URL dispatcher.
mysite/wsgi.py: An entry-point for WSGI-compatible web servers to serve your project. See How to deploy with WSGI for more details.
We will come back to this in a following post. That's it for now. The main idea, for now, is the directory structure and files that Django created for us, what I called the "scaffolding", namely:
mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py
Next we will look at these files and see what they are all about.
- Fn.py: Enjoy Functional Programming in Python
- Functional Programming with Python
- kachayev/fn.py
- Python Tutorial: Lambda Operator, filter, reduce and map
- 2. Built-in Functions — Python 2.7.11rc1 documentation
- Map, Filter, Lambda, and List Comprehensions in Python — MSE 350 vFall 2009 documentation
- Functional Programming HOWTO — Python 2.7.11rc1 documentation
- 6. Functional Programming — Python Practice Book
- Python's Magical Self | Blog | Mobile, Web and Enterprise | Design and Development | Concentric Sky
- class - What is the purpose of self in Python? - Stack Overflow
- Neopythonic: Why explicit self has to stay
- Design and History FAQ — Python 2.7.11rc1 documentation
- The self variable in python explained | Python Tips
- The Story of self Parameter in Python, Demystified
- Python's Magical Self p.2: Rebuild Everything | Blog | Mobile, Web and Enterprise | Design and Development | Concentric Sky
- 32.12. dis — Disassembler for Python bytecode — Python 2.7.11rc1 documentation
- dis – Python Bytecode Disassembler - Python Module of the Week
- Python Bytecode: Fun with dis - Allison Kaptur
- Exploring Python Code Objects « late.am
- Code Objects — Python 2.7.11rc1 documentation
- 28.13. inspect — Inspect live objects — Python 2.7.11rc1 documentation
- 29.2. codeop — Compile Python code — Python 2.7.11rc1 documentation
- Python’s Innards: Code Objects | NIL: .to write(1) ~ help:about
- Python’s Innards: Introduction | NIL: .to write(1) ~ help:about
- Introduction to the Python Interpreter, Part 2: Code Objects - Allison Kaptur
- py.code: higher level python code and introspection objects — py 1.4.30 documentation
- pyDatalog
- logpy/basic.md at master · logpy/logpy
- logpy/differences.md at master · logpy/logpy
- PyLog
- pyswip - PySWIP is a bridge between Python and SWI-Prolog. - Google Project Hosting
- Welcome to Pyke