-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Hello! I am intereted in your project. I want to know is it possible to create such widget as in the picture below with your app? I have form (ProgramForm) with ModelMultipleChoiceField (function field). I want to allow the user to choose functions by selecting of checkboxes. I dont understand how separate levels with your app. Lets say as queryset I send all Group objects. How app know where is there chields? In other words I need something as in tree_widget.html. Check it pls. Also I am tring to test your app and have next error.
models.py:
class Group(models.Model):
name = models.CharField(_('Name'), max_length=250)
class Task(models.Model):
name = models.CharField(_('Name'), max_length=250)
group = models.ForeignKey(Group, on_delete=models.CASCADE)
class Function(models.Model):
name = models.CharField(_('Name'), max_length=250)
task = models.ForeignKey(Task, on_delete=models.CASCADE)
class Program(models.Model):
name = models.CharField(_('Name'), max_length=250)
function = models.ManyToManyField("Function")
forms.py:
class ProgramForm(forms.ModelForm):
function = forms.ModelMultipleChoiceField(queryset=Group.objects.none())
class Meta:
model = Program
fields = ('function',)
def __init__(self, all_groups, all_user_characteristics, *args, **kwargs):
super(RequirementForm, self).__init__(*args, **kwargs)
self.fields['function'].widget = FancyTreeWidget(queryset=all_group_tasks) # I take all Group objects from view
self.fields['function'].queryset = all_group_tasks
tree_widget.hml:
{% for group in groups %}
<p>{{ group }}</p>
{% for task in group.task_set.all %}
<p>{{ task }}</p>
{% for function in task.function_set.all %}
<p>
<input type="checkbox" name="option" value="{{ function }}">{{ function }}
</p>
{% endfor %}
{% endfor %}
{% endfor %}
Error:
Traceback (most recent call last):
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\commands\runserver.py", line 113, in inner_run
autoreload.raise_last_exception()
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\apps\registry.py", line 115, in populate
app_config.ready()
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\contrib\admin\apps.py", line 23, in ready
self.module.autodiscover()
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\contrib\admin\__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\Nurzhan\PycharmProjects\RMS\project\admin.py", line 4, in <module>
from .forms import MemberAdminForm
File "C:\Users\Nurzhan\PycharmProjects\RMS\project\forms.py", line 5, in <module>
from fancytree.widgets import FancyTreeWidget
File "C:\Users\Nurzhan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\fancytree\widgets.py", line 6, in <module>
from django.utils.encoding import force_unicode
ImportError: cannot import name 'force_unicode'
Well It seems like Python 3 didnt support force_unicode. Is it possible to use your app in Python 3?
Metadata
Metadata
Assignees
Labels
No labels
