Wednesday, October 28, 2020

Filter a field in a form CreatView

Hi guys, How r u doing?

I have a field called articulos that is foreign key,  in a form is defined as follow:

forms.py
from django import forms
#from django.contrib.auth.models import User
from .models import Stockmov

class StockmovForm(forms.ModelForm):
    class Meta:
        model = Stockmov
        #fields ="__all__"
        fields =  ['articulo', 'motivo', 'Cantidad' ]
        widgets = {
        'articulo': forms.Select(attrs={'class':'form-control', 'placeholder':'Articulo'}),
        'motivo': forms.TextInput(attrs={'class':'form-control', 'placeholder':'Motivo'}),
        'Cantidad': forms.NumberInput(attrs={'class':'form-control', 'placeholder':'Cantidad'}),
        }
        labels = {
            'articulo':'', 'motivo':'', 'Cantidad':'',
        }

I want to allow the user to search an instance in the same  combobox articulo in the createview. Check the pic.

Whats is the best native way to do that?Other alternatives?

Thanks in Advance!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/692f2017-ab9e-40b7-8a7c-5c22bffaf368n%40googlegroups.com.

No comments:

Post a Comment