I'm using django-thumbs (http://code.google.com/p/django-thumbs/), and
the problem with it is that you can't stick blank=True, null=True when
you declare a field in your model.
To get around this, I thought I'd wrap it in another model, and
reference it from my Posting model, which contains information for a
post (text and picture.... etc etc). This works fine for one picture,
but I wanted say five - I tried to reference 5 of them by having 5
foreign key fields to the same model - but django didn't like that
very much and gave me a whole heap of errors - is there a way around
this?
My models look a bit like this:
class Image(models.Model):
photo = ImageWithThumbsField(
upload_to="static/site_images",
sizes=((thumb_widths,thumb_heights),))
class Posting(models.Model):
'''An abstract class to represent a listing '''
#main data
title = models.CharField(max_length=200)
body_text = models.TextField()
#Listing images
first_photo = models.ForeignKey(Image, blank=True, null=True)
second_photo = models.ForeignKey(Image, blank=True, null=True)
third_photo = models.ForeignKey(Image, blank=True, null=True)
fourth_photo = models.ForeignKey(Image, blank=True, null=True)
fifth_photo = models.ForeignKey(Image, blank=True, null=True)
class PostingForm(ModelForm):
class Meta:
model = Posting
This gives me loads of errors - i'm pretty sure it's because of the
ForeignKeys.
Thoughts?
On Jan 20, 5:48 pm, DragonSlayre <[email protected]> wrote:
> Hi,
>
> I've seen some posts from a while back, but didn't find any real
> solution when searching to find out how to put multiple images (or any
> field for that matter) into a form (mainly a ModelForm)
>
> Basically what I want to have is a form that has a one to many
> relationship from a post to images, and to allow 5 images to be
> displayed on the form.
>
> Any simple way of doing this?
>
> If not, any other ways that people can think of/have done?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---