Skip to content

Responder table endpoints #13

@BrianHGrant

Description

@BrianHGrant

Responder does not have a single primary key field but has composite key of incident_id and responder_id, what is best path for representing this as model and as a retrieve endpoint?

Current model, which works for list method:

class Responder(models.Model):
    incident_id = models.IntegerField(primary_key=True)
    responder_id = models.IntegerField()
    responderunit = models.ForeignKey('ResponderUnit', models.DO_NOTHING, blank=True, null=True)
    codetosc = models.IntegerField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'responder'
        unique_together = [
            ('incident_id', 'responder_id'),
        ]

This fails though when using a generics.RetrieveAPIView, as an attempt to retrieve a responder instance based on primary key will return many when the get() method is expecting a single instance.

A possible solution is to keep current model and build custom endpoint that will expect multiple responses for the single endpoint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions