Hello everyone, 

I run into a odd situation while trying to run some tests in an old project 
(dj 1.8)
Then I tried the same on a django 3.1 and the problem is still there. 

# models.py  #################
class Disco(models.Model):
    nome = models.CharField('disco', max_length=50)

class Musica(models.Model):
    disco = models.ForeignKey(Disco, on_delete=models.CASCADE)
    nome = models.CharField('nome do disco', max_length=50)

# forms.py  #################
class MusicForm(forms.Form):
     ''' ... like a search form, I need option from database '''
     disco = forms.ChoiceField(choices=Disco.objects.all())

# tests.py  #################
# in the tests.py I just need to import the form to have the odd bahaviour

from django.test import TestCase
from .forms import MusicForm

... I just need to import the `MusicForm` to have the erros 
# the error #########
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
   django.db.utils.OperationalError: FATAL:  database "disccollection" does 
not exist

I was trying to run tests, so the database to hit should be  `test_
disccollection`
but not `disccollection` (in my settings.py). 
That may happends because django test framework only changes the 
settings.database.default alias after my form was initialized.

Is it a known bug or a bug at all ? 

I dont kknow not even search for this on django bugs . 

Have anybody seem there before ?

PS: I put a sample code on 
https://github.com/cadu-leite/django18py2testdb/tree/dj33py3test



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/91dcb131-749c-4065-bd37-e94d62249398n%40googlegroups.com.

Reply via email to