• last month
The posts list in my Social Scheduler app has the scope to show the history for published posts. It shows the posts status, published time, posts content and the scheduled posts can be canceled manually.

This video shows how is working the posts list feature.
Transcript
00:00The posts list in my social scheduler app has the scope to show the history and cancel the scheduled posts.
00:16It uses infinite scrolling pagination.
00:24Here is the post status, hour when should be published or was published, and here is the post content.
00:46To get details about a post, we need to click on this button. This model is still in development.
01:01For infinite scrolling, I'm using this directive and this reactive object with information about the displayed posts,
01:24page name, number, total number of posts and animation.
01:34When this component is mounted, I'm using this function to request the posts from the database.
01:54I'm using this HTTP request with page number.
02:02When I scroll the posts list to the bottom, I'm using this function to verify if I have reached the bottom and I'm verifying if there are still more posts to display.
02:31If posts exist, I'm requesting them from the database.
02:40This function is called here using this directive.
02:50Now, let's analyze the backend.
03:01First, I need to look for this piece of URL here.
03:12This URL pattern directs the request to the posts app here.
03:26Then, I'm using this PostListView class to process the request.
03:46In this class, I'm extending the ListAPIView class of Django REST framework because I need to use its features for pagination and list.
04:07In this class, I'm using this serializer to specify which fields should be in each post.
04:24Then, I'm using this query to request all posts from the database.
04:34In this method, I'm using the user to filter all its posts from this query.
04:45This class contains the pagination options.
04:54This is used to verify if the user is authenticated.
05:03Finally, this is the method used to list all posts.
05:13This is used to apply the filters.
05:22Then, I'm ordering the posts by ID in descending order.
05:34Then, I'm using this paginateQuerySet method to apply this pagination class options.
05:50Here, I'm verifying if posts exist and I'm getting the current page to use it in the response.
06:06Then, I'm using the serializer to specify in the PostList which fields should be allowed.
06:25And, I'm returning even the total number of posts.
06:32If posts missing, I'm returning this error message.

Recommended