question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Docs] Add usage instructions for Django (including 3.x)

See original GitHub issue

Hi I’m trying the django example from: https://devblogs.microsoft.com/python/announcing-playwright-for-python-reliable-end-to-end-testing-for-the-web/

But I’m getting this error:

Creating test database for alias 'default'...
System check identified no issues (1 silenced).
.E
======================================================================
ERROR: test_login (app.tests_playwright.MyViewTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Lubitz\.virtualenvs\DjangoBasisLager-JHlOkGlw\lib\site-packages\django\test\testcases.py", line 274, in __call__
    self._post_teardown()
  File "C:\Users\Lubitz\.virtualenvs\DjangoBasisLager-JHlOkGlw\lib\site-packages\django\test\testcases.py", line 1009, in _post_teardown
    self._fixture_teardown()
  File "C:\Users\Lubitz\.virtualenvs\DjangoBasisLager-JHlOkGlw\lib\site-packages\django\test\testcases.py", line 1044, in _fixture_teardown
    inhibit_post_migrate=inhibit_post_migrate)
  File "C:\Users\Lubitz\.virtualenvs\DjangoBasisLager-JHlOkGlw\lib\site-packages\django\core\management\__init__.py", line 168, in call_command
    return command.execute(*args, **defaults)
  File "C:\Users\Lubitz\.virtualenvs\DjangoBasisLager-JHlOkGlw\lib\site-packages\django\core\management\base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "C:\Users\Lubitz\.virtualenvs\DjangoBasisLager-JHlOkGlw\lib\site-packages\django\core\management\commands\flush.py", line 49, in handle
    allow_cascade=allow_cascade)
  File "C:\Users\Lubitz\.virtualenvs\DjangoBasisLager-JHlOkGlw\lib\site-packages\django\core\management\sql.py", line 13, in sql_flush
    tables = connection.introspection.django_table_names(only_existing=True, include_views=False)
  File "C:\Users\Lubitz\.virtualenvs\DjangoBasisLager-JHlOkGlw\lib\site-packages\django\db\backends\base\introspection.py", line 85, in django_table_names
    existing_tables = set(self.table_names(include_views=include_views))
  File "C:\Users\Lubitz\.virtualenvs\DjangoBasisLager-JHlOkGlw\lib\site-packages\django\db\backends\base\introspection.py", line 46, in table_names
    with self.connection.cursor() as cursor:
  File "C:\Users\Lubitz\.virtualenvs\DjangoBasisLager-JHlOkGlw\lib\site-packages\django\utils\asyncio.py", line 24, in inner
    raise SynchronousOnlyOperation(message)
django.core.exceptions.SynchronousOnlyOperation: You cannot call this from an async context - use a thread or sync_to_async.

----------------------------------------------------------------------
Ran 1 test in 2.323s

FAILED (errors=1)
Destroying test database for alias 'default'...
```

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
arjunattamcommented, Oct 7, 2020

Thanks for reporting this @pinguin999. I was testing on Django 2.x while writing the blog post, and I suspect that you’re using Django 3. I’ll fix the post for 3.x.

@mxschmitt and I were trying this on Django 3, and he put together this sample project that requires the DJANGO_ALLOW_ASYNC_UNSAFE=1 environment variable to run the test without throwing this error.

Would it be possible for you to try with this env var? We would need to understand whether there are any side-effects.

0reactions
pavelfeldmancommented, Mar 2, 2021

Joining with #439

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django documentation
A high-level overview of how it's organized will help you know where to look for certain things: Tutorials take you by the hand...
Read more >
Django Tutorial Part 9: Working with forms - MDN Web Docs
In this tutorial, we're going to show you a few of the ways you can create and work with forms, and in particular,...
Read more >
Running Django on the App Engine standard environment
While this tutorial demonstrates Django specifically, you can use this deployment process with other Django-based frameworks, such as Wagtail and Django CMS.
Read more >
Welcome to the django-extensions documentation! — django ...
Then you will need to add the django_extensions application to the ... We follow the Django guidelines for supported Python and Django versions....
Read more >
Porting Python 2 Code to Python 3 — Python 3.11.1 ...
Once your dependencies are no longer blocking you, use continuous integration to make sure you stay compatible with Python 2 & 3 (tox...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found