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" ass
Hi
I have a formset and I'm passing initial data:
DeletionFormset = formset_factory(deletionForm, extra=0)
formset = DeletionFormset(initial=make_initial_data(instance))
The initial data arrives to the constructor fine.
When the construct bilds the forms it overrides a ChoiceField with a
I've send this post this morning:
Hi
I have a formset and I'm passing initial data:
DeletionFormset = formset_factory(deletionForm, extra=0)
formset = DeletionFormset(initial=make_initial_data(instance))
The initial data arrives to the constructor fine.
When the construct bilds the forms
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 bl
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 als
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
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
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 ...
thank
Are you sure the data will be retrieved twice ? I thought those
queryset definitions were lazy, so they are only executed when the
widgets are rendered.
Hmm, I'll try that out some time to check.
Koen
On 1 sep, 14:18, patrickk <[EMAIL PROTECTED]> wrote:
> that seems to be possible. on the other
hmm, if the data won´t be received twice this might be a solution.
do you have any idea about the syntax?
attachment_formset = BookingAttachmentFormSet(prefix="attachments")
for form in attachment_formset:
??? how do I set initial_data here ???
thanks,
patrick
On Sep 1, 3:39 pm, koenb <[EMA
Something like this might work I think:
attachment_formset = BookingAttachmentFormSet(prefix = "attachments")
for form in attachment_formset.forms:
form.fields['attachment'].queryset =
Attachment.objects.filter(user=request.user)
Koen
On 2 sep, 13:05, patrickk <[EMAIL PROTECTED]> wrote:
> h
Hi i used formsets in generic FormView like this:
class RequestRecommendationView(FormView):
template_name = "account/stepfour.html"
form_class = formset_factory(StepFourForm)
def form_valid(self,form):
print form.is_valid()
cleaned_data = form.cleaned_data
# r
The example below is a snippet from a view where I use a form to show
'Parent' and a formset to show its 'Children'.
If I get the children as a queryset and pass it on to the formsets
initial property, it errors out with: 'Parent' object is not iterable
InlineFormSet = formset_factory(InlineFor
On Thu, 2008-12-11 at 20:19 -0800, maeck wrote:
> The example below is a snippet from a view where I use a form to show
> 'Parent' and a formset to show its 'Children'.
> If I get the children as a queryset and pass it on to the formsets
> initial property, it errors out with: 'Parent' object is
Thanks Malcolm,
Just figured out the values transformation on querysets myself.
Nevertheless, in my experience there seems to be an issue with
foreignkeys when using queryset values in combination with formsets.
Values returns keys like 'parent_id', however formsets expect the
fieldname as 'paren
On Thu, Dec 11, 2008 at 9:55 PM, maeck wrote:
> Now I can pass the fieldnames as values('parent') for now, It would be
> easier if initial did not care if the _id is provided or not.
> Or am I missing something else?
You shouldn't be using a regular formset. Django provides model
formsets that k
On Thu, 2008-12-11 at 20:55 -0800, maeck wrote:
[...]
> Now I can pass the fieldnames as values('parent') for now, It would be
> easier if initial did not care if the _id is provided or not.
> Or am I missing something else?
What you're missing, or rather, assuming, is that querysets are ideal o
Malcolm,
Thanks for the comment.
I truly understand where this is coming from. This issue is completely
my issue of taking things for granted.
I have been coding around in Django for a while now (hooked on in the
0.95 days), and have been coding most of the form stuff (including
inlines) all by h
18 matches
Mail list logo