Skip to content

Instantly share code, notes, and snippets.

@krishnaglodha
Created August 27, 2021 13:32
Show Gist options
  • Save krishnaglodha/80549e781f8b2537ae7b8c985e51b038 to your computer and use it in GitHub Desktop.
Save krishnaglodha/80549e781f8b2537ae7b8c985e51b038 to your computer and use it in GitHub Desktop.
saving jsPDF
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class receipt(models.Model):
title = models.CharField(max_length=50)
date_created = models.DateField(auto_now=True)
customer = models.OneToOneField(User, on_delete=models.CASCADE)
pdf = models.FileField(upload_to='receipts/') #pdf will be stored in receipts folder in media folder
def __str__(self):
return self.title
MEDIA_DIR = os.path.join(BASE_DIR, 'media')
MEDIA_ROOT = MEDIA_DIR
MEDIA_URL = '/media/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment