Target API Views#
Warning
Check your groups!
When creating a Target via the API, one of the accepted parameters is a list of groups that will have permission
to view the Target. If you neglect to specify any groups, your Target will only be visible to the user that
created the Target. Please be sure to specify groups!!
Tip
Better API documentation
The available parameters for RESTful API calls are not available here. However, if you navigate to /api/targets/
and click the OPTIONS button, you can easily view all of the available parameters.
From the GET view, you can experiment with the available filters and see an example of the request.
- class tom_targets.api_views.TargetExtraViewSet(**kwargs)[source]#
Viewset for TargetExtra objects. Only
GETandDELETEoperations are permitted.To view available query parameters, please use the OPTIONS endpoint, which can be accessed through the web UI.
- get_queryset()[source]#
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- serializer_class#
alias of
TargetExtraSerializer
- class tom_targets.api_views.TargetListViewSet(**kwargs)[source]#
Viewset for TargetList objects. Only
GETandDELETEoperations are permitted.To view available query parameters, please use the OPTIONS endpoint, which can be accessed through the web UI.
- get_queryset()[source]#
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- serializer_class#
alias of
TargetListSerializer
- class tom_targets.api_views.TargetNameViewSet(**kwargs)[source]#
Viewset for TargetName objects. Only
GETandDELETEoperations are permitted.To view available query parameters, please use the OPTIONS endpoint, which can be accessed through the web UI.
- get_queryset()[source]#
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- serializer_class#
alias of
TargetNameSerializer
- class tom_targets.api_views.TargetViewSet(**kwargs)[source]#
Viewset for Target objects. By default supports CRUD operations. See the docs on viewsets: https://www.django-rest-framework.org/api-guide/viewsets/
To view supported query parameters, please use the
OPTIONSendpoint, which can be accessed through the web UI.Please note that ``groups`` are an accepted query parameters for the ``CREATE`` endpoint. The ``groups`` parameter will specify which ``groups`` can view the created Target. If no ``groups`` are specified, the ``Target`` will only be visible to the user that created the ``Target``. Make sure to check your ``groups``!!
In order to create new
TargetNameorTargetExtraobjects, a dictionary with the new values must be appended to thealiasesortargetextra_setlists. Ifidis included, the API will attempt to update an existingTargetNameorTargetExtra. If noidis provided, the API will attempt to create new entries.TargetNameandTargetExtraobjects can only be deleted or specifically retrieved via the/api/targetname/or/api/targetextra/endpoints.- filterset_class#
alias of
TargetFilterSet
- get_queryset()[source]#
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- handle_exception(exc)[source]#
Create Custom Error Message for Http404 errors because Target can have different names based on the supplied Model.
- serializer_class#
alias of
TargetSerializer
- Filters are available for Target objects:
type: Filter by target type (e.g., ‘SIDEREAL’, ‘NON_SIDEREAL’).
name: Filter by target name or alias.
key: Filter by a specific key in the target’s extra fields.
value: Filter by a specific value in the target’s extra fields.
cone_search: Perform a cone search around a given position (RA,Dec,Radius).
targetlist__name: Filter by the name of the target list the target belongs to.
name_fuzzy: Perform a fuzzy search on the target name or aliases.
target_cone_search: Perform a cone search on the target’s position (radius).
order: Order the results by a specific field (‘name’, ‘created’, ‘modified’)
- Access these filters via the API endpoint:
GET /api/targets/?type=<type>&cone_search=<ra,dec,radius>