Django & Django Rest Framework (DRF)
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. DRF is used to build robust and scalable RESTful APIs.
Setup and Integration
Install Django and DRF
pip install django djangorestframeworkCreate a Django Project and App
django-admin startproject ewalletly
cd ewalletly
python manage.py startapp apiDefine Models, Serializers, and Views:
models.py:
from django.db import models
class Wallet(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
balance = models.DecimalField(max_digits=10, decimal_places=2)
currency = models.CharField(max_length=3)
serializers.py:
from rest_framework import serializers
from .models import Wallet
class WalletSerializer(serializers.ModelSerializer):
class Meta:
model = Wallet
fields = '__all__'
views.py
urls.py
Last updated