Album app process in Django
Question: I want to know how to display images separated by albums onto a page in
Django. So far, I've learned how to do so with the line

`<img src="{% static "images/python-logo@2x.png" %}">`

in my html file.

structure:

    
    
    /PersonalWebsite
       /static
          /img
             /albums
                /album1
                   img1
                /album2
                   img2
                ...etc
    

What I want to do is have a few album thumbnails out and upon click, all the
images from the album should be displayed. I believe I would do this with an
AJAX request. I am probably going to categorized these photos with tags and
put names one them and other characteristics. This would be done in my
`models.py` which I have: (though not completed)

    
    
    from django.db import models
    from django.contrib import admin
    import os
    from PersonalWebsite.settings import MEDIA_ROOT
    
    class Album(models.Model):
        title = models.CharField(max_length = 60)
    
        def __unicode__(self):
             return self.title
    
        def get_image_by_album(self):
             images = []
             for root, dirs, files in os.walk(os.path.join(MEDIA_ROOT, 'albums', self.title)):
                 mypath = os.sep.join(os.path.join(root, file).split(os.sep[4:]))
                 images.append(mypath)
                 return images
    
    class Tag(models.Model):
        tag = models.CharField(max_length = 50)
    
        def __unicode__(self):
            return self.tag
    
    class Image(models.Model):
        title = models.CharField(max_length = 60, blank = True, null = True)
        #image = models.FileField(upload_to = get_upload_file_name)
        tags = models.ManyToManyField(Tag, blank = True)
        albums = models.ForeignKey(Album)
        width = models.IntegerField(blank = True, null = True)
        height = models.IntegerField(blank = True, null = True)
        created = models.DateTimeField(auto_now_add=True)
    
    
        def __unicode__(self):
            return self.image.name 
    
    class AlbumAdmin(admin.ModelAdmin):
        search_fields = ["title"]
        list_display = ["title"]
    
    class TagAdmin(admin.ModelAdmin):
        list_display = ["tag"]
    
    class ImageAdmin(admin.ModelAdmin):
        search_fields = ["title"]
        list_display = ["__unicode__", "title", "created"]
        list_filter = ["tags", "albums"]
    
    admin.site.register(Album, AlbumAdmin)
    admin.site.register(Tag, TagAdmin)
    admin.site.register(Image, ImageAdmin)
    

My "get_image_by_album" parses through the albums and appends the path to
"images" list. Thats as far as I've got right now =/ I also want to set up an
admin so I can maintain the site easily later on. I think I am going to make a
view method that will simply get the list of image paths and display it that
way. I am open to suggestions! let me know what you think! I also want to set
up an admin interface that would enable me to upload and edit meta data from
the photos manually but I will figure out how to do so later.


Answer: I built a very simple gallery app using django-photologue.
<http://gallery.gentryart.us>

