I'm trying to create a REST_API in Django.Please tell me how to get the path.

Asked 1 years ago, Updated 1 years ago, 77 views

The URL is as follows.

scheme://host:80/model_name/param1/param2/param3?order_by[]=field1%20acs&order_by[]=field2%20decs&limit=1&offset=2

The field specified in order_by is
I would like to determine if it matches the column name in the model_name (table).

FuelPHP can get model_name in \Uri::segment(1), but
Is there a method like this in Django?

Also, the model_name is designed to be linked to the table.

Methods that can retrieve column lists from ORM Please let me know if anyone knows.

python django orm

2022-09-30 17:35

1 Answers

If you simply want to get a list of field names, I think you can get them below.

 [f.name for fin MyModel._meta.get_fields()]

I think you can understand more by referring to the following.
https://docs.djangoproject.com/en/1.10/ref/models/meta/


2022-09-30 17:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.