wojtekj
wojtekj

Reputation: 55

Django restframework Error binding parameter

When trying to save the data in the DB I have this error:

sqlite3.InterfaceError: Error binding parameter 1 - probably unsupported type.

models.py

class Movie(Model):
    title = CharField(max_length=255)
    omdb = JSONField()
    slug = SlugField(max_length=255, unique=True, allow_unicode=True)

views.py

omdb_data = get_movie(title) # returns response.json() from external API call
print(type(omdb_data['Title'])) # str
        print(type(omdb_data)) # dict
        movie = Movie(title=omdb_data['Title'],
                      omdb=omdb_data, slug=slugify(title))
        movie.save() # crashing here

What could be wrong? I'm guess it's problem with title or omdb parameters (not sure if ID counts or not) but no idea whats wrong.

Upvotes: 1

Views: 316

Answers (1)

thiras
thiras

Reputation: 541

SQLite doesn't support all types data. It's in its name (Lite). You may try to convert to PostgreSQL or another complete database solution. Here is a tutorial for Django+Postgres but be careful, it's little bit outdated.

Upvotes: 1

Related Questions