Iteration4 Update Layout of README.md and Installation.md (#53)

* Update README.md Layout

* Update Installation.md
This commit is contained in:
Sirin Puenggun 2023-09-19 23:53:17 +07:00 committed by GitHub
parent c9466b686d
commit a26f16cd88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 68 deletions

View File

@ -82,6 +82,7 @@ or
python manage.py migrate python manage.py migrate
python manage.py loaddata data/users.json python manage.py loaddata data/users.json
python manage.py loaddata data/polls.json python manage.py loaddata data/polls.json
python manage.py loaddata data/vote.json
python manage.py runserver python manage.py runserver
``` ```

View File

@ -4,87 +4,48 @@
An application to conduct online polls and surveys based An application to conduct online polls and surveys based
on the [Django Tutorial project](https://docs.djangoproject.com/en/4.2/intro/tutorial01/), with additional features. on the [Django Tutorial project](https://docs.djangoproject.com/en/4.2/intro/tutorial01/), with additional features.
## Install and Run ## Installation
### Run Setup.py (Recommended)
1. Install [Python 3.11 or later](https://www.python.org/downloads/) Here is **[Install Instruction](Installation.md)**.
2. Clone this repository and Run `setup.py` to install and run the project
## How to Run
### Setup.py Method
Using setup.py method, it will set `.env` for you and runserver automatically with [--insecure](https://docs.djangoproject.com/en/4.2/ref/contrib/staticfiles/#cmdoption-runserver-insecure).
You can set `DEBUG=True` later and then runserver normally to load static files.
Then, connect to [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
### Manual Installation
After follow all of instruction.
- Set Virtual Environment and Use it.
- Install Dependencies.
- Migrate and then Load fixtures.
- Set variable of `.env`
You can run with this command.
**Don't forget to answer the question from `setup.py` to setup the project**
```bash ```bash
git clone https://github.com/Sosokker/ku-polls
cd ku-polls
python setup.py
```
If you want to customize the environment variables, name of environment folder then run this command
```bash
python setup.py -custom
```
or run `setup.ps1` (For Windows User)
----
### Manual Installation (If the above method doesn't work)
1. Install [Python 3.11 or later](https://www.python.org/downloads/)
2. Run these commands to clone and install requirements.txt
```bash
git clone https://github.com/Sosokker/ku-polls
cd ku-polls
pip install -r requirements.txt
```
3. Create file call `.env` in `ku-polls` directory and add this line
```bash
SECRET_KEY=your_secret_key
```
You can generate your own `your_secret_key` by this command
```bash
python manage.py shell -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
```
or
- [Django Secret Key Generator #1](https://djecrety.ir/)
- [Django Secret Key Generator #2](https://miniwebtool.com/django-secret-key-generator/)
**Don't forget to change `your_secret_key` to your secret key (without quote)**
**You can look at `sample.env` for more information and others environment variables to set.**
4. Run these commands
```bash
python manage.py migrate
python manage.py loaddata data/users.json
python manage.py loaddata data/polls.json
python manage.py runserver python manage.py runserver
``` ```
***NOTE*** Anyway, if you set `DEBUG = False` then django production server will not load static files for you.
You need to set `DEBUG = True` or run this command.
By Default `DEBUG=False` and Django will not load Static files for you so if you want to apply CSS run this.
```bash ```bash
python manage.py runserver --insecure python manage.py runserver --insecure
``` ```
or set `DEBUG=True`
or do the [collectstatic](https://docs.djangoproject.com/en/4.2/ref/contrib/staticfiles/)
Then connect to [http://127.0.0.1:8000/](http://127.0.0.1:8000/) or [localhost:8000/](localhost:8000/) Then, connect to [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
---- ---
**Recommend** **NOTE** : If you have problems with port you can use runserver and specific your own port.
You can create virtual environment by using this command before install requirements.txt
1. Install virtualenv via pip
For example, If you run this command then you need to connect to [http://127.0.0.1:7000/](http://127.0.0.1:7000/)
```bash ```bash
python -m pip install --user virtualenv python manage.py runserver 7000
```
2. Run these commands
```bash
python -m virtualenv .venv
```
3. Use `virtual environment`
```bash
.venv\Scripts\activate
``` ```
## Demo Superuser ## Demo Superuser
@ -112,5 +73,6 @@ All project documents are in the [Project Wiki](https://github.com/Sosokker/ku-p
- [Iteration1](https://github.com/Sosokker/ku-polls/wiki/Iteration-1-Plan) - [Iteration1](https://github.com/Sosokker/ku-polls/wiki/Iteration-1-Plan)
- [Iteration2](https://github.com/Sosokker/ku-polls/wiki/Iteration-2-Plan) - [Iteration2](https://github.com/Sosokker/ku-polls/wiki/Iteration-2-Plan)
- [Iteration3](https://github.com/Sosokker/ku-polls/wiki/Iteration-3-Plan) - [Iteration3](https://github.com/Sosokker/ku-polls/wiki/Iteration-3-Plan)
- [Iteration4](https://github.com/Sosokker/ku-polls/wiki/Iteration-4-Plan)
[django-tutorial](https://docs.djangoproject.com/en/4.2/intro/tutorial01/) [Django-Tutorial](https://docs.djangoproject.com/en/4.2/intro/tutorial01/)