haasystems.blogg.se

Drf ticket creator
Drf ticket creator





However, nothing seems to be working for me. Retrieving a Foreign Key value with django-rest-framework serializers I have referenced similar set ups such as in this post: I have been messing around with this for a while and struggling. When I return the data, I receive the PK of the Status table (1,2,3, etc.) but I do not receive the status_text field. The field status_text is not coming back as part of the API call. Status_text = serializers.ReadOnlyField(source='Status.status_text') My serializer looks like this: class SirTargetStatusSerializer(serializers.ModelSerializer):

drf ticket creator

Return '%d - %s %s' % (self.id, self.first_name, self.last_name) Sir_status = models.ForeignKey(Status, on_delete=models.CASCADE, default=1, related_name='targets') Last_name = models.CharField(max_length=40)įirst_name = models.CharField(max_length=40) Status_open = models.BooleanField(default=1)Įntry_date = models.DateTimeField(auto_now_add=True)

drf ticket creator

Status_text = models.CharField(max_length=20)

drf ticket creator

The models are as follows: class Status(models.Model): The SirTarget is like a ticket & the Status is a textual status label of the ticket that corresponds to the phase of handling the ticket. I am really struggling with an issue returning a value from my Django Rest Framework API.







Drf ticket creator