#5302 closed (duplicate)
unique and editinline bug
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | unique, edit_inline | |
Cc: | patrick.lauber@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
the following model can not be saved in admin:
class CourseCollection(models.Model): course_type=models.ForeignKey(CourseType) days=models.PositiveSmallIntegerField(_("Tage")) popup_text=models.TextField(_("Popup Text")) info=models.CharField(_("Zusatz Info"),maxlength=100) prize=models.PositiveSmallIntegerField(_("Preis")) class Admin: list_display = ('course_type','type','days','prize') list_filter = ('course_type','days','prize') search_fields = ('popup_text','info') class Meta: verbose_name=_('Kurs Gruppe') verbose_name_plural=_('Kurs Gruppen') def __unicode__(self): return "%s(%s)" %(self.course_type,unicode(self.type)) class Course(models.Model): course_collection=models.ForeignKey(CourseCollection,edit_inline=models.TABULAR,num_in_admin=40) code=models.CharField(_("Code"),maxlength=8,unique=True) location=models.ForeignKey(Location,core=True) start_date=models.DateField(_("Start Datum"),default=datetime.date.today) examination_date=models.DateField(_(u"Prüfungs Datum"),null=True,blank=True)
the problem lies with the code field in the Course model. As long as there is a unique=True it will raise the following exception:
{{
TypeError at /admin/courses/coursecollection/1/
Cannot resolve keyword 'coda' into field. Choices are: course, id, course_type, type, days, popup_text, info, prize
Request Method: POST
Request URL: http://localhost:8000/admin/courses/coursecollection/1/
Exception Type: TypeError
Exception Value: Cannot resolve keyword 'coda' into field. Choices are: course, id, course_type, type, days, popup_text, info, prize
Exception Location: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in lookup_inner, line 1039
Python Executable: /Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.5.1
Traceback (innermost last)
Switch to copy-and-paste view
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py in get_response
65.
- resolver = urlresolvers.RegexURLResolver(r'/', urlconf)
- try:
- callback, callback_args, callback_kwargs = resolver.resolve(request.path) 69.
- # Apply view middleware
- for middleware_method in self._view_middleware:
- response = middleware_method(request, callback, callback_args, callback_kwargs) ...
- if response:
- return response 75.
- try:
- response = callback(request, *callback_args, callback_kwargs)
- except Exception, e:
▶ Local vars
Variable Value
callback
<function _checklogin at 0x2301c30>
callback_args
(u'courses', u'coursecollection', u'1')
callback_kwargs
{}
debug
<module 'django.views.debug' from '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/views/debug.pyc'>
exceptions
<module 'django.core.exceptions' from '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/exceptions.pyc'>
mail_admins
<function mail_admins at 0x22a96b0>
middleware_method
<bound method StatsMiddleware.process_view of <divio.middleware.stats.StatsMiddleware object at 0x22ae230>>
request
<WSGIRequest GET:<MultiValueDict: {}>, POST:<MultiValueDict: {u'info': [u'Bei ungen\xfcgender Anzahl Anmeldungen werden die Kurse koordiniert.'], u'course.0.location': [u'1'], u'course.0.examination_date': [u''], u'course.1.examination_date': [u''], u'prize': [u'590'], u'course.1.start_date': [u'2007-08-30'], u'days': [u'12'], u'course_type': [u'1'], u'course.1.coda': [u'dsf'], u'course.0.id': [u'1'], u'course.1.id': [u''], u'course.1.location': [u'1'], u'popup_text': [u'12 Kursabende 19.00 - 21.30 h / 19.15 - 21.45 h\r\nzus\xe4tzlich 1 ganzt\xe4giges Meteoseminar Basis'], u'course.0.coda': [u'dfs'], u'type': [u'0'], u'course.0.start_date': [u'2007-08-30']}>, COOKIES:{'sessionid': '02ec2573a0cb5bcda106515624beb12b'}, META:{'ADMINMEDIA': '/Users/patricklauber/Documents/workspace/divio.django/httpdocs/admin_media:', 'CONTENT_LENGTH': '453', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'DJANGO_SETTINGS_MODULE': 'hoz.settings', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HOME': '/Users/patricklauber', 'HTTP_ACCEPT': 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'de-ch,de;q=0.8,en-us;q=0.5,en;q=0.3', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': 'sessionid=02ec2573a0cb5bcda106515624beb12b', 'HTTP_HOST': 'localhost:8000', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': 'http://localhost:8000/admin/courses/coursecollection/1/', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6', 'PATH': '/usr/local/Trolltech/Qt-4.3.0/bin:/Users/patricklauber/Documents/workspace/django/django/bin:/usr/local/mysql-5.0.37-osx10.4-i686/bin:/sw/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/bin:/sbin:/usr/bin:/usr/sbin', 'PATH_INFO': '/admin/courses/coursecollection/1/', 'PWD': '/Users/patricklauber/Documents/workspace/html.hoz.ch/py_src/hoz', 'PYTHONPATH': '..:/Users/patricklauber/Documents/workspace/divio.django/src/:/Users/patricklauber/Documents/workspace/divio.django/src:', 'QUERY_STRING': , 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_HOST': , 'REQUEST_METHOD': 'POST', 'RUN_MAIN': 'true', 'SCRIPT_NAME': , 'SECURITYSESSIONID': 'b96da0', 'SERVER_NAME': 'localhost\r', 'SERVER_PORT': '8000', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.5.1', 'SHELL': '/bin/bash', 'SHLVL': '1', 'TERM': 'xterm-new', 'TERM_PROGRAM': 'iTerm.app', 'TZ': 'Europe/Zurich', 'USER': 'patricklauber', '_': '/usr/local/bin/python', 'CF_USER_TEXT_ENCODING': '0x1F5:0:0', 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x130b0>, 'wsgi.file_wrapper': <class 'django.core.servers.basehttp.FileWrapper'>, 'wsgi.input': <socket._fileobject object at 0x1095f30>, 'wsgi.multiprocess': False, 'wsgi.multithread': True, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}>
resolver
<RegexURLResolver hoz.urls />
response
None
self
<django.core.handlers.wsgi.WSGIHandler object at 0x11aad70>
settings
<django.conf.LazySettings object at 0xea590>
urlconf
u'hoz.urls'
urlresolvers
<module 'django.core.urlresolvers' from '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.pyc'>
- /Users/patricklauber/Documents/workspace/divio.django/src/divio/middleware/stats.py in process_view
- settings.DEBUG = True 21.
- # get number of db queries before we do anything
- n = len(connection.queries) 24.
- # time the view
- start = time()
- response = view_func(request, *view_args, view_kwargs) ...
- totTime = time() - start 29.
- # compute the db time for the queries just run
- queries = len(connection.queries) - n
- if queries:
- dbTime = reduce(add, [float(qtime)
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/admin/views/decorators.py in _checklogin
- def _checklogin(request, *args, kwargs):
- if request.user.is_authenticated() and request.user.is_staff:
- # The user is valid. Continue to the admin page.
- if 'post_data' in request.POST:
- # User must have re-authenticated through a different window
- # or tab.
- request.POST = _decode_post_data(request.POSTpost_data)
- return view_func(request, *args, kwargs) ... 56.
- assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." 58.
- # If this isn't already the login page, display it.
- if LOGIN_FORM_KEY not in request.POST:
- if request.POST:
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/views/decorators/cache.py in _wrapped_view_func
32.
- def never_cache(view_func):
- """
- Decorator that adds headers to a response so that it will
- never be cached.
- """
- def _wrapped_view_func(request, *args, kwargs):
- response = view_func(request, *args, kwargs) ...
- add_never_cache_headers(response)
- return response
- return _wrapped_view_func
▶ Local vars
Variable Value
args
(u'courses', u'coursecollection', u'1')
kwargs
{}
request
<WSGIRequest GET:<MultiValueDict: {}>, POST:<MultiValueDict: {u'info': [u'Bei ungen\xfcgender Anzahl Anmeldungen werden die Kurse koordiniert.'], u'course.0.location': [u'1'], u'course.0.examination_date': [u''], u'course.1.examination_date': [u''], u'prize': [u'590'], u'course.1.start_date': [u'2007-08-30'], u'days': [u'12'], u'course_type': [u'1'], u'course.1.coda': [u'dsf'], u'course.0.id': [u'1'], u'course.1.id': [u''], u'course.1.location': [u'1'], u'popup_text': [u'12 Kursabende 19.00 - 21.30 h / 19.15 - 21.45 h\r\nzus\xe4tzlich 1 ganzt\xe4giges Meteoseminar Basis'], u'course.0.coda': [u'dfs'], u'type': [u'0'], u'course.0.start_date': [u'2007-08-30']}>, COOKIES:{'sessionid': '02ec2573a0cb5bcda106515624beb12b'}, META:{'ADMINMEDIA': '/Users/patricklauber/Documents/workspace/divio.django/httpdocs/admin_media:', 'CONTENT_LENGTH': '453', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'DJANGO_SETTINGS_MODULE': 'hoz.settings', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HOME': '/Users/patricklauber', 'HTTP_ACCEPT': 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'de-ch,de;q=0.8,en-us;q=0.5,en;q=0.3', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': 'sessionid=02ec2573a0cb5bcda106515624beb12b', 'HTTP_HOST': 'localhost:8000', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': 'http://localhost:8000/admin/courses/coursecollection/1/', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6', 'PATH': '/usr/local/Trolltech/Qt-4.3.0/bin:/Users/patricklauber/Documents/workspace/django/django/bin:/usr/local/mysql-5.0.37-osx10.4-i686/bin:/sw/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/bin:/sbin:/usr/bin:/usr/sbin', 'PATH_INFO': '/admin/courses/coursecollection/1/', 'PWD': '/Users/patricklauber/Documents/workspace/html.hoz.ch/py_src/hoz', 'PYTHONPATH': '..:/Users/patricklauber/Documents/workspace/divio.django/src/:/Users/patricklauber/Documents/workspace/divio.django/src:', 'QUERY_STRING': , 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_HOST': , 'REQUEST_METHOD': 'POST', 'RUN_MAIN': 'true', 'SCRIPT_NAME': , 'SECURITYSESSIONID': 'b96da0', 'SERVER_NAME': 'localhost\r', 'SERVER_PORT': '8000', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.5.1', 'SHELL': '/bin/bash', 'SHLVL': '1', 'TERM': 'xterm-new', 'TERM_PROGRAM': 'iTerm.app', 'TZ': 'Europe/Zurich', 'USER': 'patricklauber', '_': '/usr/local/bin/python', 'CF_USER_TEXT_ENCODING': '0x1F5:0:0', 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x130b0>, 'wsgi.file_wrapper': <class 'django.core.servers.basehttp.FileWrapper'>, 'wsgi.input': <socket._fileobject object at 0x1095f30>, 'wsgi.multiprocess': False, 'wsgi.multithread': True, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}>
view_func
<function change_stage at 0x2301bb0>
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/admin/views/main.py in change_stage
325.
- if request.POST:
- new_data = request.POST.copy() 328.
- if opts.has_field_type(models.FileField):
- new_data.update(request.FILES)
331.
- errors = manipulator.get_validation_errors(new_data) ...
- manipulator.do_html2python(new_data) 334.
- if not errors:
- new_object = manipulator.save(new_data)
- pk_value = new_object._get_pk_val()
338.
▶ Local vars
Variable Value
app_label
u'courses'
manipulator
<django.db.models.manipulators.ChangeManipulator object at 0x2303df0>
model
<class 'hoz.courses.models.CourseCollection'>
model_name
u'coursecollection'
new_data
<MultiValueDict: {u'info': [u'Bei ungen\xfcgender Anzahl Anmeldungen werden die Kurse koordiniert.'], u'course.0.location': [u'1'], u'course.0.examination_date': [u''], u'course.1.examination_date': [u''], u'course.1.start_date': [u'2007-08-30'], u'days': [u'12'], u'course_type': [u'1'], u'course.0.start_date': [u'2007-08-30'], u'course.1.coda': [u'dsf'], u'course.0.id': [u'1'], u'course.1.id': [u''], u'course.1.location': [u'1'], u'popup_text': [u'12 Kursabende 19.00 - 21.30 h / 19.15 - 21.45 h\r\nzus\xe4tzlich 1 ganzt\xe4giges Meteoseminar Basis'], u'course.0.coda': [u'dfs'], u'type': [u'0'], u'prize': [u'590']}>
object_id
u'1'
opts
<Options for CourseCollection>
request
<WSGIRequest GET:<MultiValueDict: {}>, POST:<MultiValueDict: {u'info': [u'Bei ungen\xfcgender Anzahl Anmeldungen werden die Kurse koordiniert.'], u'course.0.location': [u'1'], u'course.0.examination_date': [u''], u'course.1.examination_date': [u''], u'prize': [u'590'], u'course.1.start_date': [u'2007-08-30'], u'days': [u'12'], u'course_type': [u'1'], u'course.1.coda': [u'dsf'], u'course.0.id': [u'1'], u'course.1.id': [u''], u'course.1.location': [u'1'], u'popup_text': [u'12 Kursabende 19.00 - 21.30 h / 19.15 - 21.45 h\r\nzus\xe4tzlich 1 ganzt\xe4giges Meteoseminar Basis'], u'course.0.coda': [u'dfs'], u'type': [u'0'], u'course.0.start_date': [u'2007-08-30']}>, COOKIES:{'sessionid': '02ec2573a0cb5bcda106515624beb12b'}, META:{'ADMINMEDIA': '/Users/patricklauber/Documents/workspace/divio.django/httpdocs/admin_media:', 'CONTENT_LENGTH': '453', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'DJANGO_SETTINGS_MODULE': 'hoz.settings', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HOME': '/Users/patricklauber', 'HTTP_ACCEPT': 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'de-ch,de;q=0.8,en-us;q=0.5,en;q=0.3', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': 'sessionid=02ec2573a0cb5bcda106515624beb12b', 'HTTP_HOST': 'localhost:8000', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': 'http://localhost:8000/admin/courses/coursecollection/1/', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6', 'PATH': '/usr/local/Trolltech/Qt-4.3.0/bin:/Users/patricklauber/Documents/workspace/django/django/bin:/usr/local/mysql-5.0.37-osx10.4-i686/bin:/sw/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/bin:/sbin:/usr/bin:/usr/sbin', 'PATH_INFO': '/admin/courses/coursecollection/1/', 'PWD': '/Users/patricklauber/Documents/workspace/html.hoz.ch/py_src/hoz', 'PYTHONPATH': '..:/Users/patricklauber/Documents/workspace/divio.django/src/:/Users/patricklauber/Documents/workspace/divio.django/src:', 'QUERY_STRING': , 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_HOST': , 'REQUEST_METHOD': 'POST', 'RUN_MAIN': 'true', 'SCRIPT_NAME': , 'SECURITYSESSIONID': 'b96da0', 'SERVER_NAME': 'localhost\r', 'SERVER_PORT': '8000', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.5.1', 'SHELL': '/bin/bash', 'SHLVL': '1', 'TERM': 'xterm-new', 'TERM_PROGRAM': 'iTerm.app', 'TZ': 'Europe/Zurich', 'USER': 'patricklauber', '_': '/usr/local/bin/python', 'CF_USER_TEXT_ENCODING': '0x1F5:0:0', 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x130b0>, 'wsgi.file_wrapper': <class 'django.core.servers.basehttp.FileWrapper'>, 'wsgi.input': <socket._fileobject object at 0x1095f30>, 'wsgi.multiprocess': False, 'wsgi.multithread': True, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}>
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/oldforms/init.py in get_validation_errors
- field.prepare(new_data) 55.
- def get_validation_errors(self, new_data):
- "Returns dictionary mapping field_names to error-message lists"
- errors = {}
- self.prepare(new_data)
- for field in self.fields:
- errors.update(field.get_validation_errors(new_data)) ...
- val_name = 'validate_%s' % field.field_name
- if hasattr(self, val_name):
- val = getattr(self, val_name)
- try:
- field.run_validator(new_data, val)
- except (validators.ValidationError, validators.CriticalValidationError), e:
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/oldforms/init.py in get_validation_errors
- errors = {}
- if self.is_required and not new_data.get(self.field_name, False):
- errors.setdefault(self.field_name, []).append(ugettext('This field is required.'))
- return errors
- try:
- for validator in self.validator_list:
- try:
- self.run_validator(new_data, validator) ...
- except validators.ValidationError, e:
- errors.setdefault(self.field_name, []).extend(e.messages)
- # If a CriticalValidationError is raised, ignore any other ValidationErrors
- # for this particular field
- except validators.CriticalValidationError, e:
- errors.setdefault(self.field_name, []).extend(e.messages)
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/oldforms/init.py in run_validator
361.
362.
- def run_validator(self, new_data, validator):
- if self.is_required or new_data.get(self.field_name, False) or hasattr(validator, 'always_test'):
- if hasattr(self, 'requires_data_list'):
- validator(new_data.getlist(self.field_name), new_data)
- else:
- validator(new_data.get(self.field_name, ), new_data) ... 369.
- def get_validation_errors(self, new_data):
- errors = {}
- if self.is_required and not new_data.get(self.field_name, False):
- errors.setdefault(self.field_name, []).append(ugettext('This field is required.'))
- return errors
▶ Local vars
Variable Value
new_data
<MultiValueDict: {u'info': [u'Bei ungen\xfcgender Anzahl Anmeldungen werden die Kurse koordiniert.'], u'course.0.location': [u'1'], u'course.0.examination_date': [u''], u'course.1.examination_date': [u''], u'course.1.start_date': [u'2007-08-30'], u'days': [u'12'], u'course_type': [u'1'], u'course.0.start_date': [u'2007-08-30'], u'course.1.coda': [u'dsf'], u'course.0.id': [u'1'], u'course.1.id': [u''], u'course.1.location': [u'1'], u'popup_text': [u'12 Kursabende 19.00 - 21.30 h / 19.15 - 21.45 h\r\nzus\xe4tzlich 1 ganzt\xe4giges Meteoseminar Basis'], u'course.0.coda': [u'dfs'], u'type': [u'0'], u'prize': [u'590']}>
self
FormField "course.0.coda"
validator
<function _curried at 0x2304270>
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/utils/functional.py in _curried
- def curry(_curried_func, *args, kwargs):
- def _curried(*moreargs, morekwargs):
- return _curried_func(*(args+moreargs), dict(kwargs, morekwargs)) ...
- return _curried 5.
- def memoize(func, cache, num_args):
- """
- Wrap a function so that results for any argument tuple are stored in
- 'cache'. Note that the args to the function must be usable as dictionary
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/fields/init.py in manipulator_validator_unique
- class FieldDoesNotExist(Exception):
- pass 39.
- def manipulator_validator_unique(f, opts, self, field_data, all_data):
- "Validates that the value is unique for this field."
- lookup_type = f.get_validator_unique_lookup_type()
- try:
- old_obj = self.manager.get({lookup_type: field_data}) ...
- except ObjectDoesNotExist:
- return
- if getattr(self, 'original_object', None) and self.original_object._get_pk_val() == old_obj._get_pk_val():
- return
- raise validators.ValidationError, _("%(optname)s with this %(fieldname)s already exists.") % {'optname': capfirst(opts.verbose_name), 'fieldname': f.verbose_name}
50.
▶ Local vars
Variable Value
all_data
<MultiValueDict: {u'info': [u'Bei ungen\xfcgender Anzahl Anmeldungen werden die Kurse koordiniert.'], u'course.0.location': [u'1'], u'course.0.examination_date': [u''], u'course.1.examination_date': [u''], u'course.1.start_date': [u'2007-08-30'], u'days': [u'12'], u'course_type': [u'1'], u'course.0.start_date': [u'2007-08-30'], u'course.1.coda': [u'dsf'], u'course.0.id': [u'1'], u'course.1.id': [u''], u'course.1.location': [u'1'], u'popup_text': [u'12 Kursabende 19.00 - 21.30 h / 19.15 - 21.45 h\r\nzus\xe4tzlich 1 ganzt\xe4giges Meteoseminar Basis'], u'course.0.coda': [u'dfs'], u'type': [u'0'], u'prize': [u'590']}>
f
<django.db.models.fields.CharField object at 0x224a1f0>
field_data
u'dfs'
lookup_type
u'codaexact'
opts
<Options for Course>
self
<django.db.models.manipulators.ChangeManipulator object at 0x2303df0>
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/manager.py in get
- def distinct(self, *args, kwargs):
- return self.get_query_set().distinct(*args, kwargs) 64.
- def extra(self, *args, kwargs):
- return self.get_query_set().extra(*args, kwargs) 67.
- def get(self, *args, kwargs):
- return self.get_query_set().get(*args, kwargs) ... 70.
- def get_or_create(self, kwargs):
- return self.get_query_set().get_or_create(kwargs) 73.
- def create(self, kwargs):
- return self.get_query_set().create(kwargs)
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in get
253.
- def get(self, *args, kwargs):
- "Performs the SELECT and returns a single object matching the given keyword arguments."
- clone = self.filter(*args, kwargs)
- # clean up SQL by removing unneeded ORDER BY
- if not clone._order_by:
- clone._order_by = ()
- obj_list = list(clone) ...
- if len(obj_list) < 1:
- raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name
- assert len(obj_list) == 1, "get() returned more than one %s -- it returned %s! Lookup parameters were %s" % (self.model._meta.object_name, len(obj_list), kwargs)
- return obj_list[0] 265.
- def create(self, kwargs):
▶ Local vars
Variable Value
args
()
clone
Error in formatting: Cannot resolve keyword 'coda' into field. Choices are: course, id, course_type, type, days, popup_text, info, prize
kwargs
{'codaexact': u'dfs'}
self
[<CourseCollection: Hochseescheinkurse in der Schweiz(0)>]
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in iter
- def repr(self):
- return repr(self._get_data()) 108.
- def len(self):
- return len(self._get_data()) 111.
- def iter(self):
- return iter(self._get_data()) ... 114.
- def getitem(self, k):
- "Retrieve an item or slice from the set of results."
- if not isinstance(k, (slice, int, long)):
- raise TypeError
- assert (not isinstance(k, slice) and (k >= 0)) \
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in _get_data
- if (self._order_by is not None and len(self._order_by) > 0) and \
- (combined._order_by is None or len(combined._order_by) == 0):
- combined._order_by = self._order_by
- return combined 477.
- def _get_data(self):
- if self._result_cache is None:
- self._result_cache = list(self.iterator()) ...
- return self._result_cache 482.
- def _get_sql_clause(self):
- opts = self.model._meta 485.
- # Construct the fundamental parts of the query: SELECT X FROM Y WHERE Z.
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in iterator
- ####################################
- # METHODS THAT DO DATABASE QUERIES #
- #################################### 175.
- def iterator(self):
- "Performs the SELECT database lookup of this QuerySet."
- try:
- select, sql, params = self._get_sql_clause() ...
- except EmptyResultSet:
- raise StopIteration 182.
- # self._select is a dictionary, and dictionaries' key order is
- # undefined, so we convert it to a list of tuples.
- extra_select = self._select.items()
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in _get_sql_clause
- select = % (backend.quote_name(opts.db_table), backend.quote_name(f.column)) for f in opts.fields
- tables = [quote_only_if_word(t) for t in self._tables]
- joins = SortedDict()
- where = self._where[:]
- params = self._params[:] 492.
- # Convert self._filters into SQL.
- joins2, where2, params2 = self._filters.get_sql(opts) ...
- joins.update(joins2)
- where.extend(where2)
- params.extend(params2) 498.
- # Add additional tables and WHERE clauses based on select_related.
- if self._select_related:
courses_coursecollection
.id
', 'courses_coursecollection
.course_type_id
', 'courses_coursecollection
.type
', 'courses_coursecollection
.days
', 'courses_coursecollection
.popup_text
', 'courses_coursecollection
.info
', 'courses_coursecollection
.prize
'] self Error in formatting: Cannot resolve keyword 'coda' into field. Choices are: course, id, course_type, type, days, popup_text, info, prize tables [] where [] - /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in get_sql
- def init(self, *args):
- self.args = args 708.
- def get_sql(self, opts):
- joins, where, params = SortedDict(), [], []
- for val in self.args:
- try:
- joins2, where2, params2 = val.get_sql(opts) ...
- joins.update(joins2)
- where.extend(where2)
- params.extend(params2)
- except EmptyResultSet:
- if not isinstance(self, QOr):
- raise EmptyResultSet
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in get_sql
- def and(self, other):
- return QAnd(self, other) 759.
- def or(self, other):
- return QOr(self, other) 762.
- def get_sql(self, opts):
- return parse_lookup(self.kwargs.items(), opts) ... 765.
- class QNot(Q):
- "Encapsulates NOT (...) queries as objects"
- def init(self, q):
- "Creates a negation of the q object passed in."
- self.q = q
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in parse_lookup
- # Interpret 'exact=None' as the sql '= NULL'; otherwise, reject
- # all uses of None as a query value.
- if lookup_type != 'exact':
- raise ValueError, "Cannot use None as a query value"
- elif callable(value):
- value = value()
920.
- joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts, opts.db_table, None) ...
- joins.update(joins2)
- where.extend(where2)
- params.extend(params2)
- return joins, where, params 926.
- class FieldFound(Exception):
▶ Local vars
Variable Value
joins
{}
kwarg
u'codaexact'
kwarg_items
[('codaexact', u'dfs')]
lookup_type
u'exact'
opts
<Options for CourseCollection>
params
[]
path
[]
value
u'dfs'
where
[]
- /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in lookup_inner
- except FieldFound: # Match found, loop has been shortcut.
- pass
- else: # No match found.
- choices = field_choices(current_opts.many_to_many, False) + \
- field_choices(current_opts.get_all_related_many_to_many_objects(), True) + \
- field_choices(current_opts.get_all_related_objects(), True) + \
- field_choices(current_opts.fields, False)
- raise TypeError, "Cannot resolve keyword '%s' into field. Choices are: %s" % (name, ", ".join(choices)) ... 1040.
- # Check whether an intermediate join is required between current_table
- # and new_table.
- if intermediate_table:
- joins[qn(current_table)] = (
- qn(intermediate_table), "LEFT OUTER JOIN", ▶ Local vars
}}}
Duplicate of #565