Git Product home page Git Product logo

django-echoices's People

Contributors

mbourqui avatar vdboor avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

django-echoices's Issues

License forbids usage by many projects

Most of Python's libraries are BSD/MIT licensed for a reason: we can freely use each others code.

This project is GPLv3 licensed, meaning any project that uses this library MUST published under GPLv3 too. I also have to open all my website and application sources by using this library. Is this wat you consciously intended, or was that an accidental mistake?

Since we're the only copyright holders of this project, you can still freely change the license if you wish.

TypeError: unhashable type: 'EOrderedChoice'

Occurs when wanting to manually add a new object through the admin (while accessing someobject/add/).

Traceback (most recent call last):
[...]
  File "/usr/local/lib/python3.5/site-packages/django/template/defaulttags.py", line 315, in render
    return nodelist.render(context)
  File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 994, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.5/site-packages/django/template/defaulttags.py", line 315, in render
    return nodelist.render(context)
  File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 994, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 961, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 1044, in render
    output = self.filter_expression.resolve(context)
  File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 711, in resolve
    obj = self.var.resolve(context)
  File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 852, in resolve
    value = self._resolve_lookup(context)
  File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 915, in _resolve_lookup
    current = current()
  File "/usr/local/lib/python3.5/site-packages/django/contrib/admin/helpers.py", line 227, in contents
    result_repr = display_for_field(value, f, self.empty_value_display)
  File "/usr/local/lib/python3.5/site-packages/django/contrib/admin/utils.py", line 387, in display_for_field
    return dict(field.flatchoices).get(value, empty_value_display)
TypeError: unhashable type: 'EOrderedChoice'

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Live tests

  • Forms
  • admin/publications_bootstrap/publication/?status__exact=[value]

EChoiceField

merge CharEChoiceField and IntegerEChoiceField

Show label in admin model change list

The value/label of the EChoice is not shown, but '-' instead.

Potential Traceback:

[...]
File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 852, in resolve
File "/usr/local/lib/python3.5/site-packages/django/contrib/admin/helpers.py", line 227, in contents
File "/usr/local/lib/python3.5/site-packages/django/contrib/admin/utils.py", line 387, in display_for_field
def display_for_field(value, field, empty_value_display):
    from django.contrib.admin.templatetags.admin_list import _boolean_icon
    if getattr(field, 'flatchoices', None):
         return dict(field.flatchoices).get(value, empty_value_display)

where

value = <EChoice.NAME: value>
field = <echoices.fields.EChoiceField: field_name>
field.flatchoices = [(value, 'label')]
empty_value_display = django.utils.safestring.SafeText('-')

ValueError: invalid literal for int() with base 10: ''

Traceback (most recent call last):
[...]
  File "/usr/local/lib/python3.5/site-packages/django/forms/forms.py", line 169, in is_valid
    return self.is_bound and not self.errors
  File "/usr/local/lib/python3.5/site-packages/django/forms/forms.py", line 161, in errors
    self.full_clean()
  File "/usr/local/lib/python3.5/site-packages/django/forms/forms.py", line 372, in full_clean
    self._post_clean()
  File "/usr/local/lib/python3.5/site-packages/django/forms/models.py", line 398, in _post_clean
    self.instance.full_clean(exclude=exclude, validate_unique=False)
  File "/usr/local/lib/python3.5/site-packages/django/db/models/base.py", line 1210, in full_clean
    self.clean_fields(exclude=exclude)
  File "/usr/local/lib/python3.5/site-packages/django/db/models/base.py", line 1252, in clean_fields
    setattr(self, f.attname, f.clean(raw_value, self))
  File "/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 592, in clean
    self.run_validators(value)
  File "/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 538, in run_validators
    if value in self.empty_values:
  File "/usr/local/lib/python3.5/site-packages/echoices/enums.py", line 252, in __eq__
    return self.value == self.coerce(other)
  File "/usr/local/lib/python3.5/site-packages/echoices/enums.py", line 231, in coerce
    return cls.__value_type_(other)
ValueError: invalid literal for int() with base 10: ''

'str' object has no attribute 'value' in get_prep_value

File "/usr/local/lib/python3.5/site-packages/echoices/fields.py" in get_prep_value
63. return value.value

Exception Type: AttributeError at /admin/publications_bootstrap/publication/
Exception Value: 'str' object has no attribute 'value'

Form not processing EChoice enum

Actually, usgin a form generates the following error:
Select a valid choice. EChoice.FIELD is not one of the available choices.

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Traceback (most recent call last):
[...]
  File "/usr/local/lib/python3.5/site-packages/django/forms/forms.py", line 169, in is_valid
    return self.is_bound and not self.errors
  File "/usr/local/lib/python3.5/site-packages/django/forms/forms.py", line 161, in errors
    self.full_clean()
  File "/usr/local/lib/python3.5/site-packages/django/forms/forms.py", line 372, in full_clean
    self._post_clean()
  File "/usr/local/lib/python3.5/site-packages/django/forms/models.py", line 398, in _post_clean
    self.instance.full_clean(exclude=exclude, validate_unique=False)
  File "/usr/local/lib/python3.5/site-packages/django/db/models/base.py", line 1210, in full_clean
    self.clean_fields(exclude=exclude)
  File "/usr/local/lib/python3.5/site-packages/django/db/models/base.py", line 1252, in clean_fields
    setattr(self, f.attname, f.clean(raw_value, self))
  File "/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 592, in clean
    self.run_validators(value)
  File "/usr/local/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 538, in run_validators
    if value in self.empty_values:
  File "/usr/local/lib/python3.5/site-packages/echoices/enums.py", line 251, in __eq__
    return self.value == self.coerce(other)
  File "/usr/local/lib/python3.5/site-packages/echoices/enums.py", line 231, in coerce
    return cls.__value_type_(other)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

TypeError when using validators

Comparators can not be used, as they apply on the EChoice instance instead of the label, for example when using an IntegerField.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.