Hi,

Need help in understanding the relation between models and delete
operations.
Here is my model

class UserBasicDetails(models.Model):
        user_id = models.OneToOneField(User, primary_key=True,
to_field='username', parent_link=True)
        place = models.CharField(null=False, blank=False, max_length=30)

Step1:
user = User.objects.get(username='lokesh')
bas = UserBasicDetails.objects.create(user_id = user, month='feb')
Step2:
After successful creation of the record i am trying to delete all the
records from UserBasicDetails
UserBasicDetails.objects.all().delete()
Step3:
Ended up with the error and pasted below
ValueError: invalid literal for int() with base 10: 'lokesh'

My Analysis:
I have tried with the 2 scenarios
1. Primary key - Integer, Delete successful
2. Primary key - Non-Integer - Delete fails

So, I felt the primary key field should be an integer.

Please correct me if i am in wrong direction.

Regards,
Lokesh


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to