Custom Query (27115 matches)


Show under each result:

Results (10 - 12 of 27115)

1 2 3 4 5 6 7 8 9 10 11 12 13 14
Ticket Resolution Summary Owner Reporter
#29238 invalid psycopg2.InterfaceError in sequential tests after HTTP 404 nobody alubbock

I'm getting a curious error, where if I have two test methods, one using a force_login after a test with an HTTP 404, the second one fails. I've added a minimal reproducible example below. If the first method instead returns an HTTP 200, no error arises. If I use SQLite instead of Postgres, no error arises.

I'm using a custom user model with the custom_user package, with email instead of username, in case that's relevant.

Key package versions: django 1.11.10, python 3.6.4, postgres 9.6, custom_user 0.7, django allauth 0.35.0

from django.test import TestCase
from django.contrib.auth import get_user_model

class TestViews(TestCase):
    def setUpTestData(cls):
        cls.user = get_user_model().objects.create(email='')

    def test_404(self):
        resp = self.client.get('_non_existent_URL')
        self.assertEquals(resp.status_code, 404)

    def test_login(self):
        # fails with postgres

Here's the traceback:

Traceback (most recent call last):
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/db/backends/base/", line 231, in _cursor
    return self._prepare_cursor(self.create_cursor(name))
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/db/backends/postgresql/", line 220, in create_cursor
    cursor = self.connection.cursor()
psycopg2.InterfaceError: connection already closed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/alex/git/VU/myproj-web/myprojweb/tests/", line 16, in test_login
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/test/", line 645, in force_login
    self._login(user, backend)
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/test/", line 654, in _login
    if self.session:
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/test/", line 459, in session
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/contrib/sessions/backends/", line 81, in save
    return self.create()
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/contrib/sessions/backends/", line 50, in create
    self._session_key = self._get_new_session_key()
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/contrib/sessions/backends/", line 164, in _get_new_session_key
    if not self.exists(session_key):
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/contrib/sessions/backends/", line 46, in exists
    return self.model.objects.filter(session_key=session_key).exists()
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/db/models/", line 670, in exists
    return self.query.has_results(using=self.db)
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/db/models/sql/", line 517, in has_results
    return compiler.has_results()
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/db/models/sql/", line 858, in has_results
    return bool(self.execute_sql(SINGLE))
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/db/models/sql/", line 887, in execute_sql
    cursor = self.connection.cursor()
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/db/backends/base/", line 254, in cursor
    return self._cursor()
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/db/backends/base/", line 231, in _cursor
    return self._prepare_cursor(self.create_cursor(name))
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/db/", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/utils/", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/db/backends/base/", line 231, in _cursor
    return self._prepare_cursor(self.create_cursor(name))
  File "/Users/alex/miniconda3/envs/myproj/lib/python3.6/site-packages/django/db/backends/postgresql/", line 220, in create_cursor
    cursor = self.connection.cursor()
django.db.utils.InterfaceError: connection already closed
#29235 needsinfo Dropdown menu for multiple checkbox select nobody eddy-oj


I am not new to Python but new to Django and I have been impressed with it after 20 or so hours of use . However, I have stumbled upon a problem that I am struggling to fix: to allow a user to pick multiple selections from a long list of items.

I have found a couple of example Django extensions online (e.g. Django easy select) but the documentation is poor / inaccessible to users like myself. I also tried to plug this feature in using Bootstraps dropdown menu but this doesn't function right e.g. Django will know if the associated form is invalid but the validation pop up does not appear, requiring a javascript solution - but this doesn't tie in with the model in the back end properly!

Are there plans to implement this feature natively in Django?

Best regards


#29234 worksforme command "ping_google" requires django.contrib.sites to work but it's not documented nobody GOTO Hayato

I tried to use ping_google in my Django site with the following command after adding django.contrib.sitemaps to settings.INSTALLED_APPS.

python ping_google

Then, I got an error like:

django.core.exceptions.ImproperlyConfigured: ping_google requires django.contrib.sites, which isn't installed.

Seeing the related code, it seems that the command requires django.contrib.sites to be installed to work.

def _get_sitemap_full_url(sitemap_url):
    if not django_apps.is_installed('django.contrib.sites'):
        raise ImproperlyConfigured("ping_google requires django.contrib.sites, which isn't installed.")

I believe it's better to add some notes for this in the documentation.

(This is my first challenge to file an issue here. I'm sorry if I'm missing or misunderstanding anything crucial.)

1 2 3 4 5 6 7 8 9 10 11 12 13 14
Note: See TracQuery for help on using queries.
Back to Top