-
Could you help me? Sorry to disturb you but maybe you can say what to class CafeFormset(FormCollection):
default_renderer = FormRenderer(field_css_classes='mb-3')
cafe = CafeForm()
cafe_images = CafeImageCollection() Everything work fine and I have form collections with siblings in I decided to show |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
If I understand your use-case correctly, you want to show |
Beta Was this translation helpful? Give feedback.
-
Try this way form.py class CafeFormset(FormCollection):
default_renderer = FormRenderer(field_css_classes='mb-3')
cafe = CafeForm()
cafe_images = CafeImageCollection()
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
user = kwargs.get('user', None)
if user
cafe_image_queryset = CafeImages.objects.filter(user=user)
self.declared_holders['cafe_images'].declared_holders['cafe_image'].fields['image'].queryset = cafe_image_queryset views.py class CafeView(...):
...
def get_collection_kwargs(self):
collection_kwargs = super().get_collection_kwargs()
collection_kwargs['user'] = self.request.user
return collection_kwargs Let me know if you are facing any issue |
Beta Was this translation helpful? Give feedback.
-
In one of my next versions, I will add methods |
Beta Was this translation helpful? Give feedback.
If I understand your use-case correctly, you want to show
cafe_images
in your form only, ifrequest.user
is someone specific.