On 26 nov, 06:24, issya <[EMAIL PROTECTED]> wrote:
> It looks like I partly answered my own question. I just do something
> like the below to get the field names of the empty model B and I will
> iterate through the fields until 1 matches and then assign the
> information.
>
> This only prints out the field names.
>
> property_field = FeaturedProperties()._meta.fields
> for field_name in property_field:
>         print field_name.name


objA = ModelA.objects.all()[0]
fieldnames = ModelB._meta.get_all_field_names()
data = {}
for fieldname in fieldnames:
    val = getattr(objA, fieldname, None)
    if val:
        data[fieldname] = val
objB = ModelB.objects.create(**data)


HTH


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to