Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix: profile image update #71

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions shop/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ class Comment(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
likes = GenericRelation(Like)

class Meta:
ordering = ['-created_at']


class Reply(models.Model):
info = models.ForeignKey(ProductInfo, on_delete=models.CASCADE, related_name='replies')
Expand Down
2 changes: 1 addition & 1 deletion shop/paginations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ class CustomPagination(PageNumberPagination):
class CommonCursorPagination(CursorPagination):
# page_size = 20
page_size = 5
ordering = 'created_at'
ordering = '-created_at'

14 changes: 7 additions & 7 deletions styles/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def get_num_followers(self, obj: Profile):
def get_num_followings(self, obj: Profile):
return obj.followings.count()

def to_internal_value(self, data):
internal_value = super().to_internal_value(data)
try:
image = self.context['request'].FILES['image']
return {**internal_value, 'image': image}
except KeyError:
return {**internal_value, 'image': None}
# def to_internal_value(self, data):
# internal_value = super().to_internal_value(data)
# try:
# image = self.context['request'].FILES['image']
# return {**internal_value, 'image': image}
# except KeyError:
# return {**internal_value, 'image': None}

def to_representation(self, instance: Profile):
representation = super().to_representation(instance)
Expand Down