Ok, I'm just getting back to a project I had to put on hold for a
while.

I recently read an article on problems new Django users fall into, and
I think I hit one.

The bottom of my 'Systems' model looks like this:

        keyboard = models.CharField(max_length=80)
        cart = models.CharField(max_length=80)
        ram = models.CharField(max_length=40)
        rom = models.CharField(max_length=40)
        media = models.CharField(max_length=80)
        options = models.CharField(max_length=120)
        quick = models.TextField()
        info = models.TextField()
        system_pictures = models.ManyToManyField('Image')
        public = models.BooleanField()

        def __unicode__(self):
            return self.name

        def get_header_pic(self):
            return
self.system_pictures.filter(image_category__name='Header_Pic')[0]

        def get_header_logo(self):
            return
self.system_pictures.filter(image_category__name='Header_Logo')[0]

The problem is that when using the admin to enter the data for the
Systems, I get a list of every pic in the 'Image' model to choose
from.

I can see this getting frustrating very fast.

I'm thinking that I can just use the fields in the 'Image' model to
find the appropriate pics, but don't know how to re-structure
'get_header_pic' to work with that. Or should I be doing something
different in the View or Template to access these pics?

Also, I added and 'Thumb' model when I added functionality I hadn't
originally though of. Unfortunately, it's almost an exact copy of the
"Image' model I made.

As seen here:

class Image(models.Model):
        name = models.CharField(max_length=80)
        slug = models.CharField(max_length=80)
        location = models.URLField()
        height = models.IntegerField()
        width = models.IntegerField()
        image_category = models.ForeignKey('ImageCat')
        info = models.TextField()
        primary = models.BooleanField()

        def __unicode__(self):
            return self.name

class Thumb(models.Model):
    name = models.CharField(max_length=80)
    slug = models.CharField(max_length=80)
    location = models.URLField()
    height = models.IntegerField()
    width = models.IntegerField()
    system = models.ForeignKey('System')
    image_category = models.ForeignKey('ImageCat')
    big = models.ForeignKey('Image')
    primary = models.BooleanField()

    def __unicode__(self):
        return self.name

I'm thinking I should merge them by adding t_height, t_width and
t_location to the 'Image' model. Am I missing any downside to doing
this?

Lance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to