Ticket #12742: file_upload.diff

File file_upload.diff, 2.3 KB (added by Sebastian Żurek, 9 years ago)
  • django/contrib/comments/forms.py

     
    2222    timestamp     = forms.IntegerField(widget=forms.HiddenInput)
    2323    security_hash = forms.CharField(min_length=40, max_length=40, widget=forms.HiddenInput)
    2424
    25     def __init__(self, target_object, data=None, initial=None):
     25    # use *args and **kwrgs as __init__args to allow super to work
     26    # properly and handle e.g. request.FILES in post handler
     27    def __init__(self, target_object, data=None, initial=None, *args, **kwargs):
    2628        self.target_object = target_object
    2729        if initial is None:
    2830            initial = {}
    2931        initial.update(self.generate_security_data())
    30         super(CommentSecurityForm, self).__init__(data=data, initial=initial)
     32        # super did not use *arts, and **kwargs,       
     33        super(CommentSecurityForm, self).__init__(data=data, initial=initial, *args, **kwargs)
    3134
    3235    def security_errors(self):
    3336        """Return just those errors associated with security"""
  • django/contrib/comments/views/comments.py

     
    6767    preview = "preview" in data
    6868
    6969    # Construct the comment form
    70     form = comments.get_form()(target, data=data)
     70    # NEW: added files=request.FILES support
     71    form = comments.get_form()(target, data=data, files=request.FILES)
    7172
    7273    # Check security information
    7374    if form.security_errors():
  • django/contrib/comments/templates/comments/form.html

     
    11{% load comments i18n %}
    2 <form action="{% comment_form_target %}" method="post">{% csrf_token %}
     2<form {% if form.is_multipart %} enctype="multipart/form-data" {% endif %} action="{% comment_form_target %}" method="post">{% csrf_token %}
    33  {% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
    44  {% for field in form %}
    55    {% if field.is_hidden %}
Back to Top