Skip to content

rajaprerak/user_activities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django based application to serve API of user activities

https://user-activity-ftl.herokuapp.com/

Website shields.io Ask Me Anything ! License

Table of Contents 📚

Installation 📦

pip install -r requirements.txt

Clone

git clone https://github.com/rajaprerak/user_activities.git

Run server locally

$ 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
Porfolio Website

License 📜

License

Languages