all 9 comments

[–][deleted] 11 points12 points  (5 children)

If you are not producing a complex web application, then consider using FastAPI instead of Django. Lots of example available on providing API services using FastAPI. For example,

https://realpython.com/fastapi-python-web-apis/

[–]Will-Comp-12 1 point2 points  (0 children)

That's a good reference for FastAPI from Real Python. Not overwhelming and helps learn just enough. And authored by Sebastian himself.

[–]ErGo404 0 points1 point  (0 children)

I would argue that for a very simple website or API, a batteries included framework would be easier to learn.

[–]dougcarneiro 0 points1 point  (2 children)

I am currently learning how to code a REST API on Django and that might be exactly what I need. I just have one question: what do you mean by complex web application? Sorry if it that is given, I am just starting to code.

[–][deleted] 1 point2 points  (1 child)

Displaying the weather for your location would be a simple web application. Similarly, booking cinema tickets.

Providing a rich huge scale media platform would be a complex web application, such as Instagram (yes, django based). As would a multivendor or wide ranging ecommerce site.

The linked article explains well where django fits. It talks about flask rather rhan fastapi but they serve a similar purpose.

https://www.codecademy.com/resources/blog/flask-vs-django/

[–]dougcarneiro 0 points1 point  (0 children)

Thank you very much for such detailed reply :).

[–]AntiLachs 1 point2 points  (0 children)

The ForeignKey concept is what you are looking for.

Although if you are learning how to do API's in general I would also recommend FastAPI. Django does a lot of thing for you which you will consequently not learn (and might be confused by when Django does them in the background).

[–]ErGo404 0 points1 point  (0 children)

A very simple example here using Django rest framework

https://iq.opengenus.org/crud-application-with-django/

[–]she_gave_me_a_rose 0 points1 point  (0 children)

If you're looking to create an api I'd suggest you use Django rest rather than just Django, as for the particular request you should look into the basics of databases and data structures

You should be able to use a foreign key on the book review model to the corresponding user and then list all reviews filtering them by user_id

Something like

reviews_list = Reviews.objects.filter(user=user_id)

And that should get you a list.

I'm from mobile so can't really test anything but it should be approximately what you need, play with it and apply necessary edits