Hello. I have a view that should duplicate a model object and save it in the database. I tried with this code:
obj = MyModel.objects.get(pk=1) obj2 = MyModel() for e in obj.__dict__: if e != 'id': obj2.__setattr__(e, obj.__getattribute__(e)) #error obj2.save() But I get this error: Exception Type: TypeError Exception Value: expected 2 arguments, got 1 in the line marked with #error... The same code works if I execute it from the django shell... Why? By the way, is this a good way to duplicate an object or there are better methods? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---