-
Notifications
You must be signed in to change notification settings - Fork 3
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
related objects should be included in the Columns
fields
#736
Comments
+1 (for Frischmuth) |
APIS is very customizable by now, so a column with related objects (with "related" referring to objects connected by the TempTriples) this could be solved using a custom queryset together with a custom table: # in `your_ontology.querysets`
# this adds the ids of related objects to the persons listed in a list view
def PersonListViewQueryset(queryset):
ro_subquery = RootObject.objects.filter(triple_set_from_obj__subj_id=OuterRef("pk")).values("id")
return queryset.annotate(related=ArraySubquery(ro_subquery)) # in `your_ontology.tables`
# this adds a `related` column that prints the string representation of the related objects
class PersonTable(AbstractEntityTable):
related = tables.Column(empty_values=[])
def render_related(self, record):
rel_objs = map(str, RootObject.objects_inheritance.filter(id__in=record.related).select_subclasses())
return ", ".join(rel_objs) (this is only a POC, which shows related entities that are triple objects, not the other way around) |
@b1rger Yes, this is fantastic - and I use it. @sennierer talks about making these custom columns "optional" via the columns field
At the moment only "fields" of the model are available in the columns dropdown; and the columns we define in tables appear in the view but they cannot be turned off or optionally added by selecting ín the columns field |
Adding to the agenda, because we might close this. It is possible to implement this in projects |
we make this the default behaviour with the new class based relations. |
idea was to easily allow for using annotated fields in tables. there is an issue on custom table fields (#1030) |
currently we only include attributes of the classes in the tables, but we should include FK and M2M fields. These shouldnt be selected by default (because of the additional queries), but should be selectable via the columns field.
related to #735
The text was updated successfully, but these errors were encountered: