Django CRUD App Lab Setup
Setup
Open your Terminal application and navigate to your ~/code/ga/lessons directory:
cd ~/code/ga/lessons
Create a new repository on GitHub named django-crud-app-lab.
git clone https://github.com/<your-username>/django-crud-app-lab.git
🚨 Do not copy the above command. It will not work. Your GitHub username will replace
(including the < and >) in the URL above.
Next, cd into your new cloned directory, django-crud-app-lab:
cd django-crud-app-lab
Initialize a new virtual environment inside your project directory and install Django:
pipenv install django
This command will create a new Pipfile and Pipfile.lock in your project directory, specifying Django as a dependency.
Activate the virtual environment:
pipenv shell
đź§ With your virtual environment activated you should see a slight change in your terminal, with the virtual environment folder name listed to the left of your command line prompt.
Name your Project
Before you begin your lab you’ll need to choose a name for your project, If you already know the model you’ll use, consider calling it something related to that resource. Ex: finchcollector, nationalparks, bloghub
Here are some Django guidelines and naming conventions:
- The project name should reflect its functionality or purpose.
- Avoid naming projects after Python or Django internal components, like
djangoortest. Ex: djangoproject, djangomusic, testproject - Python doesn’t allow hyphens in module names because they are interpreted as minus signs. Use underscores if needed, although single-word names are preferred for simplicity.
- It’s a Python convention to name packages all in lowercase to avoid issues with case-sensitive filesystems.
Got a name? Great.
Start a new Django project within your virtual environment:
django-admin startproject <mycoolapp>
Once the project is created, cd into the new <mycoolapp> directory:
cd <mycoolapp>
Open the project’s folder in your code editor:
code .
To deactivate the virtual environment when you’re done, type:
exit