-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding value to attribute throws an exception #187
Comments
Hi @nabokovYaroslav - Thanks for reporting this! To be clear, are you talking about a datatype of In either case, could you post a snippet to reproduce what you're seeing? |
Hello, @Dresdn Code from your current django-eav2 repository that is causing the error
What happens when you add a value (model Value)? (It doesn't matter what type of attribute)
This piece of code from this method raises an AttributeError exception because value = [] and the list does not have a "split" method
This piece of code from this method raises an AttributeError exception because the "separator" attribute was not found. My temporary fix
Sorry for writing in such detail what the problem is. I just decided to clarify the problem. I hope you understand |
@nabokovYaroslav, I spent some time and finally took a look at this. From the AdminSite, I'm only seeing issues with the
Honestly, I'm not really finding any value in the CSV Type as it'd be easy enough to store a string using a TextField, and parsing the string in your app. I'm half tempted to just implement your fix and mark the field as deprecated. What do you think? Worth making it work properly or not? |
@Dresdn I don't see the point in this field either. I'd rather take it out of the library, but I can't speak for everyone. I think at the moment, it's better to make it work, that is, replace the current implementation with mine. By the way, I wanted to say that I was interested in writing my own implementation of eav without using ContentTypes, because it is obvious that it is bad in performance. |
fix: #187 return csv field value in widget
Adding a value to an attribute with data type "Text" throws an AttributeError referring to line 45 of eav/forms.py in the validate method with the description 'list' object has no attribute 'split'. Also, when I got into your library to figure out what was happening, I found that the error was caused by CSVFormField, although the attribute was set with the "Text" type and the value of this field in the form was empty. I also tried to enter a value when adding "1;2;3" to the CSV field and that threw another AttributeError: 'CSVFormField' object has no attribute 'separator' exception.
Expected Behavior
Value should be set
Actual Behavior
an AttributeError is thrown
Possible Fix
The to_python method returns [] because the CSV field contains an empty value, so an AttributeError exception is thrown in the validate method.
When adding a value to this field, another exception is thrown, due to the fact that the "separator" attribute was not found. The "default_separator" attribute is present, maybe you should use it?
Steps to Reproduce
Your Environment
Include relevant details about the environment you experienced the bug in.
The text was updated successfully, but these errors were encountered: