Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Making some small changes to post causes Bad request 400 error #752

Description

@alsiPanda

I have changed the post in PostImage to ForeignKey from one-to-one. And added a CharField called ptype, which I wanted to use for filtering based on its value.
In getTopPosts, I have moved post__image from select_related to prefetch_related, and added ptype to only. I have also added ptype to curate_top_posts in jobs. On other hand, I have also added many=true wherever PostMediaSerializer is used.

I then added a query in top_post_community_query, post__ptype__exact="string" where string is recieved from request in view. Made relevant changes to serializer as well. This is where I am facing the problem of bad request 400 in api, and invalid model in app. If I comment out the ptype query, error dissapears and I get a list of top posts. But if I keep the query and instead comment out content_object in PostMediaSerializer, then also the 400 error dissapears, although I get error in app due to no Content object.

I tried to add the ptype field to TopPost model instead, so I could use it direct, and made all the relevant changes to jobs, and ran migration successfully. But then the scheduled job fails with Integrity error, 1364, ptype has no default even though I have added default string in the ptype field. I also tried to set null=True and null=False, but getting the same error in the failed job.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions