Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge master into django-01 #300

Merged
merged 49 commits into from
Jan 6, 2022
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ea5c2a3
lab-01 v2
austenc-id Dec 14, 2021
9f37a86
resolve conflicts
austenc-id Dec 16, 2021
b053aab
Merge branch 'Austen' into austen-js-01
austenc-id Dec 16, 2021
2f5a844
resolve conflicts
austenc-id Dec 16, 2021
2d36911
ignore secretes.js
austenc-id Dec 22, 2021
ed5a318
Merge branch 'master' into austen-js-01
austenc-id Dec 22, 2021
0ba4d52
Merge branch 'master' of https://github.com/PdxCodeGuild/Class_Raven
colburnlee Dec 23, 2021
4f5cc2b
Merge branch 'master' into austen-js-01
austenc-id Dec 28, 2021
8d22fb8
completed v3
austenc-id Dec 28, 2021
d2fdf22
Merge branch 'master' into austen-js-01
austenc-id Dec 28, 2021
4a79174
update tracker
austenc-id Dec 28, 2021
4958401
add space around ## links
austenc-id Dec 28, 2021
c38e927
Merge branch 'master' of https://github.com/PdxCodeGuild/Class_Raven
colburnlee Dec 29, 2021
969405b
created new branch
ArktheTark Dec 29, 2021
2f56820
app initialization
austenc-id Dec 30, 2021
5b308b1
it sucks but it works
austenc-id Dec 30, 2021
9514f56
move from working directory
austenc-id Dec 31, 2021
f77204a
init flask app
austenc-id Dec 31, 2021
7189da6
commit to switch branch
austenc-id Dec 31, 2021
23a1306
it sucks but it works
austenc-id Dec 31, 2021
ca44f07
adding lab1 as complete
colburnlee Dec 31, 2021
bf5741a
Merge branch 'master' of https://github.com/PdxCodeGuild/Class_Raven
colburnlee Dec 31, 2021
8675f22
Merge branch 'master' into lee-django-lab01
colburnlee Dec 31, 2021
9d72685
Just need to figure out foreign key issue
ArktheTark Jan 2, 2022
88bfdea
Merge branch 'master' into arek-dj-lab1
ArktheTark Jan 4, 2022
15fcfda
saving changes
ArktheTark Jan 4, 2022
fafd17b
removed un needed fileds causing constraints
ArktheTark Jan 4, 2022
0ff06b0
made code simpler with .get_or_create method and fixed issue of priot…
ArktheTark Jan 4, 2022
9dc34c1
Submitting Lab1
ArktheTark Jan 4, 2022
ff40614
update, detail and logout urls, views and templates
perennialAutodidact Jan 5, 2022
d17506f
adjusted styling
perennialAutodidact Jan 5, 2022
849eb49
Merge branch 'master' into austen-js-01
perennialAutodidact Jan 5, 2022
1c0d3b4
Merge pull request #291 from PdxCodeGuild/austen-js-01
perennialAutodidact Jan 5, 2022
20bbdf1
Merge branch 'master' into austen-tracker
perennialAutodidact Jan 5, 2022
16b7c01
Merge pull request #292 from PdxCodeGuild/austen-tracker
perennialAutodidact Jan 5, 2022
d8e774b
Merge branch 'master' into austen-flask-01
perennialAutodidact Jan 5, 2022
ee3ec2e
Merge pull request #293 from PdxCodeGuild/austen-flask-01
perennialAutodidact Jan 5, 2022
166409b
Merge branch 'master' into austen-flask-02
perennialAutodidact Jan 5, 2022
34ae5de
Merge pull request #294 from PdxCodeGuild/austen-flask-02
perennialAutodidact Jan 5, 2022
2eeeee2
added django lab2 and Django resources
perennialAutodidact Jan 5, 2022
c94c29d
added hyphen
perennialAutodidact Jan 5, 2022
1b6525f
Merge branch 'master' into lee-django-lab01
perennialAutodidact Jan 5, 2022
af8b7a2
Merge pull request #295 from PdxCodeGuild/lee-django-lab01
perennialAutodidact Jan 5, 2022
478d0c7
fixed 404 error on port 8000
ArktheTark Jan 5, 2022
b27495a
Merge branch 'master' into arek-dj-lab1
perennialAutodidact Jan 5, 2022
2380823
Merge pull request #296 from PdxCodeGuild/arek-dj-lab1
perennialAutodidact Jan 5, 2022
dc4540b
added venv instructions and screenshots
perennialAutodidact Jan 5, 2022
a11dedb
Merge branch 'master' of github.com:PdxCodeGuild/Class_Raven
perennialAutodidact Jan 5, 2022
4caad2d
fixed spacing
perennialAutodidact Jan 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added venv instructions and screenshots
  • Loading branch information
perennialAutodidact committed Jan 5, 2022
commit dc4540bb665016357b8b0a688e04cf4fcd712cf5
70 changes: 63 additions & 7 deletions 4 Django/docs/Django Quickstart.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,62 @@

# Django Quickstart

## 1) Project Setup
## Create Virtual Environment
These instructions use Python's `venv` module to create a virtual environment. They will differ if using another library.

1. Create a project: `django-admin startproject myproject`, if you get 'command not found', try `python -m django startproject myproject`
2. Move into the project folder: `cd myproject`
- Create a folder for the project

`$ mkdir <PROJ_NAME>`

- Create the environment with `python -m venv <NAME_OF_ENVIRONMENT>`. The name of the environment folder should be in `.gitignore`.

- On Windows machines, this will create a command called `activate`

On Windows machines, this command is stored in `<NAME_OF_ENVIRONMENT>/Scripts/` and on Unix machines in `<NAME_OF_ENVIRONMENT>/bin/`.

- From the directory containing your environment folder, run one of the following commands:
- Windows: `env/Scripts/activate`
- The ability to run scripts might have to be enabled on your machine. If you don't want to do this, a Bash shell can be used instead with the Unix command below.
- Unix: `source env/bin/activate` or `. env/bin/activate`

In most terminals the name of the environment should show up somewhere in on the command line, often in parentheses.

The command `which pip` and `which python` should reveal that those commands are being pulled from your environment's `/lib` folder where Python is installed. Notice that the alias `python` is used instead of `py`.

Bash
<img src='./screenshots/which-pip-python-bash.jpg' width='800'/>


PowerShell
<img src='./screenshots/get-command-powershell.jpg' width='800'/>


## Project Setup

1. Create a project

**Navigate into the folder containing your virtual environment.**

`django-admin startproject <PROJ_NAME> .`

`<PROJ_NAME>` is the name of your project. Note the `.` at the end. This tells Django to put the project in the **current directory**.

If you get 'command not found', try `python -m django startproject <PROJ_NAME> .`

In this example, the project will be called `myproject`.

2. Extend the User model, if desired (optional but recommended).
3. Create the database with built-in models: `python manage.py migrate`
4. Create a superuser: `python manage.py createsuperuser`
5. Set the timezone in your `myproject/settings.py`: (e.g. `TIME_ZONE = 'America/Los_Angeles'`) [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
5. Set the [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) in your `myproject/settings.py`:

(e.g. `TIME_ZONE = 'America/Los_Angeles'`)

## 2) App Setup

1. Create an app: `python manage.py startapp myapp`
1. Create an app: `python manage.py startapp <NAME_OF_APP>`

`<NAME_OF_APP>` will be the actual name of the app. In this example the app will be called `myapp`, but yours will be a word describing what the app is used for (`users`, `posts`, `comments`, etc).
2. Add `'myapp'` to the list of `INSTALLED_APPS`:

**myproject/settings.py**
@@ -36,7 +81,7 @@ def myview(request):
return HttpResponse('hello world!')
```

2. Create a `urls.py` in your app folder with a path to your view:
2. Create a file called `urls.py` in your app folder with a path to your view:

**myapp/urls.py**
```python
@@ -64,6 +109,17 @@ urlpatterns = [

4. Run the server `python manage.py runserver` and in your browser's address bar, type `localhost:8000/myapp/myview/` and you should see `hello world!`

To have this page render at `localhost:8000/`, change the path in both `urls.py` files to a blank string.

```python
# myproject/urls.py
path('', include('myapp.urls'))

# myapp/urls.py
path('', views.myview, name='myview')

```


## 4) Render a Template

@@ -80,7 +136,7 @@ myproject
...
```

2. Inside your `mytemplate.html`, put some text to make sure the template is being served by django.
2. Inside your `mytemplate.html`, put some text to make sure the template is being served by Django.

**myapp/templates/myapp/mytemplate.html**
```html
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.