Opened 17 years ago

Closed 17 years ago

Last modified 16 years ago

#5302 closed (duplicate)

unique and editinline bug

Reported by: patrick.lauber@… 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.

  1. resolver = urlresolvers.RegexURLResolver(r'/', urlconf)
  2. try:
  3. callback, callback_args, callback_kwargs = resolver.resolve(request.path) 69.
  4. # Apply view middleware
  5. for middleware_method in self._view_middleware:
  6. response = middleware_method(request, callback, callback_args, callback_kwargs) ...
  7. if response:
  8. return response 75.
  9. try:
  10. response = callback(request, *callback_args, callback_kwargs)
  11. 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
    1. settings.DEBUG = True 21.
    2. # get number of db queries before we do anything
    3. n = len(connection.queries) 24.
    4. # time the view
    5. start = time()
    6. response = view_func(request, *view_args, view_kwargs) ...
    7. totTime = time() - start 29.
    8. # compute the db time for the queries just run
    9. queries = len(connection.queries) - n
    10. if queries:
    11. dbTime = reduce(add, [float(qtime)
    ▶ Local vars Variable Value debug True n 1 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)}> self <divio.middleware.stats.StatsMiddleware object at 0x22ae230> settings <django.conf.LazySettings object at 0xea590> start 1188489635.296381 view_args (u'courses', u'coursecollection', u'1') view_func <function _checklogin at 0x2301c30> view_kwargs {}
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/contrib/admin/views/decorators.py in _checklogin
    1. def _checklogin(request, *args, kwargs):
    2. if request.user.is_authenticated() and request.user.is_staff:
    3. # The user is valid. Continue to the admin page.
    4. if 'post_data' in request.POST:
    5. # User must have re-authenticated through a different window
    6. # or tab.
    7. request.POST = _decode_post_data(request.POSTpost_data)
    8. return view_func(request, *args, kwargs) ... 56.
    9. 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.
    10. # If this isn't already the login page, display it.
    11. if LOGIN_FORM_KEY not in request.POST:
    12. if request.POST:
    ▶ 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 _wrapped_view_func at 0x2301bf0>
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/views/decorators/cache.py in _wrapped_view_func

32.

  1. def never_cache(view_func):
  2. """
  3. Decorator that adds headers to a response so that it will
  4. never be cached.
  5. """
  6. def _wrapped_view_func(request, *args, kwargs):
  7. response = view_func(request, *args, kwargs) ...
  8. add_never_cache_headers(response)
  9. return response
  10. 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.

  1. if request.POST:
  2. new_data = request.POST.copy() 328.
  3. if opts.has_field_type(models.FileField):
  4. new_data.update(request.FILES)

331.

  1. errors = manipulator.get_validation_errors(new_data) ...
  2. manipulator.do_html2python(new_data) 334.
  3. if not errors:
  4. new_object = manipulator.save(new_data)
  5. 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
    1. field.prepare(new_data) 55.
    2. def get_validation_errors(self, new_data):
    3. "Returns dictionary mapping field_names to error-message lists"
    4. errors = {}
    5. self.prepare(new_data)
    6. for field in self.fields:
    7. errors.update(field.get_validation_errors(new_data)) ...
    8. val_name = 'validate_%s' % field.field_name
    9. if hasattr(self, val_name):
    10. val = getattr(self, val_name)
    11. try:
    12. field.run_validator(new_data, val)
    13. except (validators.ValidationError, validators.CriticalValidationError), e:
    ▶ Local vars Variable Value errors {} field FormField "course.0.coda" 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 <django.db.models.manipulators.ChangeManipulator object at 0x2303df0> val_name u'validate_course.0.id'
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/oldforms/init.py in get_validation_errors
    1. errors = {}
    2. if self.is_required and not new_data.get(self.field_name, False):
    3. errors.setdefault(self.field_name, []).append(ugettext('This field is required.'))
    4. return errors
    5. try:
    6. for validator in self.validator_list:
    7. try:
    8. self.run_validator(new_data, validator) ...
    9. except validators.ValidationError, e:
    10. errors.setdefault(self.field_name, []).extend(e.messages)
    11. # If a CriticalValidationError is raised, ignore any other ValidationErrors
    12. # for this particular field
    13. except validators.CriticalValidationError, e:
    14. errors.setdefault(self.field_name, []).extend(e.messages)
    ▶ Local vars Variable Value errors {} 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/oldforms/init.py in run_validator

361.
362.

  1. def run_validator(self, new_data, validator):
  2. if self.is_required or new_data.get(self.field_name, False) or hasattr(validator, 'always_test'):
  3. if hasattr(self, 'requires_data_list'):
  4. validator(new_data.getlist(self.field_name), new_data)
  5. else:
  6. validator(new_data.get(self.field_name, ), new_data) ... 369.
  7. def get_validation_errors(self, new_data):
  8. errors = {}
  9. if self.is_required and not new_data.get(self.field_name, False):
  10. errors.setdefault(self.field_name, []).append(ugettext('This field is required.'))
  11. 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
    1. def curry(_curried_func, *args, kwargs):
    2. def _curried(*moreargs, morekwargs):
    3. return _curried_func(*(args+moreargs), dict(kwargs, morekwargs)) ...
    4. return _curried 5.
    5. def memoize(func, cache, num_args):
    6. """
    7. Wrap a function so that results for any argument tuple are stored in
    8. 'cache'. Note that the args to the function must be usable as dictionary
    ▶ Local vars Variable Value _curried_func <function manipulator_validator_unique at 0x12b6530> args (<django.db.models.fields.CharField object at 0x224a1f0>, <Options for Course>, <django.db.models.manipulators.ChangeManipulator object at 0x2303df0>) kwargs {} moreargs (u'dfs', <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']}>) morekwargs {}
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/fields/init.py in manipulator_validator_unique
    1. class FieldDoesNotExist(Exception):
    2. pass 39.
    3. def manipulator_validator_unique(f, opts, self, field_data, all_data):
    4. "Validates that the value is unique for this field."
    5. lookup_type = f.get_validator_unique_lookup_type()
    6. try:
    7. old_obj = self.manager.get({lookup_type: field_data}) ...
    8. except ObjectDoesNotExist:
    9. return
    10. if getattr(self, 'original_object', None) and self.original_object._get_pk_val() == old_obj._get_pk_val():
    11. return
    12. 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
    1. def distinct(self, *args, kwargs):
    2. return self.get_query_set().distinct(*args, kwargs) 64.
    3. def extra(self, *args, kwargs):
    4. return self.get_query_set().extra(*args, kwargs) 67.
    5. def get(self, *args, kwargs):
    6. return self.get_query_set().get(*args, kwargs) ... 70.
    7. def get_or_create(self, kwargs):
    8. return self.get_query_set().get_or_create(kwargs) 73.
    9. def create(self, kwargs):
    10. return self.get_query_set().create(kwargs)
    ▶ Local vars Variable Value args () kwargs {'codaexact': u'dfs'} self <django.db.models.manager.Manager object at 0x224a290>
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in get

253.

  1. def get(self, *args, kwargs):
  2. "Performs the SELECT and returns a single object matching the given keyword arguments."
  3. clone = self.filter(*args, kwargs)
  4. # clean up SQL by removing unneeded ORDER BY
  5. if not clone._order_by:
  6. clone._order_by = ()
  7. obj_list = list(clone) ...
  8. if len(obj_list) < 1:
  9. raise self.model.DoesNotExist, "%s matching query does not exist." % self.model._meta.object_name
  10. 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)
  11. return obj_list[0] 265.
  12. 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
    1. def repr(self):
    2. return repr(self._get_data()) 108.
    3. def len(self):
    4. return len(self._get_data()) 111.
    5. def iter(self):
    6. return iter(self._get_data()) ... 114.
    7. def getitem(self, k):
    8. "Retrieve an item or slice from the set of results."
    9. if not isinstance(k, (slice, int, long)):
    10. raise TypeError
    11. assert (not isinstance(k, slice) and (k >= 0)) \
    ▶ Local vars Variable Value self Error in formatting: Cannot resolve keyword 'coda' into field. Choices are: course, id, course_type, type, days, popup_text, info, prize
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in _get_data
    1. if (self._order_by is not None and len(self._order_by) > 0) and \
    2. (combined._order_by is None or len(combined._order_by) == 0):
    3. combined._order_by = self._order_by
    4. return combined 477.
    5. def _get_data(self):
    6. if self._result_cache is None:
    7. self._result_cache = list(self.iterator()) ...
    8. return self._result_cache 482.
    9. def _get_sql_clause(self):
    10. opts = self.model._meta 485.
    11. # Construct the fundamental parts of the query: SELECT X FROM Y WHERE Z.
    ▶ Local vars Variable Value self Error in formatting: Cannot resolve keyword 'coda' into field. Choices are: course, id, course_type, type, days, popup_text, info, prize
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in iterator
    1. ####################################
    2. # METHODS THAT DO DATABASE QUERIES #
    3. #################################### 175.
    4. def iterator(self):
    5. "Performs the SELECT database lookup of this QuerySet."
    6. try:
    7. select, sql, params = self._get_sql_clause() ...
    8. except EmptyResultSet:
    9. raise StopIteration 182.
    10. # self._select is a dictionary, and dictionaries' key order is
    11. # undefined, so we convert it to a list of tuples.
    12. extra_select = self._select.items()
    ▶ Local vars Variable Value self Error in formatting: Cannot resolve keyword 'coda' into field. Choices are: course, id, course_type, type, days, popup_text, info, prize
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in _get_sql_clause
    1. select = % (backend.quote_name(opts.db_table), backend.quote_name(f.column)) for f in opts.fields
    2. tables = [quote_only_if_word(t) for t in self._tables]
    3. joins = SortedDict()
    4. where = self._where[:]
    5. params = self._params[:] 492.
    6. # Convert self._filters into SQL.
    7. joins2, where2, params2 = self._filters.get_sql(opts) ...
    8. joins.update(joins2)
    9. where.extend(where2)
    10. params.extend(params2) 498.
    11. # Add additional tables and WHERE clauses based on select_related.
    12. if self._select_related:
    ▶ Local vars Variable Value f <django.db.models.fields.PositiveSmallIntegerField object at 0x2254c30> joins {} opts <Options for CourseCollection> params [] select ['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
    1. def init(self, *args):
    2. self.args = args 708.
    3. def get_sql(self, opts):
    4. joins, where, params = SortedDict(), [], []
    5. for val in self.args:
    6. try:
    7. joins2, where2, params2 = val.get_sql(opts) ...
    8. joins.update(joins2)
    9. where.extend(where2)
    10. params.extend(params2)
    11. except EmptyResultSet:
    12. if not isinstance(self, QOr):
    13. raise EmptyResultSet
    ▶ Local vars Variable Value joins {} joins2 {} opts <Options for CourseCollection> params [] params2 [] self <django.db.models.query.QAnd object at 0x231a0f0> val <django.db.models.query.Q object at 0x231a0d0> where [] where2 []
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in get_sql
    1. def and(self, other):
    2. return QAnd(self, other) 759.
    3. def or(self, other):
    4. return QOr(self, other) 762.
    5. def get_sql(self, opts):
    6. return parse_lookup(self.kwargs.items(), opts) ... 765.
    7. class QNot(Q):
    8. "Encapsulates NOT (...) queries as objects"
    9. def init(self, q):
    10. "Creates a negation of the q object passed in."
    11. self.q = q
    ▶ Local vars Variable Value opts <Options for CourseCollection> self <django.db.models.query.Q object at 0x231a0d0>
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py in parse_lookup
    1. # Interpret 'exact=None' as the sql '= NULL'; otherwise, reject
    2. # all uses of None as a query value.
    3. if lookup_type != 'exact':
    4. raise ValueError, "Cannot use None as a query value"
    5. elif callable(value):
    6. value = value()

920.

  1. joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts, opts.db_table, None) ...
  2. joins.update(joins2)
  3. where.extend(where2)
  4. params.extend(params2)
  5. return joins, where, params 926.
  6. class FieldFound(Exception):

▶ Local vars
Variable Value
joins
{}
kwarg
u'codaexact'
kwarg_items
[('coda
exact', 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
    1. except FieldFound: # Match found, loop has been shortcut.
    2. pass
    3. else: # No match found.
    4. choices = field_choices(current_opts.many_to_many, False) + \
    5. field_choices(current_opts.get_all_related_many_to_many_objects(), True) + \
    6. field_choices(current_opts.get_all_related_objects(), True) + \
    7. field_choices(current_opts.fields, False)
    8. raise TypeError, "Cannot resolve keyword '%s' into field. Choices are: %s" % (name, ", ".join(choices)) ... 1040.
    9. # Check whether an intermediate join is required between current_table
    10. # and new_table.
    11. if intermediate_table:
    12. joins[qn(current_table)] = (
    13. qn(intermediate_table), "LEFT OUTER JOIN", ▶ Local vars

}}}

Change History (2)

comment:1 by Simon G. <dev@…>, 17 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #565

comment:2 by anonymous, 16 years ago

lol :)) small error

Note: See TracTickets for help on using tickets.
Back to Top