0

I want to add an ip list (ex. ['192.168.0.1','...',]) into Django Model TextField. I don't know the serializer and validator well, so I keep getting the error 'not a valid string'. How can I change it?

3
  • 1
    You say you keep getting the error not a valid string, please show your code that yielded this error to help in understanding Commented Jan 10, 2020 at 4:18
  • 1
    Your question may already be answered here stackoverflow.com/questions/44630642/… Commented Jan 10, 2020 at 4:19
  • @HymnsForDisco Thank you for the link. I'm reading it now, and it would be helpful for me. Commented Jan 10, 2020 at 4:55

1 Answer 1

2

you are most probably trying to save list in text field, which will not be possible, you can use array fields

https://docs.djangoproject.com/en/3.0/ref/contrib/postgres/fields/#arrayfield

class ChessBoard(models.Model):
    board = ArrayField(
        ArrayField(
            models.CharField(max_length=10, blank=True),
            size=8,
        ),
        size=8,
    )
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.