You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
938 B
29 lines
938 B
# encoding: utf-8
|
|
from django.db import models
|
|
|
|
|
|
class Picture(models.Model):
|
|
"""This is a small demo using just two fields. The slug field is really not
|
|
necessary, but makes the code simpler. ImageField depends on PIL or
|
|
pillow (where Pillow is easily installable in a virtualenv. If you have
|
|
problems installing pillow, use a more generic FileField instead.
|
|
|
|
"""
|
|
file = models.ImageField(upload_to="wizard_pictures")
|
|
slug = models.SlugField(max_length=50, blank=True)
|
|
|
|
def __unicode__(self):
|
|
return self.file.name
|
|
|
|
@models.permalink
|
|
def get_absolute_url(self):
|
|
return ('upload-new', )
|
|
|
|
def save(self, *args, **kwargs):
|
|
self.slug = self.file.name
|
|
super(Picture, self).save(*args, **kwargs)
|
|
|
|
def delete(self, *args, **kwargs):
|
|
"""delete -- Remove to leave file."""
|
|
self.file.delete(False)
|
|
super(Picture, self).delete(*args, **kwargs)
|
|
|