Skip to content

Cannot set id as field #12

Description

@agusmakmun

I found an error when my data have an id or pk field. But, when I removed it id, it just working fine.

image

from reobject.models import Model, Field

data = [
  {'id': 1, 'name': 'brad', 'color': 'red', 'tags': [], 'author': {'name': 'admin'}},
  {'id': 2, 'name': 'sylvia', 'color': 'blue', 'tags': [], 'author': {'name': 'user'}},
  {'id': 3, 'name': 'sylwia', 'color': 'green', 'tags': [], 'author': {'name': 'admin'}},
  {'id': 4, 'name': 'shane', 'color': 'red', 'tags': [], 'author': {'name': 'admin'}},
  {'id': 5, 'name': 'shane', 'color': 'red', 'tags': ['python', 'django'], 'author': {'name': 'user'}}
]

class Book(Model):
    id = Field()
    name = Field()
    color = Field()
    tags = Field()
    author = Field()


for item in data:
    Book(**item)


Book.objects.all()
Book.objects.filter(author__name='admin')

Also it doesn't work for:

Book.objects.filter(tags__in=['python'])

oh it working with:

Book.objects.filter(tags__contains='python')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions