I want to do so without using an app because I feel that way I can really 
learn Django. Currently this is what I have in my models.py

from django.db import models
from django.contrib import admin
#from PIL import Images as PImage
import os
from PersonalWebsite.settings import MEDIA_ROOT

#def get_upload_file_name(instance, filename):
# return "uploaded_files/%s_%s" % (str(time()).replace('.', '_'), filename)

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)

I'm not sure if my models.py is set up correctly. But I did the best i can 
=/ My "get_image_by_album" method walks through all directories in my 
albums directory to get the path of the image and appends them to a list 
called "images". That is how much I got done so far. I was thinking about 
setting up a simple admin interface as well to allow me to easily maintain 
the site. Not sure where to go from here though =/



On Thursday, May 8, 2014 6:32:46 PM UTC-7, Venkatraman.S. wrote:
>
>
> On Fri, May 9, 2014 at 4:22 AM, m1chael <myk...@gmail.com <javascript:>>wrote:
>
>> photologue may work for you.. i use it, and have customized it very
>> extensively for my needs
>
>
> +1. Very easy to customize and play with.  Does most of the functions 
> needed of a photo-app.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a30ac610-144a-4e6a-8703-6e139115b6f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to