********************** shell *******************
In [1]: from photos.models import Image, Pool
In [3]: Image.objects.values_list('image')
Out[3]: [(u'photologue/photos/wielrenfiets.jpg',), (u'photologue/
photos/example2.jpg',)]
********************** models.py ***************
"""Post model."""
URL_CHOICES = (
(1, _('................ generated from image list (so
wielrenfiets.jpg) ......... ')),
(2, _('................ generated from image list (so
example2.jpg )......... ')),
(3, _('................ generated from image list .........
')),
etc
)
url = models.IntegerField(_('url'), choices=URL_CHOICES,
default=1)
************************
Is this something for a ModelChoiceField or Formset ? This replacement
failed
url = ModelChoiceField(queryset=Image.objects.values_list
('image'))
thanks in advance
So i tried
class Post(models.Model):
blog = models.ForeignKey(blog)
.....
url = models.ModelChoiceField
(queryset=Image.objects.values_list())
def __init__(self, *args, **kwargs):
super(Post, self).__init__(*args, **kwargs)
self.fields["url"].queryset = Image.objects.values_list
('image')
But i run into an AttributeError: 'module' object has no attribute
'ModelChoiceField'
You've misread Brian's post. The url redefinition, and the overridden
__init__, belong in the **form**, not the model. When you define your
ModelForm, use those definitions there.
--
DR.
Regards
2009/12/20 Daniel Roseman <dan...@roseman.org.uk>:
> --
>
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>
>
--
Mark Schuuring
M: mj.sch...@gmail.com