As this is the backend, no one other than admins and staff would interact with the backend site in the admin area. The admin area is the default generic template that comes with Django, with the site title changed to give it a more personal touch toward the Cotal brand.
In the admin area, all content models (user and profile) have some interactivity to satisfy the user stories created for the backend.
The data model built for this project laid the foundation for how the app should work, and from this point forward, all that is needed is to get hacking.
The above image has since changed a bit but still applies today. Models are crafted to satisfy the features offered on the frontend, with some that are working technically but are not fully implemented on the frontend, like follow and connect. The frontend does get the data, but does not post it. Due to the limited time I had, I prioritized the overall functionality of the backend and frontend. Tagging posts works perfectly, but it requires more work to be fully optimized. Currently, if a user wants to retain the existing tags, the user must add the existing tags to the PUT request with the other data.
The minimum this app should include:
- The ability to handle API HTTP errors gracefully.
- The ability to handle API Errors gracefully.
- The ability for admin to be able to delete user content.
- All database models specified in frontend project.
The desired features this would want:
- API scalability effectivly.
- API flexibility to be able to easily expand upon.
- Email capability.
App Goal:
-
Cotal-drf is the backend for Cotal, aiming to fulfill and satisfy all requests about the users, posts, likes, follows, connections between users, and more.
Agile Development:
-
The agile development methodology was used for this project, with planning, development, and delivery in small sprints. There were two epics in total, spaced out over 15 days, with:
-
epic 1 - 100 percent of total time
-
epic 2 - Added to backlog
I assigned all epics labels, and I prioritized all sprints according to their labeling.
- must-have. - should have. - could have. - nice to have.
-
The Kanban board used was created using Github projects and can be seen here
- Git was used for version control by utilizing the VSCode terminal to commit to Git and Push to GitHub.
- GitHub is used to store the project's code after being pushed from Git.
- Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design.
- Django REST framework is a powerful and flexible toolkit for building Web APIs.
- Image & Video API Trusted by 1.3M+ Developers. Cut the complexity involved in optimizing, editing, and managing media for your app, e-commerce store, marketplace, or website.
- The Python Imaging Library adds image processing capabilities to your Python interpreter.
- This simple Django utility allows you to utilize the 12factor-inspired DATABASE_URL environment variable to configure your Django application.
- This simple Django utility allows you to utilize the 12factor-inspired DATABASE_URL environment variable to configure your Django application.
- REST implementation of Django authentication system. djoser library provides a set of Django Rest Framework views to handle basic actions such as registration, login, logout, password reset and account activation. It works with custom user model.
- This package provides routers and fields to create nested resources in the Django Rest Framework.
- A simple but powerful UI & UX sketching app for iPad.
- DataGrip is a database IDE tailored to suit professional SQL developers' specific needs.
- Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.
-
Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the Python world. Windows is a first-class citizen, in our world.
-
It automatically creates and manages a virtualenv for your projects, as well as adds/removes packages from your Pipfile as you install/uninstall packages. It also generates the ever-important Pipfile.lock, which is used to produce deterministic builds.
-
Render is a unified cloud to build and run all your apps and websites with free TLS certificates, a global CDN, DDoS protection, private networks, and auto deploys from Git.
API_ENDPOINT: rest/
Profiles:
/profiles/
Profile object:
/profiles/<username>/
Linktrees:
/profiles/<username>/linktree/
Socials:
/profiles/<username>/socials/
Social object:
/profiles/<username>/socials/<id>/
model = portfolios/awards/certificates or creatives
model:
/profiles/<username>/<model>/
model object:
/profiles/<username>/<model>/<slug>/
Posts:
/posts/
Profile posts:
/posts/profiles/<username>/posts/
Profile post object:
/posts/profiles/<username>/posts/<slug>/
For post comment:
/posts/profiles/<username>/posts/<slug>/comments/
Comment object:
/posts/profiles/<username>/posts/<slug>/comments/<id>/
For follow:
/profiles/<username>/follow/
Connects:
For connecter:
/profiles/<username>/connecter/
For connecting:
/profiles/<username>/connecting/
I have grown fond of eliminating bugs found in my code as I intentionally try to provoke and find them. Currently, no known bugs or errors exist.
A lot of testing took place with the help of DataGrip.
Python code was checked against the PEP8 VSCode extension, and errors and warnings were fixed during development.
How to fork this repository:
- Log in to GitHub and navigate to this repository.
- You'll see a button called "Fork" on the top right side of the page. Click the button to create a copy of this repository on your own GitHub account.
How to clone this project:
- Under the repository’s name, click on the Code button.
- In the HTTPS tap, click on the clipboard icon to copy the given URL.
- In your IDE of choice, open git bash.
- Change the current working directory to where you want the cloned directory to be.
- Type git clone, paste the URL copied from GitHub - https://github.com/MTraveller/cotal-drf.git.
- Press enter, and you are done.
This project was chosen to be hosted on render.com; if you choose to host it elsewhere, please consult the documentation of that host. If you want to host on render, follow the steps below.
First, create a folder anywhere you want to work with this repository. Inside this folder, follow the steps below.
Assuming you have a Github account; if not, create one and proceed with the steps below. If you do not have a terminal app, you can see what options are available for your operating system.
We will be using a terminal window to continue with the steps below. I use: Hyper
Do:
means to input the highlighted
command into the terminal, followed by Enter
on the keyboard.
- Prerequisite
- Do:
git clone https://github.com/MTraveller/cotal-drf.git
"Press Enter" - CD into the cloned folder
cotal-drf
.- Find the folder:
- On linux: Do:
find . -name "cotal-drf" -type d
"Press Enter" - On windows Do:
dir "cotal-drf" /AD /s
"Press Enter"- In root - e.g. C:/
- read more here
- On linux: Do:
- Find the folder:
- Install GitHub cli if you don't have it.
- Do:
gh auth login
"Press Enter"- Follow the instructions to connect the Github CLI to your Github account.
- Do:
- Do:
gh repo create
"Press Enter"-
Choose:
- Create a new repository from scratch
- No license
- No readme
- Do not clone
- Make public
-
Assuming you're in the working folder, continue reading.
- Do:
rm -rf .git
"Press Enter" - Do:
git init
"Press Enter" - Do:
git remote add origin https://github.com/<your-user-name>/<created-repo-name>.git
"Press Enter"- The repo you just created!
- Do:
git add .
"Press Enter" - Do:
git commit -m "Initial commit"
"Press Enter" - Do:
git branch -M main
"Press Enter" - Do:
git push -u origin main
"Press Enter" - Wait until files are uploaded; this usually takes a couple seconds.
- This project is now in your newly created repo.
-
To push to GitHub, you must use the command from step 7.
-
to push using only git push:
- Do:
git branch --set-upstream-to=origin/main main
"Press Enter"
- Do:
-
- Do:
-
- Do:
- Development:
- Find and rename
cotal_drf_api/settings/dev_file_rename_to_just_dev.py
to dev.py- dev.py is automatically ignored by git
- Insert a Django secret key obtained from the provided website.
- Add your cloudinary api
cloudinary://my_key:my_secret@my_cloud_name
.
- Open a new terminal window and navigate to the cloned project folder.
- I recommend continuing with a virtual environment; for more information, see:
- pipenv
- First install pipenv.
- Set up a Pipenv environment:
- Do:
pipenv shell
"Press Enter"
- Do:
- Just remember to set the vscode Python interpreter to the virtual environment used if vscode is used. For other programs, you'll have to see their documents.
- I recommend continuing with a virtual environment; for more information, see:
- Depending on your operating system or if pipenv is used:
- on windows use
python
- on linux based systems use
python3
- if pipenv is used, use
python
- on windows use
- Do:
python
orpython3
install -r requirements.txt
"Press Enter" or if pipenv is used: Dopipenv sync
- Do:
python
orpython3
manage.py runserver 127.0.0.1:3000
"Press Enter" - You should now be able to open the project at 127.0.0.1:3000.
- Find and rename
- Production:
- Sign-in or signup for a Render.com account.
- Open
config/.env
file, copy all variables, and change accordingly in a new text document "keep it open". - Go to New Env Group and create a new environment group for this project.
- Scroll down to "Secret Files" press "Add Secret":
- in key input add:
- .env
- press the eye and add:
- all variables from the open text document you made in step 2
- press save.
- in key input add:
- Open
render.yaml
and make any changes to reflect your project, fromGroup(env group name from step 3), names, region etc.- find available regions here
- In the same terminal window, or open a new one if closed, and cd to the project folder.
- Do:
git add .
"Press Enter" - Do:
git commit -m "Your Message"
"Press Enter" - Do:
git push -u origin main
orgit push
if upstream is set "Press Enter" - Go to render to add a new blueprint
- Connect your github account and give render access to the repo.
- Connect repo and choose service name and press apply.
- The project should be live in a couple minutes.
- Press on "Dashboard" in the navigation bar to see the creation process.
No code within this project is a copy unless specified explicitly in the source code. The sources used above provided guidance throughout the development.
This project is part of the "Full Stack Software Developer Diploma" at Code Institute.
MT 2022.