As a developer, I can set up PyCharm so that I can create, edit, and test my app locally.
Acceptance Criteria
PyCharm project created
PyCharm project linked to GitHub
Django installed and app created
Necessary environment variables set
Tasks
[x] File > Open > select local GitHub directory
[x] In PyCharm's Terminal, install and extract the necessary libraries
pip3 install django==4.2.1
pip3 install gunicorn
pip3 freeze local > requirements.txt
[x] In PyCharm's Terminal, create the Django project and app
django-admin startproject ci_project4 .
python3 manage.py startapp lego_collection
[x] Update the settings.py file with the following (according to the Hello Django > Deployment chapter of Code Institute's Full Stack Frameworks (FST) (Deprecated) module)
Add import os to the file imports
Add import dj_database_url to the file imports
Under the file imports, add development = os.environ.get('DEVELOPMENT', False)
Change the SECRET_KEY line to SECRET_KEY = os.environ.get('SECRET_KEY', '')
Change DEBUG = True to DEBUG = development
Add the app name into the INSTALLED_APPS section
In the ALLOWED_HOSTS section, write an if statement to check the development status
if development:ALLOWED_HOSTS = ['127.0.0.1']else:ALLOWED_HOSTS = [os.environ.get('HEROKU_HOSTNAME')]
[x] Update the other necessary project and app files
Import HttpResponse from django.http in views.py
from django.http import HttpResponse
Create a basic Hello World function in views.py to test the setup
As a developer, I can set up PyCharm so that I can create, edit, and test my app locally.
Acceptance Criteria
Tasks
pip3 install django==4.2.1
pip3 install gunicorn
pip3 freeze local > requirements.txt
django-admin startproject ci_project4 .
python3 manage.py startapp lego_collection
import os
to the file importsimport dj_database_url
to the file importsdevelopment = os.environ.get('DEVELOPMENT', False)
SECRET_KEY = os.environ.get('SECRET_KEY', '')
DEBUG = True
toDEBUG = development
if development:
ALLOWED_HOSTS = ['127.0.0.1']
else:
ALLOWED_HOSTS = [os.environ.get('HEROKU_HOSTNAME')]
from django.http import HttpResponse
def hello_world(request):
return HttpResponse('Hello, World!')
from lego_collection.views import hello_world
path('', hello_world, name='hello world')
web: gunicorn codestar.wsgi
to the file and savepython3 manage.py runserver
Linked EPIC
5