All Templates / Starters

Django REST Template

Django REST Template

Django Rest Framework Starter Template

Deploy Django REST Template

Postgres

railwayapp-templates/postgres-ssl:latest

Just deployed

/var/lib/postgresql/data

django-rest-starter

Grey-A/django-rest-starter

Just deployed

Getting Started with Django REST + Postgres Starter

Welcome to the Django REST + Postgres Starter! This guide will walk you through the steps to get started with the project after deploying the service. Before you begin, make sure you have deployed the template.

Step 1: Set the SECRET_KEY Variable

The SECRET_KEY is a critical security parameter used by Django to secure cryptographic signatures and session data. To enhance the security of your project, it's essential to change the default SECRET_KEY to a unique and secure value.

  1. Open the your railway service variables.
  2. Locate the SECRET_KEY variable and update it with your desired value.

Example:

SECRET_KEY = 'your_secret_key_here'

Step 2: Update CSRF_TRUSTED_ORIGINS

Django uses Cross-Site Request Forgery (CSRF) protection to prevent malicious attacks. When deploying the project to Railway or a custom domain, you need to specify the trusted origins that are allowed to send POST, PUT, PATCH, or DELETE requests.

  1. Open the project local_settings file.
  2. Locate the CSRF_TRUSTED_ORIGINS variable and update it with the URLs of your Railway app or custom domain.
  3. Dont forget to also do the same at your production_settings.py

Example:

CSRF_TRUSTED_ORIGINS = ['your_railway_app_url_here', 'your_custom_domain_url_here']

Step 3: Run the Development Server

With the SECRET_KEY and CSRF_TRUSTED_ORIGINS updated, you can now run the development server to test your Django REST + Postgres Starter locally.

  1. Open a terminal or command prompt.
  2. Navigate to the root directory of your project.
  3. Run the following command:
python manage.py runserver

The development server should start, and you can access your project at http://127.0.0.1:8000/.

Step 4: Start Building Your API

With the project set up and the development server running, you are ready to start building your API. The Django REST + Postgres Starter provides a solid foundation to create powerful RESTful APIs. You can define your models, serializers, views, and URLs to implement your desired functionality.

Refer to Django REST Framework documentation (https://www.django-rest-framework.org/) for detailed information on how to create APIs, handle authentication, permissions, and much more.

Conclusion

Congratulations! You have successfully set up the Django REST + Postgres Starter and made the necessary changes to enhance the security and compatibility with Railway or a custom domain. Now you can begin building your API and start your exciting development journey with Django and Postgres.

Happy coding! 🚀


Deploy Now

Details

GrandGale Technologies

Created on Aug 5, 2023

302 total projects

113 active projects

53% success on recent deploys

Python

Starters



More templates in this category

View Template
mellow-vue

mellow-vue

A full-stack Vue app with The Boring JavaScript Stack.


My Workspace

View Template
.NET8 Web API

.NET8 Web API

A basic ASP.NET Core Web API template (.NET 8)


Dango

View Template
Django Monolith

Django Monolith

A Django app connected to a Postgres database with Celery and Celery Beat.


Odogwu Machalla's Projects