2

how to add list field in the sqlite db in django restframework

    camera = models.ForeignKey(Camera, on_delete=models.CASCADE)
    updated_time = models.DateTimeField(auto_now_add=True)
    objects_inself = models.????
1
  • what kind of list is that exactly? Commented May 20, 2022 at 12:39

1 Answer 1

2

SQLite doesn't support list or array fields, but you have few options depending on what you want to archive.

  1. Switch to Postresql (it supports those fields)
  2. If your list store objects, then you can create model for the objects and create One-to-Many or Many-to-Many relationship. Then you can get a list of models using something like YourModel.your_related_objects_set.all()
  3. If you want to just store simple values like integers or strings then you can use Charfield and some custom logic to extract values from string and convert it to list
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.