JaqiKal / pixavibe-frontend

The Pixavibe is a social media website for sharing photos. Created as part of my full-stack portfolio project 5 for the Code Institute diploma in full stack software development.
0 stars 0 forks source link

[BUG] Avatar broken in posts card #65

Closed JaqiKal closed 1 month ago

JaqiKal commented 1 month ago

Describe the bug When adding a new post the post owner avatar is broken.

To Reproduce Yes, just follow the steps to ad a post.

Expected behavior When post i screated owner avatar should be visible

Screenshots n/a

Desktop / Smartphone (please complete the following information):**

Additional context Seems that the introduction on App Hashtag is wreaking havoc with my posts.

JaqiKal commented 1 month ago

Solution: Adding attribute profile_image in PostCreateUpdateSerializer and adding it to the metadata fields.

Solved in commit 46: d18f476 in pixavibe-api.

# Serializer for creating & updating Post instances,
# including associating hashtags via their IDs
class PostCreateUpdateSerializer(serializers.ModelSerializer):
    # Allows specifying hashtags by their IDs during
    # creation or update of a post.
    hashtag_ids = serializers.PrimaryKeyRelatedField(
        many=True,
        queryset=Hashtag.objects.all(),
        source='hashtags',
    )
    profile_image = serializers.ReadOnlyField(source='owner.profile.image.url')

    # Meta class for specifying the model & fields to serialize.
    class Meta:
        model = Post
        fields = [
            'id','title', 'content', 'image',
            'image_filter', 'hashtag_ids',
            'profile_image',