aalug / blog_drf Goto Github PK
View Code? Open in Web Editor NEWBlog app built in the Django REST framework
Blog app built in the Django REST framework
Implement token authentication. Specifically. There should be an option to generate and manage tokens through an API endpoint.
Create a new API endpoint that generates access tokens upon successful authentication.
Test this endpoint.
Create a wait for db
command.
Add Django REST Framework JSON CamelCase so the API will be able to receive and send data in camel case format. It will ensure that the language style conventions are kept (python snake case, JS/TS camelCase).
Create an API for managing PostImage objects. It should have permission_classes = [IsAdminUser]
so only the staff can create, update and delete post images. 'Normal' users can access them by fetching post details.
Create an API for managing comments. This ViewSet
should handle creating, updating, and deleting comments. permission_classes
should be set to [IsAuthenticated]
so every logged-in user can comment on posts. Additionally, there should be a check in the partial_update
and destroy
methods so that users can alter only comments that they are authors of.
Create a 'create user' API endpoint that will handle creating new users. Test that endpoint.
Create a voting feature.
read_only
because it should be set based on the user making the requestdestroy
method, a check should be added that raises an error if the user making the request is not the author of the voteUserProfile.points
based on vote type and on the fact, whether is the vote being created or deletedCreate and test models required for creating posts. That is Post, Comment, Tag, and PostImage models.
Create an API for managing tags - creating, retrieving all, updating, and deleting.
Create a profile API endpoint that will handle retrieving and updating users' data.
Create a signal for deleting tags that are not assigned to any post. The function should run pre_delete
. It should loop through the tags of the post that is being deleted, and check if the tag is assigned to any other post. if it's not, the tag should be deleted. That will make sure that there are no pointless tag objects in the database.
Create a posts API. Create endpoints to GET, POST, PATCH and DELETE posts. GET should require no authentication. The rest of the methodes should require is_staff
property set to True (rest_framework.permissions.IsAdminUser
).
Test all of the endpoints.
Update the user model by removing all fields except of email ans password. For the rest of the fields create a new model - UserProfile. It should be created automatically after User. Use signals and post_save
Add no pagination option to list tags endpoint.
Add the following code to the posts.views.TagViewSet
:
def paginate_queryset(self, queryset, view=None):
if 'no_page' in self.request.query_params:
return None
else:
return self.paginator.paginate_queryset(queryset, self.request, view=self)
Thanks to this, when no_page
is present in query params all tags will be listed at once - with no pagination.
Add a post-sorting feature. It should take as a query param sort
and sort posts depending on the value.
Sorting options:
sort=title-asc
or sort=comments-desc
)Tweak posts.serializers
to better refrect data nedded in the frontend app. Comment serializer should have this:
class UserProfileSerializer(serializers.ModelSerializer):
class Meta:
model = UserProfile
fields = ('first_name', 'last_name',
'date_of_birth', 'profile_image', 'points')
class PublicUserSerializer(UserSerializer):
user_profile = UserProfileSerializer()
class Meta(UserSerializer.Meta):
fields = UserSerializer.Meta.fields + ('user_profile',)
and set author = PublicUserSerializer()
in comment serializer.
Add Redis to the project. By integrating Redis into the project, we can improve the performance and scalability of the application, particularly when it comes to handling high-traffic web pages like the posts page.
Add Celery to the project and handle sending 'forgot password' emails.
Create a post details endpoint. The serializer should extend the PostsSerializer
and additionally have three fields - body, images, and comments.
Also, add the number_of_comments
property to the Post model and add it to the PostsSerializer
. There should be information about the number of comments while listing posts.
Create a new User model and serializer that will accommodate this app's needs for user's data.
Add an option to reset a password.
There should be an option to send a POST
request with an email of the user that has forgotten their password to get a link to reset it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.