Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rajaprerak/user_activities
Django based application to serve API
https://github.com/rajaprerak/user_activities
api api-rest django django-application django-rest-framework heroku python
Last synced: 10 days ago
JSON representation
Django based application to serve API
- Host: GitHub
- URL: https://github.com/rajaprerak/user_activities
- Owner: rajaprerak
- Created: 2020-07-29T13:32:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T11:17:54.000Z (almost 2 years ago)
- Last Synced: 2023-03-05T13:31:14.193Z (over 1 year ago)
- Topics: api, api-rest, django, django-application, django-rest-framework, heroku, python
- Language: Python
- Homepage: https://user-activity-ftl.herokuapp.com
- Size: 46.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Django based application to serve API of user activities
> https://user-activity-ftl.herokuapp.com/[![Website shields.io](https://img.shields.io/badge/website-up-yellow)](http://rajaprerak.github.io/)
[![Ask Me Anything !](https://img.shields.io/badge/ask%20me-linkedin-1abc9c.svg)](https://www.linkedin.com/in/rajaprerak/)
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://badges.mit-license.org)## Table of Contents ๐
- [Installation](#installation)
- [File Hierarchy](#filehierarchy)
- [Populate Database](#populatedatabase)
- [Features](#features)
- [Deployment](#deployment)
- [Migration(Optional)](#migration)
- [Developer](#developer)
- [License](#license)## Installation ๐ฆ
>pip install -r requirements.txt
#### Clone
>git clone https://github.com/rajaprerak/user_activities.git
#### Run server locally
```shell
$ python manage.py runserver
```
> Go to localhost:8000## FileHierarchy ๐
* **manage.py** - Run code
* **requirements.txt** - Required package information
* **Procfile** - Contains commands that are executed in heorku on startup.
* **db.sqlite3** - Our database file
* **user_activities** folder
* **settings.py** - It holds configuration values that your webapp needs.
* **urls.py** - URL mapping file
* **wsgi.py** - Used both by Djangoโs development server and in production WSGI deployments
* **activity** folder (app that we created inside our project)
* **models.py** - Contains class that represent table in our database.
* **admin.py** - Register the models that we created.
* **serializers.py** - Convert query datatypes to python datatype that can be easily rendered to json or xml content type.
* **urls.py** - URL mapper for our app views.
* **views.py** - Takes web request and returns a web response.
* **management/commands/** folder
* **populate.py** - File contains custom management commands to populate the database with dummy data.
* Basic information for creating django project
* To create project
>django-admin starproject user_activities
* To create app within project
>python manage.py startapp activity
* To create your own superuser to handle admin functionality
>python manage.py createsuperuser
* Create migration for all application installed in your project
>python manage.py makemigrations
* Apply migrations to the database
>python manage.py migrate
* Run code
>python manage.py runserver## PopulateDatabase ๐ฎ
* I have made use of Django custom management command to populate our database with some dummy data.
* The file is present in app folder(activity/management/commands/populate.py)
* To populate the database, run following command.
>python manage.py populate
## Features ๐
โก๏ธ **GET** request to get user activities in json format.\
โก๏ธ **POST** request to add users to the list.## Deployment ๐
* The application is deployed using heroku.
* Heroku reads from **Procfile** to run our application.
* All the required packages are present in **requirements.txt** file.
> https://user-activity-ftl.herokuapp.com/## Migration ๐
* Migration is django's way of propogating the changes you make to your models(updating database, creating new table, adding new fields).
* Suppose you want to update the model or change some of the fields, you need to apply migration after doing the change. You are required to run following commands if you change code in **models.py**
>python manage.py makemigrations
>python manage.py migrate
>python manage.py runserver
>Go to localhost:8000## Developer โจ
| **Prerak Raja** |
| :---: |
| [![Prerak Raja](https://github.com/rajaprerak.png?size=100)](https://rajaprerak.github.io)
| Porfolio Website |## License ๐
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://badges.mit-license.org)
- **[MIT license](http://opensource.org/licenses/mit-license.php)**