Django-Next contains a backend Django app that features restful api endpoints.
It also contains a Next.js app for the frontend which fetches data from the api.
- 🛢 Backend API endpoints using Django Rest Framework
- ✅ Initial data loaded with one command through fixtures
- To checkout the documentation, click the fixtures link and find
loaddata
in the contents sidebar. - The mock data was created using mockaroo
- To checkout the documentation, click the fixtures link and find
- 🎨 Sleek frontend styling with Material-UI
- 🎬 Basic transitions and animations with Framer Motion
git clone https://github.com/Brlaney/django-next.git
cd dj-api
# Activate a virtual environment
virtualenv ll_env
ll_env\scripts\activate.bat
# Download necessary packages
py -m pip install Django djangorestframework django-cors-headers
# Make database migrations
py manage.py makemigrations
py manage.py migrate
# Create admin superuser
py manage.py createsuperuser
..<input a username, email, and password>
# Populate your database with initial data from the dj-api/api/fixtures directory
py manage.py loaddata fixture
The terminal should output: Installed 30 object(s) from 1 fixture(s)
.
If an error message appears then run py manage.py migrate --run-syncdb
and py manage.py migrate
first and then py manage.py loaddata fixture
should work.
py manage.py runserver
Now navigate to http://127.0.0.1:8000/api and confirm the initial data was loaded properly.
Open up another terminal (tab or window) and keep your backend running.
# In the new terminal cd into the next-app directory
cd next-app
# Install all dependencies
yarn install
# or if using npm
npm install
# Create a .env.local file with backend api endpoint inside
echo > .env.local
# In your text editor put the following line in your .env.local file
DJANGO_API=http://localhost:8000/api
# Start your frontend app
yarn dev
# or
npm run dev
Opening http://localhost:3000/ in your browser should now show your frontend Next.js app.
- Email: brlaney@outlook.com
- Twitter: brendan_webdev
- Instagram: brlaney94
MIT License
Copyright (c) 2021 Brendan Laney - Django-Next author.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
I would love your feedback on my project - please feel free to make a pull request or submit an issue if you find any. Thanks for checking out my project!