-
Notifications
You must be signed in to change notification settings - Fork 319
Description
So I am using the a customized class extended from ModelSelect2TagWidget.
`
class EssayTagWidget(ModelSelect2TagWidget):
model=Tag
queryset = Tag.objects.all()
search_fields = [
'name',
'pk__startswith'
]
def create_value(self, value):
self.get_queryset().create(name=value)
def value_from_datadict(self, data, files, name):
values = super(EssayTagWidget,self).value_from_datadict(data, files, name)
qs = self.queryset.filter(**{'pk__in': list(values)})
names = set(force_text(o.name) for o in qs)
cleaned_values = []
for val in values:
if force_text(val) not in names:
name = self.queryset.create(name=val).name
name=force_text(val)
cleaned_values.append(name)
return cleaned_values`
django is running remotely with uwsgi. When I type in the tags in browser, sometimes it returns
[pid: 29045|app: 0|req: 50/79] 71.235.103.17 () {44 vars in 1145 bytes} [Mon Oct 17 07:57:12 2016] GET /select2/fields/auto.json?term=f&field_id=NjA0NTIxMTI%3A1bvvIN%3A6wKudeJGu1ZTRSFrMbqxn50xELE => generated 64 bytes in 8 msecs (HTTP/1.1 200) 2 headers in 80 bytes (1 switches on core 0)
Not Found: /select2/fields/auto.json
and sometime it works.
If I manually type the address
/select2/fields/auto.json?
term=f&field_id=NjA0NTIxMTI%3A1bvvIN%3A6wKudeJGu1ZTRSFrMbqxn50xELE
into the browser, there is a chance (roughly 50%) that I can get desired result,
and all other times I got
Request Method: GET
Request URL: http://madeleine.academechina.com/select2/fields/auto.json?term=fad&field_id=NjA0NTIxMTI%3A1bvvIN%3A6wKudeJGu1ZTRSFrMbqxn50xELE
Raised by: django_select2.views.AutoResponseView
field_id not found
Please help! Thanks!