Skip to content

Tag: django

How to give the data to serializer with JSONField

I have model and serializer with JSONField Then,I want to set the data to serializer class, However some how serializer.is_valid() faild. I have tested two pettern data1 data2 What data should I give to this serializer? And is there any method to debug is_valid()? Answer You are giving the data in right way, but as you are updating partially, you

Django – How to save model objects in another model?

Let’s say I have these two models (in file): How can I merge these two models in a new model but with the same Id? So it becomes: PS: In my file I called a save method like that: Thanks in advance and I really appreciate who answers that because I see that many people having the same

Django Standalone Script in Django 4.1

I am trying to run a standalone script in django 4.1. I have the setup as suggested in this post at the top of my file: Django Standalone Script However, on the 4th line, I get the following error: ModuleNotFoundError: No module named ‘sport_api’ This is my INSTALLED_APPS in How do I get around this error? Update: Answer You

Django NotEqual custom lookup on related field

I registered a custom lookup base on this answer and official documentation. I registered the custom lookup in my app config. Then i use it in the exclude method this way. The idea here is to get all the customers where user is info.context.user (with private is False or True) OR user is NOT info.context.user but private is False but

NoReverseMatch at /login/ Reverse for ” not found. ” is not a valid view function or pattern nam

I don’t know why this problem is occuring. The login page is being rendered fine. But when I am clicking the Log In button after filling out the forms, I am getting this error. Can anyone help me solve this? My My My login.html file: Answer You’ve specified LOGIN_REDIRECT_URL = “”. The documentation for this setting says: The

Django get data from related model which has the FK

how can i make this queryset: models with Property.objects.all() I can see in the returned object that there is a listing_set let say: but it brings the entire model, and not the related to property_id; also tried to get Ota data in serializer with SerializerMethodField and perform a new query to get this info, but decrease performance significantly. Answer I