Categories
Mastering Development

image : None while successfully upload Django

I’m getting image url None while successfully uploading the image, i expected to get the image url which i sent to my server, but i’m getting the None value instead. Any help, would be much appreciated. thank you so much in advance. serializers.py class BulkImageSerializer(ModelSerializer): image1 = ImageField(required=True) image2 = ImageField(required=False) user_id = CharField(read_only=True) class […]

Categories
Mastering Development

Django + React Able to create new user in database, but token-auth returns 400 bad request

So I have an app that I’m writing. It’s working, for the most part, so far. I only currently have a login and signup setup, with a ‘homepage’ that just has a logout button and some text on it so I can test. When I do signup, it posts the user to the database, but […]

Categories
Development

PayPal Webhook cannot be validated

This might seem like a duplicate question but I wouldn’t be here if any of the proposed solutions did work. I have been trying to integrate PayPal IPN on my server-side according to their docs and the Github code sample here https://github.com/paypal/ipn-code-samples/blob/master/python/paypal_ipn.py I have changed the encoding of my sandbox business account to UTF-8 as […]

Categories
Development

Configure Nginx and Django for Byte Range Request

I am building a web API using Django and Nginx that needs to support Byte-Range requests. Currently, when making a request such as: curl –header “Content-Type: application/json” –header “Authorization: Token 8f25cd3bb5b43a5277f4237b1d1db0273dbe8f6a” –request POST http://myurl/download/ –header “Range: bytes=0-50” -v my Django view (the MyFileAPI class) is called, the user is authenticated, and the correct file path […]

Categories
Development

How to upload binary blob

I am attempting to send some binary data from a client via a blob to a django rest server, but the content of the received file ends up being “{}” independently of the content of the blob. I do not want to upload using base64 encoding. sample client code: fetch(“myserver/upload/file”, { headers: { ‘Authorization’: ‘Token […]

Categories
Development

required=False not working with update_or_create in ModelSerializer

I am creating an API where I get some data with user_id field. If given user_id exist in DB it update rest of the data else it will create new data. Here my code: serializers.py class DataUpdateSerializer(serializers.ModelSerializer): user_id = serializers.CharField(max_length=250) email = serializers.EmailField(required=False) first_name = serializers.CharField(required=False) last_name = serializers.CharField(required=False) class Meta: model = User fields […]

Categories
Development Heroku

Django API OneToOne relationship using Auth, User model, Views, Serializers

I’m trying to connect the HighScore model to my User model. This way I can save a HighScore instance for each User. No matter what I do, I get a 500 internal server error. I’ve tried creating a custom user model using AbstractUser. I’ve tried setting up OneToOne using settings.AUTH_USER_MODEL, and I’ve tried doing User […]