Skip to content

Instantly share code, notes, and snippets.

@astux7
Last active March 5, 2020 12:59
Show Gist options
  • Save astux7/04b2bf59594e056b6ec80ecd71b020bf to your computer and use it in GitHub Desktop.
Save astux7/04b2bf59594e056b6ec80ecd71b020bf to your computer and use it in GitHub Desktop.
Django cheat sheet

Django shell/interactive console on your laptop

(myvenv) ~/djangogirls$ python manage.py shell close >>> exit()

Activate virtual env myvenv in your laptop

$ myvenv\Scripts\activate Windows $ source myvenv/bin/activate

Starting web service in your laptop

(myvenv) ~/djangogirls$ python manage.py runserver Go to browser http://127.0.0.1:8000/

Stop web service in your laptop

CTRL+C / Ctrl+Break for windows in command line

Create user in your laptop

(myvenv) ~/djangogirls$ python manage.py createsuperuser Windows (myvenv) C:\Users\Name\djangogirls> python manage.py createsuperuser

Github initialize into project (for first time)

$ git init

Project status in Github

$ git status

Github Save changes

$ git add --all . $ git commit -m "My Django Girls app, first commit"

Push code to Github

Add origin only for first time $ git remote add origin https://github.com/<your-github-username>/my-first-blog.git push changes $ git push -u origin master

PythonAnywhere: Update project from github

$ cd <your-pythonanywhere-domain>.pythonanywhere.com $ git pull

PythonAnywhere: Update static files

$ workon <your-pythonanywhere-domain>.pythonanywhere.com (<name>.pythonanywhere.com)$ python manage.py collectstatic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment