Opened 11 years ago
Closed 11 years ago
#23412 closed Bug (invalid)
Unable to import django.forms.util.ValidationError
| Reported by: | Nathan Osman | Owned by: | nobody |
|---|---|---|---|
| Component: | Forms | Version: | 1.7 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I ran the following commands on a completely clean installation of Ubuntu Server 14.04.1:
apt-get install python-pip pip install Django
I then opened the Python interpreter and ran the following commands:
Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from django import forms >>> forms.util.ValidationError Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'util'
It would appear that django.forms.util is missing. This is very odd since I can confirm that the relevant file does indeed exist:
# cd /usr/local/lib/python2.7/dist-packages/django/forms # ls extras formsets.py forms.pyc models.py util.pyc widgets.py fields.py formsets.pyc __init__.py models.pyc utils.py widgets.pyc fields.pyc forms.py __init__.pyc util.py utils.pyc
I have confirmed this error on two other machines running Ubuntu 14.04. According to the contents of the file, the module is set to be removed in Django 1.9, so it should still work in Django 1.7.
Change History (2)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
ValidationError has to be imoprted from django.core.exceptions, and it is documented so for some time I think. Of course, you can theoratically import various names from each file where it is imported also, but we cannot guarantee that the imports will work over time. If the old import location were to be documented in a recent documentation version, that would be another story.
django.form.utilused to be defined as a side effect of all the imports indjango/forms/__init__.py.Since we don't import this module anymore, to prevent firing
DeprecatingWarnings, it's never assigned as a property to thedjango.formsmodule. You can validate this is the case by trying to accessforms.utilonce you explicitly importeddjango.forms.util.Since accessing
django.forms.utilwithout explicitly importing theutilmodule used to works only because of import side effects I'm tempted to mark this ticket as won't fix. I'm not even sure there's a way to lazily expose theutilmodule to support your case without triggering the deprecating warnings.