User:Darija Medic/technicalcourse/django

From XPUB & Lens-Based wiki
< User:Darija Medic‎ | technicalcourse
Revision as of 20:34, 23 September 2010 by Migratebot (talk | contribs) (Created page with "preliminary version of models <source lang="python"> class Tag(models.Model): name = models.CharField(max_length=255) # pieces = ... def __unicode__(self): ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

preliminary version of models

class Tag(models.Model):
    name = models.CharField(max_length=255)
    # pieces = ...
    def __unicode__(self):
        return self.name

class Piece(models.Model):
    title = models.CharField(max_length=255, blank=True)
    year_built= models.IntegerField(null=True, blank=True)
    torn_down= models.IntegerField(null=True, blank=True)
    description = models.TextField(blank=True)
    image=models.ImageField(upload_to="images")
    footnote=models.CharField(max_length=255, blank=True)

    sounds=models.ManyToManyField("Zvuk", related_name="pieces", blank=True)
    tags = models.ManyToManyField("Tag", related_name="pieces", blank = True)  
    def __unicode__(self):
        return self.title      

class Pic(models.Model):
    piece=models.ForeignKey("Piece", related_name="pics")
    image=ImageWithThumbnailsField(
        upload_to='images',
        thumbnail={'size': (120, 120)},
        extra_thumbnails={
            'icon': {'size': (32, 32), 'options': ['crop', 'upscale']},
            'large': {'size': (640, 640)},
        }
    )

    def __unicode__(self):
        return self.image.name

class Zvuk(models.Model):
    fajl=models.FileField(upload_to="zvuks")
    def __unicode__(self):
        return self.fajl.name