I am trying to run some python code, using django, but it is returning that “No value for argument ‘on_delete’ in constructor call”. Answer Use Following Code
Tag: django
Is there a way to call two function-based views from views.py from one url? – Django or even by using Class-based view
I have tried two different style of views: Function-based and class-based. I have two functions in my views.py and i don’t know how to call both of them under single same url. I have seen suggestions to combine both functions into one but it still doesn’t work. Tried get() from class-based view an…
Django runserver hangs at “System check identified no issues (0 silenced).” for a while
I am not able to start manage.py runserver 0.0.0.0:8000. I am using a MySQL database and I have imported all the required modules. I am trying to run quite basic application. I am running python 3.7.3 on windows 10. Here is the error I am getting: I’ve seen a similar MemoryError around here, but I’…
How to test authenticated POST request with Pytest in Django
I want to test an authenticated post request on an API using Pytest. This is what I am doing so far: This doesn’t work because it gives me back a 401 (Unauthorized) instead of a 200. That makes sense since the fixture is a client and not an admin client. Yet if I pass in admin_client instead of client i…
in Celery/Django : cannot find reference ‘control’ in celery.task.control
I’m trying to use celery in my project. when I use from celery.task.control import revoke the PyCharm highlight control and warn me cannot find reference ‘control’ in __init__.py and also PyCharm adds broken line under revoke and warn me Unresolved reference revoke. But when I run the projec…
Install needed libraries for Weasyprint on pipenv (Windows environment)
In order to start generating documents with Weasyprint I installed it on my Windows machine following these instructions: https://weasyprint.readthedocs.io/en/stable/install.html#step-5-run-weasyprint On my computer it works but I have a Django project where I want to integrate this library and I use pipenv. …
Can’t fix “zipimport.ZipImportError: can’t decompress data; zlib not available” when I type in “python3.6 get-pip.py”
I was trying to install Django. Turns out that course’s teacher said that we will be working with Python 3.6 I install Python 3.6. Now it’s my default, it somewhat replaced the last version I had; which is Python 3.5. Everything ok until that. But when I want to install Django doing “pip3 in…
How to make multiple api calls with python requests
I am trying to make parallel calls to external apis from django using requests or any other library that allows me to do this. I have already tried using grequests to make this calls, sometimes it works but most times I get ‘NoneType’ object has no attribute ‘json’ error on the client …
How to get QuerySet values separately?
How I can to get values from QuerySet separately? The result of my QuerySet now is <QuertSet[<value: 5>, <value:90>]> How I can get 5, 90 to separate variable ? Answer There are many ways you can acheive it. For example: or using values_list(): If you want the first two values of a queryset,…
cant fix error: create() takes 1 positional argument but 2 were given and cant seem to fix it
I have a django rest framework view set. I want to create an object based on data that is passed in with the post request. I have it setup right now to create new object with dummy data before it starts to take information from the request. I am getting the following error: Here is my viewset method: Answer P…