that seems to be possible. on the other hand, it also seems to be a
strange way to go: instantiating the formset (retrieving all data/
querysets) and then changing the querysets? performance-wise, this is
probably not a good solution. and I doubt that this is a good decision
design-wise ...

thanks,
patrick


On Sep 1, 1:51 pm, koenb <[EMAIL PROTECTED]> wrote:
> I have not tried this, but can't you just in your view instantiate the
> formset and then loop over the forms and set the queryset on your
> field ?
>
> Koen
>
> On 1 sep, 09:24, patrickk <[EMAIL PROTECTED]> wrote:
>
> > found a solution: with using threadlocals, it´s possible to define a
> > custom manager which only returns the data assigned to the currently
> > logged-in user. since threadlocals has been considered a "hack"
> > recently by one of the main django-developers (I think it was
> > malcolm), this is probably not the best thing to do though.
>
> > On Aug 31, 4:35 pm, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > sorry for being so annoying with this issue, but I´m asking this one
> > > more time.
>
> > > - with using inlineformset_factory, my problem is that limiting the
> > > choices to the currently logged-in user seems impossible. I´ve just
> > > tried to write a custom manger with "use_for_related_fields = True",
> > > but it´s also not possible to limit the basic queryset to the current
> > > user.
>
> > > so - before going back to pure forms and re-writing the main part of
> > > my application, I´m just asking this question for the last time ...
>
> > > thanks,
> > > patrick
>
> > > On Aug 27, 9:04 am, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > > anyone?
>
> > > > On Aug 26, 12:19 pm, patrickk <[EMAIL PROTECTED]> wrote:
>
> > > > > scenario: users are uploading documents (e.g. images, files, ...).
> > > > > these documents are saved in a model "Attachment" assigned to the
> > > > > currently logged-in "User". now, every user has the possibility to
> > > > > attach documents to a blog-entry. these attachments are saved in a
> > > > > model "BlogEntryAttachment" assigned to a "BlogEntry".
> > > > > the best way to achieve this is probably using formsets. when writing
> > > > > a BlogEntry, the user has the option to attach his/her documents to
> > > > > that BlogEntry. to achieve this, I have to limit the choices (of a
> > > > > select-field) to the currenlty logged-in User.
>
> > > > > questions & notes:
> > > > > ### how can I limit the choices of a select-field using formsets?
> > > > > ### I've tried inlineformset_factory, but there's no argument
> > > > > "initial". besides that, I´m not sure how to use "initial" for
> > > > > limiting a queryset ...
> > > > > ### with using formset_factory on the other hand, I could use a
> > > > > ModelChoiceField with queryset=Attachment.objects.filter(user=user),
> > > > > but how do I get the "user" there?
> > > > > ### Overriding __init__ within BlogEntryAttachmentForm and passing the
> > > > > currently logged-in user seems possible, but then I also have to
> > > > > override the BaseFormSets __init__ and _construct_form, which just
> > > > > seems ugly and far too complicated.
>
> > > > > MODELS:
>
> > > > > class Attachment(models.Model):
>
> > > > >     user = models.ForeignKey('auth.User')
> > > > >     title = models.CharField('Title', max_length=100, blank=True,
> > > > > null=True)
> > > > >     filename = models.CharField('Filename', max_length=100,
> > > > > blank=True, null=True)
> > > > >     path = models.CharField('Path', max_length=200, blank=True,
> > > > > null=True)
> > > > >     ...
>
> > > > > class BlogEntryAttachment(models.Model):
>
> > > > >     blogentry = models.ForeignKey(BlogEntry)
> > > > >     attachment = models.ForeignKey(Attachment)
> > > > >     ....
>
>
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to