agateblue / agateblue/django-dynamic-preferences

FilePathField not supported?

Đang mở
#203 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
documentation help wanted
Ngôn ngữ chính
Python
Star
359
Fork
86
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hello,

I'm trying to call a FilePathField model into the FilePreference (I also tried BasePreference) class without success, here is my code in the dynamic_preferences_registry.py:

```
from django.db.models import FilePathField

@global_preferences_registry.register
class Search_Results_Directory(FilePreference):
name = 'Search_Results_Directory'
verbose_name = 'Search Results Directory'
default = '../search-results/'
required = True
# Make it a folder
field_class = FilePathField(path=default)
```

This is the error I get:
![Screenshot_2020-01-31_13-27-17](https://user-images.githubusercontent.com/4020546/73564390-711a7d80-442d-11ea-9813-9897cfe67afc.png)

```
File "/home/francois/Desktop/KiCad/kicad-part-manager/web-app/kicad_librarian/views.py", line 15, in SettingsURL
form = global_preference_form_builder()
File "/home/francois/.local/lib/python3.8/site-packages/dynamic_preferences/forms.py", line 126, in global_preference_form_builder
return preference_form_builder(GlobalPreferenceForm, preferences, **kwargs)
File "/home/francois/.local/lib/python3.8/site-packages/dynamic_preferences/forms.py", line 107, in preference_form_builder
f = preference.field
File "/home/francois/.local/lib/python3.8/site-packages/dynamic_preferences/types.py", line 76, in field
return self.setup_field()
File "/home/francois/.local/lib/python3.8/site-packages/dynamic_preferences/types.py", line 82, in setup_field
return field_class(**field_kwargs)
TypeError: 'FilePathField' object is not callable
```

Is there a workaround? I would like the user to be able to select a directory, not a file.

Thank you,
Francois

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.