0

There is a widget in Django, called NumberInput, the type of which can be defined as range. It is an usual range. There is a graphical element – a slider (a range as well) in a website. That's convenient that it has an animated label with number value. A code and an image of the slider will be on the website. I found a supposed code realizing a similar thing, here is the code from that website:

import floppyforms as forms

class Slider(forms.RangeInput):
    min = 5
    max = 20
    step = 5
    template_name = 'slider.html'
    class Media:
        js = (
            'js/jquery.min.js',
            'js/jquery-ui.min.js',
        )
        css = {
            'all': (
                'css/jquery-ui.css',
            )
        }

I tried to redefine template_name variable with an html-file containing the code and also to point paths to css and js files but an error appears at testing in Django shell (run as python manage.py shell). If to apply a widget in Django form, to take an instance of the form, and to print the instance, then html code must be returned, but an error did. The error is about not existing a template (TemplateDoesNotExist). I think what to do. Can I create Django widgets at an own discretion? Can I pass html, css, js code directly to special variables? Or can I only use a template file with a widget html, css, js code? Into what directrory should templates be placed? I placed into BASE_DIR / templates and static but the error left.

SFriendly
  • 119
  • 3

0 Answers0