Skip to content

Commit

Permalink
Mayank (#19)
Browse files Browse the repository at this point in the history
* added fork instructions and started defining directory structure

* Implemented basic stuff (#1)

* move essentials into src

* update missing parts

* updated readme and makefile (#10)

* updated readme and makefile

* added .pyc files in gitignore

* initialising django rest framework

* predeciding whether to make react as another django app or as a stand alone SPA

* frontend and baackend running
  • Loading branch information
fireballpoint1 authored Jun 26, 2020
1 parent d061c7a commit 01b1e2f
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# created by virtualenv automatically
*
*.pyc
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,54 @@ git pull upstream <branch-name>
## Instructions to run
- TODO

## Instructions to run
### Activate virtual environment
```bash
cd src
source venv/bin/activate
```

### Generate requirements file
```
pip3 freeze > requirements
```
### Activate server
```bash
python3 manage.py runserver
```

### Backend - Django
#### Migrations
Every time there is a change in the models, they need to be reflected to the database by running migrations.
```bash
python manage.py makemigrations backend
python manage.py migrate
```
#### Enabling/Disabling browseable API
Uncomment/Comment (respectively) the following lines in `django_react/settings.py`
```python
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
)
}
```

### Testing
Make sure you're in the correct directory:
```bash
cd src
```

Running Tests:
```bash
coverage run --source='.' manage.py test
```
and generate the report:
```bash
coverage html
```
You'll see exactly what to test. If you prefer seeing the report on the command line run:
```bash
coverage report
```
3 changes: 2 additions & 1 deletion src/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Source
Will contain the backend and front end pieces
Will contain the backend and front end pieces

Binary file added src/db.sqlite3
Binary file not shown.
19 changes: 19 additions & 0 deletions src/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
venv: venv/bin/activate

install1: requirements.txt
( \
source path/to/virtualenv/bin/activate; \
pip3 install -r requirements.txt; \
)

install: requirements.txt
#test -d venv || virtualenv venv
. ./venv/bin/activate; pip3 install -Ur requirements.txt
touch venv/bin/activate

test: venv
. venv/bin/activate; nosetests ./

clean:
rm -rf venv
find -iname "*.pyc" -delete
21 changes: 21 additions & 0 deletions src/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_react.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
7 changes: 7 additions & 0 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
asgiref==3.2.10
coverage==5.1
Django==3.0.7
djangorestframework==3.11.0
pkg-resources==0.0.0
pytz==2020.1
sqlparse==0.3.1

0 comments on commit 01b1e2f

Please sign in to comment.