Answers for "filter field set in django formds"

0

filter field set in django formds

if request.method == "POST":
    modelform = AgregarProducto(request.POST, request.FILES, user=request.user)
    ...
else:
    modelform = AgregarProducto(user=request.user)
Posted by: Guest on August-26-2020
0

filter field set in django formds

from django.contrib.auth.decorators import login_required

@login_required
def agregar_producto(request):
Posted by: Guest on August-26-2020
0

filter field set in django formds

class AgregarProducto(forms.ModelForm):
    class Meta:
        model   = productos

    def __init__(self, *args, **kwargs):
        user = kwargs.pop('user')
        super(AgregarProducto, self).__init__(*args, **kwargs)
        self.fields['secciones'].queryset = secciones.objects.filter(user=user)
Posted by: Guest on August-26-2020

Code answers related to "filter field set in django formds"

Python Answers by Framework

Browse Popular Code Answers by Language