Skip to content

Commit

Permalink
update getting started/installation docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tataraba authored and adamghill committed Jul 26, 2024
1 parent d7dceee commit 76dd220
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
3 changes: 3 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"myst_parser",
"sphinx_design",
"sphinx_copybutton",
"sphinx.ext.napoleon",
"sphinx.ext.autosectionlabel",
Expand All @@ -52,6 +53,8 @@
autosectionlabel_prefix_document = True
autosectionlabel_maxdepth = 3

myst_enable_extensions = ["colon_fence"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

Expand Down
25 changes: 19 additions & 6 deletions docs/source/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ working with Python and Django, below is a list of steps you would need to take
Django `Unicorn`.

```{dropdown} Install the latest version of Python
Django `Unicorn will work with Python 3.8 or greater. But if you don't have Python installed, you will need to
download and install Python to your local machine.
Django `Unicorn` will work with Python 3.8 or greater. But if you don't have Python installed, you will need to
download and install it on your local machine.
You can find the [latest version](https://www.python.org/downloads/) of Python at [Python.org](https://www.python.org).
Expand All @@ -21,9 +21,22 @@ up a Terminal and checking for your version of Python.
```

```{dropdown} Create a virtual environment
does this work?
Before installing Django, you will want to create a new directory for your project. It is also recommended that you create a "virtual environment" where you can install Django, Django Unicorn, and any other dependencies. Once you have created and navigated to the directory, type the following command to create a virtual environment.
```{shell}
python -m venv .venv
`python -m venv .venv`
```
```

```{dropdown} Install Django and start a project
You are now ready to install Django and start your project.
`python -m pip install django`
If you have never created a Django project before, you may want to get acquainted with the library first. There are several resources you could use, though I highly recommend the [Django Girls Tutorial](https://tutorial.djangogirls.org/en/django_start_project/).
At the very least, this will include the `django-admin` command, which will generate a project structure for you.
`django-admin startproject project-name .`
```

Once you have a working Django project, you are ready to [install Django Unicorn](installation.md).
15 changes: 9 additions & 6 deletions docs/source/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@

Install `Unicorn` the same as any other Python package (preferably into a [virtual environment](https://docs.python.org/3/tutorial/venv.html)).

````{tab-set}
```{tab-item} pip
```shell
pip install django-unicorn
```
````{tab-set-code}
```pip
python -m pip install django-unicorn
```
```{tab-item} poetry
```poetry
poetry add django-unicorn
```
````


Expand Down Expand Up @@ -46,6 +45,10 @@ urlpatterns = (

3\. Add `{% load unicorn %}` to the top of the Django HTML template.

```{note}
Generally, your Django HTML templates are typically created in the `myapp/templates/myapp` directory. You will need to add `{% load unicorn %}` at the top of each of the templates utilizing a `Unicorn` component. Alternatively, you can create one "base" template that is extended by other templates, in which case, you would only need to add `{% load unicorn %}` to the top of your base template.
```

4\. Add `{% unicorn_scripts %}` into the Django HTML template and make sure there is a `{% csrf_token %}` in the template as well.

```html
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sphinx-design = { version = "*", optional = true }

[tool.poetry.extras]
minify = ["htmlmin"]
docs = ["Sphinx", "linkify-it-py", "myst-parser", "furo", "sphinx-copybutton", "sphinx-autobuild", "rst2pdf", "sphinx-autoapi", "sphinxext-opengraph", "toml", "sphinx-design"]
docs = ["Sphinx", "linkify-it-py", "myst-parser", "furo", "sphinx-copybutton", "sphinx-autobuild", "rst2pdf", "sphinx-autoapi", "sphinxext-opengraph", "toml", "sphinx-design", "colon_fence"]

[tool.poetry.group.dev.dependencies]
certifi = "^2023.7.22" # needed for GitHub Actions
Expand Down

0 comments on commit 76dd220

Please sign in to comment.