Closed j1fig closed 7 years ago
I really hate that piece of Python syntax!
How many times do we have to write:
if isinstance(value, abc.Iterator) and not isinstance(value, (str, bytes)):
But you have a good ergonomic point. I'll have a look next week. On Tue, 22 Sep 2015 at 10:55, João Figueiredo notifications@github.com wrote:
This is more of user-friendliness issue, and might :
watson.register(Community, fields=('name'))
Causes field attribute in registration.SearchAdapter to have self.fields = 'name', which will then be iterated here https://github.com/etianen/django-watson/blob/master/src/watson/registration.py#L138, which causes it to try to access models field, 'n', 'a', 'm', 'e' - which dont exist.
This is of course because ('name') is the same as 'name', and could be boiled down to user ingenuity (such as mine).
Doing
watson.register(Community, fields=('name',))
Fixes the problem, as SearchAdapter.fields will now be an iterable.
Thought it was worth posting here, for future newbie reference (though it concerns Python syntax, I wouldn't consider it an issue). Raising a TypeError when specifying a non-iterable object as arg to fields in watson,register might make it easier though.
Up to @etianen https://github.com/etianen ;)
Best, Joao
— Reply to this email directly or view it on GitHub https://github.com/etianen/django-watson/issues/126.
This is more of user-friendliness issue:
This causes field attribute in
registration.SearchAdapter
to haveself.fields = 'name'
, which will then be iterated here, which causes it to try to access models field, 'n', 'a', 'm', 'e' - which dont exist.This is of course because
('name')
is the same as'name'
, and could be boiled down to user ingenuity (such as mine).Doing
Fixes the problem, as SearchAdapter.fields will now be an iterable.
Thought it was worth posting here, for future newbie reference (though it concerns Python syntax, I wouldn't consider it an issue). Raising a TypeError when specifying a non-iterable object as arg to
fields
inwatson.register
might make it easier though.Up to @etianen ;)
Best, Joao