Search code examples
djangodjango-flatpages

Django flatpages and images


I'm interested in using the Flatpages app for my project but would also like a place (somewhere in the admin) to upload images that I want to reference on those flatpages.

Is there a way to do this without resorting to a CMS app?


Solution

  • simplest way is to upload images to a photo hosting (picasa, flickr etc). If you prefer to stick with django admin, you can write a simple app with a single model like this:

    class Image(models.Model):
        title    = models.CharField(max_length=255)
        file    = ImageField(upload_to='car_images')
    
        def get_absolute_url(self):
            return (self.file and self.file.url) or ''