Skip to content

A full-stack web app that uses NextJs for the frontend & Django for the backend.

Notifications You must be signed in to change notification settings

Brlaney/django-next

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Django-Next

A basic, full-stack web application

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.

Table Of Contents

Features

  • 🛢 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
  • 🎨 Sleek frontend styling with Material-UI
  • 🎬 Basic transitions and animations with Framer Motion

Quick Start

1. Clone repository

git clone https://github.com/Brlaney/django-next.git

2. Setup the backend Dj-api

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.

3. Confirm your backend is functioning

py manage.py runserver

Now navigate to https://127.0.0.1:8000/api and confirm the initial data was loaded properly.

screenshot-of-api


4. Setup the frontend next-app

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 https://localhost:3000/ in your browser should now show your frontend Next.js app.

Connect with me

License

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.

Contributions and issues

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!