Boilerplate: Create A New Django Site/Project
Introduction
These are the basic Mac commands to create a new Django site (aka project). I expect the commands should work on most linux installs too, but haven't had a chance to check it. I'll do that and add a Windows version as time allows. There's also more about the process in the Boilerplate Details section further below.
Boilerplate Steps
-
Specify the name for your site/project directory and intial module name (which I default to site_files for consistency):
-
Run these Mac commands
The last step will be to create a superuser accont which you'll need to fill out some details for. I use "admin" for the username, keep the email blank, and use a simple password when I'm making test boilerplate sites, but you can use whatever you want.
terminal commands -
Start the server
terminal commands -
Verify the default home page shows up
link
Next Steps
That's it for the site creation. If you're setting up for a new boilerplate example, the next step is:
Boilerplate: Add Basic Template And Static File Handling In Django
Boilerplate Details
-
The commands work on a Mac. They migth work on any given linux install. I'll make a Windows version when I have the resources to work on it.
-
The process creates a directory with your specified name. It then creates a django site/project inside it using the Module Name you defined. I go with "site_files" for consistency among my sites. Most instructions I see use a more specific name, but I haven't been able to determine if there's a reason to not stick with a generic one.
-
The process creates a Python virtual environment and activates it. Django is then installed inside it to avoid messing with the system install of Python.
-
The process creates a git repo and
.gitignore file that ignore the.env file,venv directory,db.sqlite3 database, and some other python/django related files that don't need to be stored. -
The intiail code is committed to the git repo and a new branch named dev is created and checked out to work on.
-
All the initial database migrations are run to set up the database.
-
The
createsuperuser
command is run at the end to prompt for super user account details.