Django REST Template
Django Rest Framework Starter 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.
- Open the your railway service variables.
- 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.
- Open the project local_settings file.
- Locate the
CSRF_TRUSTED_ORIGINS
variable and update it with the URLs of your Railway app or custom domain. - 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.
- Open a terminal or command prompt.
- Navigate to the root directory of your project.
- 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! 🚀
Template Content
django-rest-starter
Grey-A/django-rest-starter