Custom Query (27111 matches)


Show under each result:

Results (31 - 33 of 27111)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Ticket Resolution Summary Owner Reporter
#29201 invalid Rendering issues when using ArrayField(models.BooleanField()) linluc

My goal is to replace 50 Boolean fields with one ArrayField(models.BooleanField(), size=50) so I am prototyping this approach. I have not found a single online example with such combination (ArrayField + BooleanField) and also this area is very poorly documented. I am running into numerous issues and that makes me feel that it was never properly tested. Well, I am offering my help in future testing regarding this issue.

Here is my simple model (using Django 2.0.3):

class Test1Model(models.Model):
   user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
   user_choices = ArrayField(models.BooleanField(), default=(), size=5, null=True)


class Test1Form(forms.ModelForm):
   class Meta:
      model = Test1Model 
      fields = ('user_choices',)

      widgets = {
         'user_choices' : SplitArrayWidget(forms.CheckboxInput(),5)


def run_test1(request):
   if request.method == 'POST':
      test_form = Test1Form(instance=request.user.test1model, data=request.POST)

      if test_form.is_valid():
      test_form = Test1Form(instance=request.user.test1model)
   return render(request, 'test1/test1.html' , {'test_form': test_form})

template (test1.html):

<!DOCTYPE html>

<form action="." method="post" autocomplete="off">

     {{ test_form.as_p }}
     {% csrf_token %}
    <p><input type="submit" value="Submit"></p>



Here you will encounter a bug which I already reported ( but it is easy to fix by moving the template directory.

After fixing the template issue the initial page renders OK, 5 check-boxes are present (see attached image, section A).

Problem 1: by default all check-boxes are required and I was unable to reverse that. Adding "required = False" caused the following error:

TypeError: __init__() got an unexpected keyword argument 'required'

See the image, section B.

OK, for the purpose of prototyping I checked all check boxes and submitted the form. The output was highly unexpected (image, section C).

The output page includes 24 check-boxes and by looking at the generated HTML we can see why (hint: value=""):

<p><label for="id_user_choices_0">User choices:</label>
<input type="checkbox" name="user_choices_0" value="T" checked required id="id_user_choices_0" />
<input type="checkbox" name="user_choices_1" value="r" checked required id="id_user_choices_1" />
<input type="checkbox" name="user_choices_2" value="u" checked required id="id_user_choices_2" />
<input type="checkbox" name="user_choices_3" value="e" checked required id="id_user_choices_3" />
<input type="checkbox" name="user_choices_4" value="," checked required id="id_user_choices_4" />
<input type="checkbox" name="user_choices_5" value="T" checked required id="id_user_choices_5" />
<input type="checkbox" name="user_choices_6" value="r" checked required id="id_user_choices_6" />
<input type="checkbox" name="user_choices_7" value="u" checked required id="id_user_choices_7" />
<input type="checkbox" name="user_choices_8" value="e" checked required id="id_user_choices_8" />
<input type="checkbox" name="user_choices_9" value="," checked required id="id_user_choices_9" />
<input type="checkbox" name="user_choices_10" value="T" checked required id="id_user_choices_10" />
<input type="checkbox" name="user_choices_11" value="r" checked required id="id_user_choices_11" />
<input type="checkbox" name="user_choices_12" value="u" checked required id="id_user_choices_12" />
<input type="checkbox" name="user_choices_13" value="e" checked required id="id_user_choices_13" />
<input type="checkbox" name="user_choices_14" value="," checked required id="id_user_choices_14" />
<input type="checkbox" name="user_choices_15" value="T" checked required id="id_user_choices_15" />
<input type="checkbox" name="user_choices_16" value="r" checked required id="id_user_choices_16" />
<input type="checkbox" name="user_choices_17" value="u" checked required id="id_user_choices_17" />
<input type="checkbox" name="user_choices_18" value="e" checked required id="id_user_choices_18" />
<input type="checkbox" name="user_choices_19" value="," checked required id="id_user_choices_19" />
<input type="checkbox" name="user_choices_20" value="T" checked required id="id_user_choices_20" />
<input type="checkbox" name="user_choices_21" value="r" checked required id="id_user_choices_21" />
<input type="checkbox" name="user_choices_22" value="u" checked required id="id_user_choices_22" />
<input type="checkbox" name="user_choices_23" value="e" checked required id="id_user_choices_23" />

I should note that the values are saved in the database correctly, but still the Django included rendering choices (as_p, as_ul, as_table) are broken here.

Please also note that the label assignment is broken as well, there is only one label generated for all check-boxes.

#29200 fixed RadioSelect does not render its label in MultiWidget Tim Graham Takayuki Hirai

The code:

from django import forms

class MyWidget(forms.MultiWidget):
    def __init__(self):
        widgets = [
                choices=[('aaa', 'bbb')]
        super(MyWidget, self).__init__(

    def decompress(self, v):
        return []

print(MyWidget().render('wname', None))

Actual output:

    <li><input type="radio" name="wname_0" value="aaa" />


Expected output:

    <li><label><input type="radio" name="wname_0" value="aaa" />


It seems that this problem is caused by the following reasons:

  • a template of RadioSelect requires wrap_label context varialbe to render LABEL elements
  • MultiWidget.get_context() drops wrap_label
#29199 fixed Oracle backend won't connect if password contains '@' felixxm Shane Allgeier

The Oracle backend won't connect if password contains '@'.

For example, using this DATABASES config in

    'default': {
        'ENGINE': '',
        'NAME': 'mydsn',
        'USER': 'valid_username',
        'PASSWORD': 'p@ssword',
        'HOST': '',
        'PORT': '',

I get this traceback:

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fab58f99ae8>
Traceback (most recent call last):
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/backends/base/", line 216, in ensure_connection
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/backends/base/", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/backends/oracle/", line 208, in get_new_connection
    return Database.connect(self._connect_string(), **conn_params)
cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified

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

Traceback (most recent call last):
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/utils/", line 225, in wrapper
    fn(*args, **kwargs)
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/core/management/commands/", line 123, in inner_run
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/core/management/", line 427, in check_migrations
    executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/migrations/", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/migrations/", line 49, in __init__
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/migrations/", line 206, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/migrations/", line 61, in applied_migrations
    if self.has_table():
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/migrations/", line 44, in has_table
    return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/backends/base/", line 255, in cursor
    return self._cursor()
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/backends/base/", line 232, in _cursor
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/backends/base/", line 216, in ensure_connection
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/backends/base/", line 216, in ensure_connection
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/backends/base/", line 194, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/home/shane/.virtualenvs/django-rms/lib/python3.6/site-packages/django/db/backends/oracle/", line 208, in get_new_connection
    return Database.connect(self._connect_string(), **conn_params)
django.db.utils.DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified

After delving into the Oracle backend, I realized that Django is calling the cx_Oracle.connect() function like so: (django/db/backends/oracle/ line 208)


You can probably guess why cx_Oracle doesn't like this. As far as I can tell, there's no possible way to work around this bug without directly editing Django's (or cx_Oracle's) code. The following connection method works just fine:

Database.connect('valid_username', 'p@ssword', 'mydsn')

I should also mention that there have been others that have this issue. In my case, the bureaucracy at my company won't allow me to choose my own password, so fixing Django is my only option.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Note: See TracQuery for help on using queries.
Back to Top