django-ddp icon indicating copy to clipboard operation
django-ddp copied to clipboard

Serializer fails for ForeignKey fields with db_column set to field name.

Open tysonclugg opened this issue 8 years ago • 2 comments

The default serializer fails to return a value for the foo field of the Bar model in following:

from django.db import models

class Foo(models.Model):
    name = models.CharField(max_length=10)

class Bar(models.Model):
    foo = models.ForeignKey('Foo', db_column='foo')

tysonclugg avatar Dec 29 '15 05:12 tysonclugg

@tysonclugg - I wanted to take a look at this issue today, but I can't recreate the problem. It works just fine for me when using db_column on a ForeignKey.

What error or problem do you see with the serializer with this?

codyparker avatar Mar 01 '16 17:03 codyparker

Line https://github.com/jazzband/django-ddp/blame/develop/dddp/api.py#L435 sets fields[field.column] but then line https://github.com/jazzband/django-ddp/blame/develop/dddp/api.py#L438 runs fields.pop(field.name). If field.column is the same as field.name, then it has popped the value we just set.

tysonclugg avatar Aug 15 '16 15:08 tysonclugg