Python Using Databases in Python Gettin' CRUD-y With It Review: Using Databases in Python

Duplicate records

I don't want to be able to have a duplicate record for UPCs in my database. Finish the model below:

class Product(Model): name = CharField() description = TextField() upc = CharField(max_length=100, X =True)

In this question what would 'X' be?

2 Answers

Noah Olatoye
Noah Olatoye
Front End Web Development Techdegree Graduate 23,869 Points

The model should be: class Product(Model): name = CharField() description = TextField() upc = CharField(max_length=100, unique=True)

Steven Parker
Steven Parker
200,540 Points

Your "X" would be the keyword name of the argument which when set to "True" enforces that there will be no duplicates.

Or were you asking for the actual answer?

Actual answer would probably help me more right now :D

Steven Parker
Steven Parker
200,540 Points

Okay, the keyword name of the argument that prevents duplicates when set to "True" is "unique".