Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy.deepcopy(field) (Django 1.8.2, Python 2.7.6, on line 31) #21

Closed
alejandroMA opened this issue Jun 29, 2015 · 4 comments
Closed

copy.deepcopy(field) (Django 1.8.2, Python 2.7.6, on line 31) #21

alejandroMA opened this issue Jun 29, 2015 · 4 comments

Comments

@alejandroMA
Copy link

So i was getting a weird bug, the template would say:

  • "A server error occurred. Please contact the administrator."

And in the terminal (running the development server):

  • A big stack of errors (you know normal python error).
  • (i'll place the stack at the end of the issue).

Any way, problem appear when using the render_field tag:

  • If use alone with no attr (attr="value"), everything works perfectly.
  • But if you place any attr, it breaks.

Digging in i found the problem on widget_tweaks/templatetags/widget_tweaks.py (line 26, 31):

  • i simply commented those lines and everything works perfectly once again :)
# if not PY26:
    # # See https://bugs.python.org/issue1515.
    # # It is OK to not do it in Python 2.6 because
    # # Django versions which require deepcopy here (1.7+)
    # # don't support Python 2.6 anyways.
    # field = copy.deepcopy(field) 

(doble comment :P)

So the comment says Django (1.7+), but i think there should be a second condition because it looks like in some newer version of Django, that statement stopped working.

My configuration:

  • virtualenv
  • Django 1.8.2
  • Python 2.7.6
  • Mac Os 10.10
  • widget_tweaks 1.4

Thanks for reading! 👍

Ok, terminal stack trace:

Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
    response = self.get_response(request)
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 261, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/views/debug.py", line 97, in technical_500_response
    html = reporter.get_traceback_html()
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/views/debug.py", line 383, in get_traceback_html
    c = Context(self.get_traceback_data(), use_l10n=False)
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/views/debug.py", line 328, in get_traceback_data
    frames = self.get_traceback_frames()
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/views/debug.py", line 501, in get_traceback_frames
    'vars': self.filter.get_traceback_frame_variables(self.request, tb.tb_frame),
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/views/debug.py", line 234, in get_traceback_frame_variables
    cleansed[name] = self.cleanse_special_types(request, value)
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/views/debug.py", line 191, in cleanse_special_types
    value = self.get_request_repr(value)
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/views/debug.py", line 122, in get_request_repr
    return build_request_repr(request, POST_override=self.get_post_parameters(request))
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/views/debug.py", line 186, in get_post_parameters
    return request.POST
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 137, in _get_post
    self._load_post_and_files()
  File "/Users/alejandro/Documents/pythonDev/seeds/env/lib/python2.7/site-packages/django/http/request.py", line 246, in _load_post_and_files
    if self.method != 'POST':
AttributeError: 'WSGIRequest' object has no attribute 'method'
[29/Jun/2015 13:54:09]"GET / HTTP/1.1" 500 59
@kmike
Copy link
Collaborator

kmike commented Jun 29, 2015

Could you try it with django-widget-tweaks 1.4.1?

@alejandroMA
Copy link
Author

Just upgraded it with pip, it works like a charm :)
Thanks 👍

@kmike
Copy link
Collaborator

kmike commented Jun 29, 2015

sorry for the troubles!

@alejandroMA
Copy link
Author

No worries 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants