I want to create me admin like this: http://lightbird.net/dbe/_static/p1.png

What I have right now is:

def get_upload_file_name(instance, filename):
new_file_path_and_name = os.path.join(MEDIA_ROOT,'img/albums')
return new_file_path_and_name

class Album(models.Model):
title = models.CharField(max_length = 60)

def __unicode__(self):
return self.title

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 tags_(self):
lst = [x[1] for x in self.tags.values_list()]
return str(join(lst, ", "))

def albums_(self):
lst = [x[1] for x in self.albums.values_list()]
return str(join(lst, ", "))


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", "tags_", "albums_", "created"]
    list_filter = ["tags", "albums"]

admin.site.register(Album, AlbumAdmin)
admin.site.register(Tag, TagAdmin)
admin.site.register(Image, ImageAdmin)

I'm not sure what an acceptable input for ImageAdmin's list_display. I'm 
following the lightbird (http://lightbird.net/dbe/photo.html) tutorial but 
since it's out of date, I'm making some of my own choices along the way. 
I'm not sure how to modify my tags_ and albums_ method to achieve the admin 
layout.

-- 
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/2836d672-1120-4cc8-863d-276c9122b9e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to