question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No TextInput-like form< no information render.

See original GitHub issue

I used this guide to make autocomplete forms on my page.

My forms.py

    driver=forms.ModelChoiceField(
        queryset=Driver.objects.all(),
        widget=autocomplete.ModelSelect2(url='dautoc')
    )
    class Meta:
        model = Plan
        fields = ('driver', )
        widgets = {
        }

urlpatterns

urlpatterns = [
    url(r'^dautoc/$', DriverAutocomplete.as_view(), name="dautoc"),
]

views.py

    def get_queryset(self):
        if not self.request.user.is_authenticated():
            return Driver.objects.none()

        qs = Driver.objects.all()

        if self.q:
            qs = qs.filter(name__istartswith=self.q)
        return qs

And it’s supposed to work fine, because it’s almost identical, but instead I don’t receive any results from my model’s db and more of that it’s Select-like instead of TextInput.

Any help or info is appreciated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jpiccommented, Aug 28, 2017

The python warning is because you forgot to add default ordering in the Model I suppose.

If you have no js error, no select2, perhaps the js is not loaded at all ? Have you tried rendering {{ forms.media }} after loading jquery.js like in the documentation ?

1reaction
jpiccommented, Aug 28, 2017

It seems like your python is ok because the select is meant to be empty because it’s going to fetch results. Are you sure that javascript is loading correctly ? Does it work with runserver with DEBUG=True ? If you’re on a git checkout, have you initialized submodules ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django Form does not Render in web page - Stack Overflow
I am trying to create a post edit page in Django, but when I test it the form does not render, only the...
Read more >
Custom Block Components | Draft.js
If no custom renderer object is returned by the blockRendererFn function, Editor will render the default EditorBlock text block component.
Read more >
Basic native form controls - Learn web development | MDN
It is used for creating most types of form widgets including single line text fields, time and date controls, controls without text input...
Read more >
How to Render Django Form Manually
Dealing with user input is a very common task in any Web application or Web site. The standard way to do it is...
Read more >
Form Renderer - Form.io Documentation
Another way to alter the submission data construct is to use any of the Data Components within a form. These are special components...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found