-
-
Save javiergomezve/355988e2a989f50ca315d6b29168f62a to your computer and use it in GitHub Desktop.
Revisions
-
bradtraversy revised this gist
Sep 4, 2019 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,8 +15,6 @@ pipenv install django ```bash # Create project django-admin startproject pollster cd pollster ``` ```bash -
bradtraversy revised this gist
Sep 4, 2019 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,27 @@ # Django Crash Course Commands ```bash # Install pipenv pip install pipenv ``` ```bash # Create Venv pipenv shell ``` ```bash # Install Django pipenv install django ``` ```bash # Create project django-admin startproject pollster ``` ```bash cd pollster ``` ```bash # Run server on http: 127.0.0.1:8000 (ctrl+c to stop) python manage.py runserver ``` ```bash # Run initial migrations -
bradtraversy created this gist
Sep 4, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ # Django Crash Course Commands ```bash pip install pipenv ``` ```bash pipenv shell ``` ```bash pipenv install django ``` ```bash django-admin startproject pollster ``` ```bash cd pollster ``` ```bash python manage.py runserver # Runs on http://127.0.0.1:8000 # ctrl+c to stop ``` ```bash # Run initial migrations python manage.py migrate ``` ```bash # Create polls app python manage.py startapp polls ``` ```bash # Create polls migrations python manage.py makemigrations polls ``` ```bash # Run migrations python manage.py migrate ``` ```bash # Using the shell python manage.py shell >>> from polls.models import Question, Choice >>> from django.utils import timezone >>> Question.objects.all() >>> q = Question(question_text="What is your favorite Python Framework?", pub_date=timezone.now()) >>> q.save() >>> q.id >>> q.question_text >>> Question.objects.all() >>> Question.objects.filter(id=1) >>> Question.objects.get(pk=1) >>> q = Question.objects.get(pk=1) >>> q.choice_set.all() >>> q.choice_set.create(choice_text='Django', votes=0) >>> q.choice_set.create(choice_text='Flask', votes=0) >>> q.choice_set.create(choice_text='Flask', votes=0) >>> q.choice_set.all() >>> quit() ``` ```bash # Create admin user python manage.py createsuperuser ``` ```bash # Create pages app python manage.py startapp pages ```