taskr DRF API - Live link
This is a backend REST API for the taskr React project. For more information about taskr, please look to the README found in the taskr repository.
Below is a relational database model created at the begining of the project. Since the current scope has been narrowed significantly the number of models and fields present have been altered noticeably.
Test Area | Action | Expected Result | Pass |
---|---|---|---|
Users | Create, read, update, delete | New users can be created via the frontend using All-auth. Users can be created, read, edited or deleted from the Admin panel. | ✓ |
Profiles | Read only | A list of all profiles is readable without authentication from the "/profiles" endpoint. | ✓ |
Profiles | Create, update, delete | Profiles can be created, updated or deleted by the owner from the "/profiles/id" endpoint | ✓ |
Tasks | Read only | A list of all tasks is readable without authentication from the "/tasks" endpoint. | ✓ |
Tasks | Create, update, delete | Tasks can created updated or delete by the owner from the "tasks/id" endpoint. | ✓ |
Task Items | Read only | A list of all task items is readable without authentication from the "/taskitems" endpoint. | ✓ |
Task Items | Create, update, delete | Taskitems can created updated or delete by the owner from the "taskitems/id" endpoint. | ✓ |
-
Clone this repository.
-
In your IDE, connect to your repo, then enter this command in the terminal:
pip install -r requirements.txt
-
Make sure your INSTALLED_APPS in settings.py look like this:
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'cloudinary_storage', 'django.contrib.staticfiles', 'cloudinary', 'rest_framework', 'rest_framework.authtoken', 'dj_rest_auth', 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'dj_rest_auth.registration', 'corsheaders', 'django_filters', 'profiles', 'tasks', ]
-
In you terminal, enter these commands in the terminal:
python manage.py makemigrations python manage.py migrate
-
Git add, commit and push all changes to your repo.
-
Create or log into an account on Heroku.
-
Create a new app on Heroku.
-
Create or log into and account on ElephantSQL.
-
Create a new instance from your dashboard.
-
Go back to your dashboard and copy the database URL from the new instance.
-
In the Settings tab for your Heroku app, create a new Config Var DATABASE_URL and paste the database URL from ElephantSQL.
-
In the Deploy tab on Heroku, go to Deployment method and add your GitHub repository.
-
In the Deploy tab on Heroku, go to Manual deploy and select deploy branch for early deployment.
-
Create or log in to an account on Cloudinary.
-
Copy your API Environment Variable.
-
Go back to your Heroku app Settings and create a new Config Var CLOUDINARY_URL and paste the API environment variable.
-
Add the following variables to your Config Vars:
- ALLOWED_HOST --> Your deployed API URL
- CLIENT_ORIGIN --> Your deployed frontend URL
- SECRET_KEY --> Add a secret key of your choice
- DISABLE_COLLECTSTATIC --> 1
-
Create an env.py in the root directory, add it to .gitignore and add these lines at the top
import os os.environ['SECRET_KEY'] = "YOUR SECRET KEY" os.environ['CLOUDINARY_URL'] = "YOUR CLOUDINARY URL" os.environ['DEV'] = '1' os.environ['CLIENT_ORIGIN'] = "YOUR FRONT END HEROKU APP URL" os.environ.setdefault("DATABASE_URL", "YOUR ELEPHANT SQL DATABASE URL")
-
In settings.py, update the CORS_ALLOWED_ORIGIN_REGEXES variable to match your local server url.
if 'CLIENT_ORIGIN_DEV' in os.environ: extracted_url = re.match(r'^.+-', os.environ.get('CLIENT_ORIGIN_DEV', ''), re.IGNORECASE).group(0) CORS_ALLOWED_ORIGIN_REGEXES = [ rf"{extracted_url}(eu|us)\d+\w\.gitpod\.io$", ]
-
Create a superuser for your site:
python manage.py createsuperuser
-
To run your app locally, enter this command in your terminal: python manage.py runserver
The project is set up to automatically switch between DEBUG: True and False for the development server and deployed site.