custom fields in django to filter code example
Example 1: 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)
Example 2: filter field set in django formds
from django.contrib.auth.decorators import login_required
@login_required
def agregar_producto(request):