0

I try to use chained select (smart-select), it works from the admin panel, but doesn't work from template (html).

settings:

JQUERY_URL = False
USE_JQUERY_DJANGO = True
​

​ ​ html:

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>{% block title%}{% endblock %}</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="{% static 'main/css/main.css'%}">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="{% static 'smart-selects/admin/js/bindfields.js' %}"></script>
    <script src="{% static 'smart-selects/admin/js/chainedfk.js' %}"></script>
    <script src="{% static 'smart-selects/admin/js/chainedm2m.js' %}"></script>
</head>

class Tasks(models.Model):
​
    type = models.ForeignKey(TypeServices,on_delete=models.CASCADE,default='0')
    site = ChainedForeignKey(
        Services,
        chained_field="type",
        chained_model_field="type",
        show_all=False,
        sort=True)

1 Answers1

0

You only have to use this one USE_JQUERY_DJANGO = True

Remove JQUERY_URL = False

  • A little explanation is always better to help OP and other users understand your solution. – Ank May 24 '21 at 17:51