I want to delete the id attribute of a model but failed, it comlains that
the model has no attribute 'id'. But I use hasattr() checked it and it does
has the attribute.
My sample code
product = Product.objects.get(pk=_id)
if hasttr(product, 'id'):
del product.id
I also tried delattr(product, 'id'), got same result.
Exception Type: AttributeError Exception Value:
'Product' object has no attribute 'id'
I use python 3 and django 1.8.
Anyone could help here?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/75e6687d-d7fe-4681-ba30-8ed74044a03e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.