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

David c
PRO
David c
Pro Student 27,812 Points

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 21,758 Points

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

Steven Parker
Steven Parker
177,483 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?

David c
David c
Pro Student 27,812 Points

Actual answer would probably help me more right now :D

Steven Parker
Steven Parker
177,483 Points

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