Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django:将已填充的字段用作表单上的查询。ajax选择_Django_Forms_Django Queryset_Django Ajax Selects - Fatal编程技术网

Django:将已填充的字段用作表单上的查询。ajax选择

Django:将已填充的字段用作表单上的查询。ajax选择,django,forms,django-queryset,django-ajax-selects,Django,Forms,Django Queryset,Django Ajax Selects,我很难在表单上创建一个已填充的字段作为查询。 我正在使用ajax select渲染字段 forms.py class FormMakeOccurrence(forms.ModelForm): class Meta: model = ManageOccurrence fields = ('attribute', 'item', 'place') place = make_ajax_field(ManageOccurrence,'place','

我很难在表单上创建一个已填充的字段作为查询。 我正在使用ajax select渲染字段

forms.py

class FormMakeOccurrence(forms.ModelForm):

    class Meta:
        model = ManageOccurrence
        fields = ('attribute', 'item', 'place')

    place  = make_ajax_field(ManageOccurrence,'place','places', help_text=None)
    typeplace = make_ajax_field(TypePlace,'name','tipos_lugares', help_text=None)
    quarter = make_ajax_field(Quarter,'name','blocos', help_text=None)
lookup.py

class PlaceLookup(LookupChannel):

    model = Place

    def get_query(self,q,request):
        return Place.objects.filter(Q(name__icontains=q) | Q(typePlace__name__exact="AN FILLED FIELD") | Q(quarter__name__exact="AN FILLED FIELD"))

class TypePlaceLookup(LookupChannel):

    model = TypePlace

    def get_query(self,q,request):
    return TypePlace.objects.filter(Q(name__icontains=q)).order_by('name')
models.py

class ManageOccurrence(models.Model):


    attribute = models.ForeignKey(Attribute)
    item = models.ForeignKey(TypeItem)
    place = models.ForeignKey(Place)
    ... other fields

class Place(models.Model):
    name = models.CharField(max_length=30)
    typePlace = models.ForeignKey(TypePlace)
    quarter = models.ForeignKey(Quarter)
所以我想弄清楚,有哪些好的实践可以让这一切顺利进行


我需要先填上第一季度的表,所以打印的地方就满了。要到达正确的位置,要到达正确的属性以填充正确的项目。

恐怕django ajax会选择。但是,使用和很容易。