https://github.com/orlyohreally/django-rest-api-angular-boilerplate
Boilerplate for Django Rest API Angular project
https://github.com/orlyohreally/django-rest-api-angular-boilerplate
angular-material angular8 django-rest-framework heroku rest-api
Last synced: 2 months ago
JSON representation
Boilerplate for Django Rest API Angular project
- Host: GitHub
- URL: https://github.com/orlyohreally/django-rest-api-angular-boilerplate
- Owner: orlyohreally
- License: mit
- Created: 2019-10-12T17:01:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T10:38:16.000Z (over 3 years ago)
- Last Synced: 2025-03-23T11:31:24.253Z (over 1 year ago)
- Topics: angular-material, angular8, django-rest-framework, heroku, rest-api
- Language: TypeScript
- Homepage: https://angular-django-boilerplate.herokuapp.com
- Size: 1.97 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 29
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Django Rest API Angular Boilerplate
Boilerplate for app with Django Rest API in backend and Angular in frontend.
## Getting Started
These instructions will get you a copy of the project up and running on your local machine for development.
### Installing
Create virtual environment named env
```
python -m venv env
```
Activate created environment
```
# On Windows in command line
env/Scripts/activate
# In VSCode (Windows)
source env/Scripts/activate
```
Clone project
```
cd env
git clone https://github.com/orlyohreally/django-rest-api-angular-boilerplate.git
cd django-rest-api-angular-boilerplate
```
Install dependencies for backend
```
pip install -r restApiApp/requirements.txt
```
Install dependencies for frontend and build the project for backend at the same time
```
cd theme-customization
npm install
```
As a result all npm packages will be installed for angular project and in backend a static folder (restApiApp/static) will be create with built angular project files
Set up db for backend
```
cd ../restApiApp
python manage.py makemigrations
python manage.py migrate
```
Create admin to login into admin page
```
python manage.py createsuperuser
```
## Running the app
```
cd /restApiApp
python manage.py runserver
```
The project will be available at http://127.0.0.1:8000/.
## Deployment
Project has files prepared to deploy on [Heroku](https://www.heroku.com/platform).
## Prepare already existing Angular project for this boilerplate
Replace default Angular project with your own
Update postinstall command in package.json file for the boilerplate
```
"postinstall": "npm install --prefix [folder name of your frontend project]"
```
Update build path depending on Angular version
- .angular-cli.json `"outDir": "../restApiApp/static/blog/"`
- angular.json - `"outputPath": "../restApiApp/static/blog/"`
Add postinstall script to package.json file
```
"postinstall": "ng build --prod --deploy-url /static/blog/ --output-hashing none"
```
Run command to update static files for backend
```
npm run postinstall
```
Update restApiApp/templates/index file so it would load needed scripts for your Angular version. Look at restApiApp/static/blog/index.html for the list of needed scripts.
Assets such as images won't work when angular project has been replaced. In Angular projects all images usually have either external source or they reference assets folder. Django project will store all the static files for frontend in static/blog folder. To solve this issue create environment variable which would store location of static files. This was done in default frontend project of this boildreplate.
## Built With
- [Django REST framework](https://www.django-rest-framework.org/) - framework used for backend
- [Angular](https://angular.io/) - framework used for frontend
## Authors
- **Orly Knop** - [orlyohreally](https://github.com/orlyohreally)
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details