[PYTHON] Data acquired by Django releted

When displaying the Japanese name on the shift table, when I wanted to display the information of the table specified by ForeingKey in various ways, I could not do it anyway, so I passed it from Views to the template. ..

image.png

The user and profile are tied together, and object_list refers to the foreign key by the user, but I didn't know how to call it, and I didn't know if it was getting it together, so I knead it with a template. Was there.

image.png

It's really processed with for and if (laughs) I think this is fine, but ...

When I was investigating something different, there was information that I could get it by specifying the field that references the foreign key and then specifying the field. So a little experiment.

image.png

Is it possible to get the start time from the externally referenced shift name, or to get the name from the user table?

image.png

I will try to output with this.

image.png

I was able to output (⌒∇⌒)

DJango seems to get all the related tables. I'm grateful that you can create it without having to remember the SQL statement.

HTML, CSS, Django, Python, javascript, how much would it be if SQL were added to this, but it's convenient.

It should be possible to display with "dictionary + external reference field name + field name you want to acquire". This will reduce the number of times it is retrieved from the database, so it seems that the time until it is displayed can be reduced.

I would also like to modify the shift table when I make some changes.

You can learn and practice new things

This is fun, isn't it: middle_finger_tone1:

Recommended Posts

Data acquired by Django releted
[Django] How to get data by specifying SQL.
Split data by threshold
Training data by CNN
Correlation by data preprocessing
Classify data by k-means method
Gzip the data by streaming
Visualization of data by prefecture
django data input dumpdata loaddata
First satellite data analysis by Tellus
Sort django models by specific criteria
10 selections of data extraction by pandas.DataFrame.query
Animation of geographic data by geopandas
Save the audio data acquired by the browser in wav format on the server