Skip to content

Instantly share code, notes, and snippets.

@CITGuru
Last active June 1, 2018 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CITGuru/024ba519f54cb6aa00a3fed3f9e98bbb to your computer and use it in GitHub Desktop.
Save CITGuru/024ba519f54cb6aa00a3fed3f9e98bbb to your computer and use it in GitHub Desktop.
Imgbin models structure
from django.db import models
from django.contrib.auth.models import User
from cloudinary.models import CloudinaryField
class Tags(models.Model):
name = models.CharField(max_length=225)
slug = models.SlugField()
def __str__(self):
return self.name
class Bin(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
title = models.CharField(max_length=225)
description = models.CharField(max_length=145, blank=True, null=True)
image = CloudinaryField("image")
tags = models.ManyToManyField(Tags, related_name="tags")
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
def __str__(self):
return "{}".format(self.title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment