Skip to content

neondatabase-labs/guide-neon-django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Running migrations in a Neon-Django project

This application is a simple python API using the Django framework and Neon Postgres database. It returns a list of authors and books written by them. We illustrate how to generate and run schema change migrations.

To build this project from scratch, check out the guide in Neon's documentation.

Set up locally

You will need the following:

  • A Neon account and a project
  • Python 3.8 or higher
  1. Clone this repository:
git clone https://github.com/neondatabase/guide-neon-django
  1. Navigate to the project directory and create a new virtual environment:
cd guide-neon-django
python -m venv myenv
  1. Activate the virtual environment and install the project dependencies:
source myenv/bin/activate
pip install -r requirements.txt
  1. Create a .env file in the root of the project and add the following environment variable with your Neon database URL:
DATABASE_URL=
  1. Run the Django migrations:
python manage.py migrate
  1. Start the Django development server:
python manage.py runserver
  1. Visit http://localhost:8000 in your browser to see the list of authors and books. Or use curl to access the api from the terminal.
# Get the list of authors
curl http://localhost:8000/catalog/authors

# Get books by author with id 1
curl http://localhost:8000/catalog/books/1

About

Example application for Neon with Django

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages