Coder Social home page Coder Social logo

django-mediacat's Introduction

django-mediacat - The best way to store pictures of cats

Mediacat is an opinionated Media Library for Django, lovingly extracted from the codebase of onefinestay.

It's not quite ready yet, but here's a screenshot of the current state of play:

Mediacat Screenshot

Data Model

Mediacat is built around around two major models, Images and Crops. An Image represents an original uploaded file, along with some metadata, and a Crop represents a rectangular subsection of a specific image. Crops are also constrained to being one of a number of developer-defined ratios.

A crop can be attached to the model through the use of a MediaField. A MediaField looks like a regular Django model field, with some extra magic that happens in the background:

from django.db import models
from mediacat.fields import MediaField

class Foo(models.Model):
    ...
    field_name = MediaField('PORTRAIT', width=2000)

Rather than using a foreign key as a column in the parent model's database, Mediacat instead has an ImageCropApplication model which stores the relationship instead. The reasoning behind this unconventional apporach is to simplify the database joins required to render a list of Django models that may have multiple MediaFields.

Mediacat also provides the facade of a category structure, in reality the categories are defined as a hierarchy of your application's models, and images are associated with the models via an intermediate ImageAssocation model. This is the second unconventional design decision, made because it let us avoid the problem of having to keep a hierarchy of categories in sync with our business models.

django-mediacat's People

Contributors

andrewingram avatar stuartleigh avatar gitter-badger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.