un1t / django-file-resubmit

It remembers selected files in form on validation errors.
76 stars 39 forks source link

Django 1.11 AttributeError: type object 'ClearableFileInput' has no attribute 'template_with_initial' #16

Closed pmalmgren closed 7 years ago

pmalmgren commented 7 years ago

Hello, thank you for maintaining this package! 😄

I have been upgrading one of my projects to the 1.11 pre-release, and I've noticed that file_resubmit/widgets.py is having the following error:

  File "/Users/pmalmgren/code/project-dj1.11/project/forms.py", line 26, in <module>
    from file_resubmit.admin import AdminResubmitFileWidget
  File "/Users/pmalmgren/code/project-dj1.11/ve/lib/python2.7/site-packages/file_resubmit/admin.py", line 14, in <module>
    from .widgets import ResubmitBaseWidget, ResubmitFileWidget
  File "/Users/pmalmgren/code/project-dj1.11/ve/lib/python2.7/site-packages/file_resubmit/widgets.py", line 59, in <module>
    class ResubmitFileWidget(ResubmitBaseWidget):
  File "/Users/pmalmgren/code/project-dj1.11/ve/lib/python2.7/site-packages/file_resubmit/widgets.py", line 60, in ResubmitFileWidget
    template_with_initial = ClearableFileInput.template_with_initial
AttributeError: type object 'ClearableFileInput' has no attribute 'template_with_initial'

Taking a look at the 1.11 release widgets.py, it looks like template_with_initial and template_with_clear have been removed from the ClearableFileInput class.

maddencs commented 7 years ago

Hi, I'm going through trying to upgrade our app to Django 1.11 and came across the same bug. What I did was override the ClearableFileInput __init__ method to check the Django version before setting those attributes. I forked the branch, which you can clone from my repo if you'd like. I've created a pull request for my fix, too.

maddencs commented 7 years ago

I've now provided an alternate fix, because I couldn't decide which way was better. Here's the branch on my fork with the other method of fixing it where I used a try/except statement instead of calling django.get_version() and added some @property and setter methods for the removed fields. I figure this might provide better compatibility.

timonweb commented 7 years ago

@maddencs I hope your fix will get merged in but it looks like project maintainer isn't here. Ilya @un1t please let us know if you're still supporting this project or should we fork it.

un1t commented 7 years ago

Hi, guys! Sorry for not responding so long. If you interested I may give you permission for this repo and pipy also.

un1t commented 7 years ago

@maddencs, would you like to maintain this project?

timonweb commented 7 years ago

@un1t let's wait for @maddencs, if he won't take it, I'd like to maintain this project.

maddencs commented 7 years ago

Good morning. I'll maintain the project. I'm not going anywhere. :) Plus, my coworker has some improvements he'd like to add, as well.

un1t commented 7 years ago

@maddencs, I sent invite. Please check your email.

un1t commented 7 years ago

@maddencs, what is your name on pypi?

maddencs commented 7 years ago

Thanks, Ilya. My pypi name is csmadden.

un1t commented 7 years ago

I added you to pypi. Let me know if you need travis or something else.

maddencs commented 7 years ago

Thanks, Ilya. Still waking up, but I'll work on this later today.

maddencs commented 7 years ago

New version(0.5.1) has been pushed to PyPI. Closing issue. Let me know if you have any further problems. I'll look at the other open issues later this weekend, unless someone else comes by and feels like resolving them...