Questions tagged [django-3.0]

Django 3.0 is a version of the Django framework, released in December 2019. Please only use this tag if your question relates specifically to this version.

Django 3.0 works with Python 3.6, 3.7, 3.8, and 3.9.

release notes

302 questions
168
votes
5 answers

Django TemplateSyntaxError - 'staticfiles' is not a registered tag library

After upgrading to Django 3.0, I get the following TemplateSyntaxError: In template /Users/alasdair//myproject/myapp/templates/index.html, error at line 1 'staticfiles' is not a registered tag library. Must be one of: admin_list admin_modify…
Alasdair
  • 298,606
  • 55
  • 578
  • 516
66
votes
6 answers

Django: SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async

I use Django 3.0.6 and Jupyter notebook running with shell_plus --notebook. I try run queryset: User.objects.all() But return this error SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async. I try this…
Regis Santos
  • 3,469
  • 8
  • 43
  • 65
64
votes
1 answer

Django ImportError: cannot import name 'render_to_response' from 'django.shortcuts'

After upgrading to Django 3.0, I get the following error: ImportError: cannot import name 'render_to_response' from 'django.shortcuts' My view: from django.shortcuts import render_to_response from django.template import RequestContext def…
Alasdair
  • 298,606
  • 55
  • 578
  • 516
49
votes
4 answers

How to use django 3.0 ORM in a Jupyter Notebook without triggering the async context check?

Django 3.0 is adding asgi / async support and with it a guard around making synchronous requests in an async context. Concurrently, IPython just added top level async/await support, which seems to be running the whole interpreter session inside of a…
michalwols
  • 648
  • 1
  • 5
  • 8
22
votes
1 answer

How to integrate Faust with Django?

I am trying to integrate Faust with Django to publish the messages to Kafka. Here is the example in Faust repo: https://github.com/robinhood/faust/tree/master/examples/django I modified it a bit, and created views to push data to Kafka via…
Maverick
  • 2,738
  • 24
  • 91
  • 157
15
votes
5 answers

Django - taking values from POST request, JavaScript fetch API

Sorry if this is a noob question, I am creating a Django app and for that I am trying to access data received from POST request, using JavaScript fetch API but it is showing empty . I can't get what my mistake is. I have tried to remove all…
Abhishek Pratap Singh
  • 613
  • 3
  • 11
  • 18
12
votes
1 answer

What became available_attrs on Django 3?

First of all, I'm new to Django, so please be nice with me :D I'm currently adapting .py files for Django 3 because the files I have are compatible for Django 2. So, some changes have been made for the new version and in a file, it's written…
Maxime Teillaud
  • 123
  • 1
  • 5
12
votes
3 answers

How to call asynchronous function in Django?

The following doesn't execute foo and gives RuntimeWarning: coroutine 'foo' was never awaited # urls.py async def foo(data): # process data ... @api_view(['POST']) def endpoint(request): data = request.data.get('data') # How to…
naglas
  • 462
  • 1
  • 6
  • 16
12
votes
2 answers

Django 3 - Model.save() when providing a default for the primary key

I'm working on upgrading my project from Django 2 to Django 3, I have read their release notes of Django 3 and there is a point that I don't really understand what it will impact to my current project. Here they say: As I understand, if we try to…
Thanh Nguyen
  • 5,174
  • 11
  • 43
  • 74
10
votes
3 answers

pip can't find django 3.x - ERROR: No matching distribution found for django==3.0.4

When I run: pip3 install django==3.0.5 I get the error ERROR: Could not find a version that satisfies the requirement django==3.0.5 (from versions: 1.1.3, ... 2.2.11, 2.2.12) ERROR: No matching distribution found for django==3.0.4 I need to update…
Alejandro Veintimilla
  • 10,743
  • 23
  • 91
  • 180
8
votes
1 answer

Django-rest-framework filter_queryset() takes 3 positional arguments but 4 were given

I am using django-rest-framework in my application. And I am getting following error with this serializer. What I missed here? Got error when validating serializer serializer =…
Pez
  • 1,091
  • 2
  • 14
  • 34
8
votes
2 answers

How to generate asgi.py for existent project?

I have an existent django project in 2.2, but now i would like to start using channels, so I have to change to 3.0 and asgi instead of wsgi. How can I generate the asgi.py that I need to run the app?
Xhark
  • 781
  • 1
  • 9
  • 24
8
votes
5 answers

Django Admin Login page - Python Crashes

I am trying to login to admin url of the Django post creating superuser through command prompt. After i clicked log in button i am getting "Python has stopped working". Python Ver: 3.7.0 Django Ver: 3.0 Step 1: Created website using django-admin…
useruser00
  • 157
  • 1
  • 2
  • 14
6
votes
0 answers

Send async emails in django 3.0

I've seen that django has recently added asynchronous support in version 3.0. However, the docs are not completely clear for me and they do not provide a working example. Is it possible to send an email asynchronously using…
Manuel Montoya
  • 1,206
  • 13
  • 25
5
votes
2 answers

How to annotate sum over Django JSONField (Array of objects) data?

I have models sth like this # models.py class MyModel( models.Model ): orders = models.JsonField(null= True, blank=True, default=list) category = models.ForeignKey(Category, on_delete=models.CASCADE) I stored json data in this structure. [ …
1
2 3
20 21