You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since m2m lookups are stored as a comma-separated string of ids,
you can't really create or modify values conveniently.
It would be nice if the AttributeDict made them look like a list of Lookup instances, or at least ids.
Then you wouldn't always have to write boilerplate code like:
# Let's add one violation if it's not already there.
ni = NewsItem.objects.get(...)
violation_list = list(ni.attributes.get('violations', '').split(','))
if str(violation.id) not in violation_list:
violation_list.append(str(violation.id))
ni.attributes['violations'] = ','.join(violation_list)
An even better solution would be to dispense with this silly comma-separated string entirely, and normalize the data properly, eg. with a many-to-many relationship between Lookups and Attributes. This would also mean we could get rid of the potentially slow regex search in NewsItemQuerySet.by_attribute().
It would mean more joins though.
The text was updated successfully, but these errors were encountered:
Since m2m lookups are stored as a comma-separated string of ids,
you can't really create or modify values conveniently.
It would be nice if the AttributeDict made them look like a list of Lookup instances, or at least ids.
Then you wouldn't always have to write boilerplate code like:
An even better solution would be to dispense with this silly comma-separated string entirely, and normalize the data properly, eg. with a many-to-many relationship between Lookups and Attributes. This would also mean we could get rid of the potentially slow regex search in NewsItemQuerySet.by_attribute().
It would mean more joins though.
The text was updated successfully, but these errors were encountered: