T
T
tanyaa2017-07-21 18:03:38
Django
tanyaa, 2017-07-21 18:03:38

How to properly use django-smart-selects?

Good evening.
I need to use bound selects on a form.
As described, my models are essentially the same as in the example described in django-smart-selects:

class Continent(models.Model):
    name = models.CharField(max_length=255)

class Country(models.Model):
    continent = models.ForeignKey(Continent)
    name = models.CharField(max_length=255)
from smart_selects.db_fields import ChainedForeignKey

class Location(models.Model)
    continent = models.ForeignKey(Continent)
    country = ChainedForeignKey(
        Country,
        chained_field="continent",
        chained_model_field="continent",
        show_all=False,
        auto_choose=True,
        sort=True)
    area = ForeignKey(Area)
    city = models.CharField(max_length=50)
    street = models.CharField(max_length=100)

The application installed correctly.
Added url(r'^chaining/', include('smart_selects.urls')) to url,
added `smart_selects` to INSTALLED_APPS
But when importing
from smart_selects.db_fields import ChainedForeignKey
Error is returned:
django.core.exceptions.ImproperlyConfigured: Requested setting USE_JQUERY_DJANGO, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing
settings.
Question: where and how and with what arguments to call settings.configure() so as not to break everything or how to solve it? :) Or can such a connected select be implemented somehow differently?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question