2
You could call each class method on incoming
objects to get results, then use the corresponding field name to store in a Profile
instance. Here’s a rough example, you might need to tweak it a little to make it work for you:
# create a Profile object
new_profile = Profile()
for name in dir(incoming):
# loop on each method for incoming object
attribute = getattr(incoming, name)
if not ismethod(attribute):
# get the value of the attribute
value = attribute
setattr(new_profile, name, value)
new_profile.save()
Source:stackexchange.com