hello everyone,

am trying to build a single model that will be used for uploaded
images/files. Am trying to use it in the best way in the admin pages, so
when i associate it with a specific model as a many-to-many field it would
appear in a friendly way for users to upload images.

My attachment model is as following

class Attachment(models.Model):
    _attachment_types = (
        ('I', ('Image'))    ,
        ('P', ('PDF'))      ,
    )

    attachment_type         = models.CharField(max_length=2, default='I')
    description             = models.TextField(null=True, blank=True)
    file                    = models.FileField(upload_to='%Y/%m/%d')


my other model is

class LawCaseImage(models.Model):
    bonanza         = models.ForeignKey('LawCase')
    image           = models.ForeignKey(Attachment)
    primary_photo   = models.BooleanField(default=False)




class LawCase(models.Model):
    """  """
    user_profile    = models.ForeignKey(UserProfile,
limit_choices_to={'profile_type' : 'C'}, help_text=_('Only corporate
accounts will appear in the drop down.'))
    name            = models.CharField(max_length=20, )
    description     = models.TextField()
    created_at      = models.DateTimeField(auto_now_add=True)
    created_by      = models.ForeignKey(User, editable=False)
    image           = models.ManyToManyField(Attachment, through=LawCaseImage)


I tried to use inline associate in my admin.py as following

class LawCaseImageForm(admin.TabularInline):
    model = LawCaseImage


class LawCaseForm(admin.ModelAdmin):
    inlines = [LawCaseImageForm, ]


but all i got was a grid with the many-to-many table. I would like to be
able to upload images right away when creating a new record and they will
be uploaded to attachment model and relation will be created on that base..

Is there a way to configure admin to work on that behavior? and if not, is
there a plugin out there i could use for that purpose?

regards,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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