[Answered ]-Django python shell data access error

2👍

You cannot access a model field like that. First of all, degree_code is not imported. Also, you cannot import it, you can access it through the model: deg_course_cat.degree_code, but I’m not sure what do you want to do with it.

If you want to get all the degree_code values out there, use values_list() with flat=True:

>>> deg_course_cat.objects.values_list('degree_code', flat=True)

This will return you a list of all degree_code values out there in the database.

👤alecxe

Leave a comment