How on the site page to make a filter by directory from the sql database? - One table with a dozen columns.
search - select values from several columns and display the result
Mneb an example of a model that works, I myself get crap, but I can not find anything.
This is a very similar problem, but I did not understand the answer.
so that django knows that in addition to the default database, you need to use another one, make the appropriate changes to the settings.py file:
DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'C: / path / to / follow / mydb.db', 'USER': '', 'PASSWORD ':' ',' HOST ':' ',' PORT ':' ',
}, 'clients': {'NAME': 'clients', 'ENGINE': 'django.db.backends.mysql', 'USER': 'root', 'PASSWORD': 'root'}}
customer base consists of a single table with columns: ID | NAME | CARD | etc. 1 | vasya | 1234 | ... 2 | petya | 2344 | ... ...
adding new and editing old lines for this database is not required. I'm interested in the NAME and CARD columns. as you might guess, NAME is the owner of the CARD.
and now I have a stupor ...
- To work with clients, I need to create class Clients in models.py?
... class Clients (models.Model): ID = models.CharField (max_length = 50) NAME = models.CharField (max_length = 50) CARD = models.CharField (max_length = 50) ...
- Do I need to create a field for each column in the table if I’m only interested in NAME and CARD?
and is it possible to somehow get them without driving in, there are a lot of speakers?
- How to declare for django that the class Clients is a table from the clients database, and not from the default database?