Django automatically creates an id field as primary key.
Now I need to get the object by this id.
object = Class.objects.filter()
How to write this filter?
If you want to get an object, using get()
is more straightforward:
obj = Class.objects.get(pk=this_object_id)