djangoproject access fields of object dynamically

2010-08-04 Thread ars_sim


Hello, Can anyone help me?

I have list of fields called 'allowed_fields' and I have object called
'individual'.
allowed_fields is sub set of individual. Now I want to run loop like
this

for field in allowed_fields:
obj.field = individual.field

obj have same fields like individual. Do you have solution of my
problem? I will thankful to you.

Regards,

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



How to pass List to Form Meta Class

2010-06-05 Thread ars_sim
Hello All,
I am newbie in django and I will very thankful to you if you help me
in this regard.

I want to pass list of fields from view to Meta class of FormModel.
Please check this example.

view.py:
   fields = [name, email, phone]
   individual_form = IndividualForm(fields)

forms.py
class IndForm(forms.ModelForm):
   class Meta:
model = Ind
fields = (
'name',
'email',
'phone',
)

I want to access view fields array into forms Meta class. I am not
sure I can do this or not.
Any idea! how can I do this?

Regards,

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



Django EmailMultiAlternatives with Embadded Image in HTML

2011-06-20 Thread ars_sim
I am trying to send email with HTML and embadded image. Email sending
working fine and its also attaching the image in email but its not
showing the image in HTML (inline). I used Content:ID in view and cid
in template but no success :(. I explore so many forms and apply
solutions but in vain please help!. Here is my code:

html_content = render_to_string('newsletters/
newsletter_template.html', vars)
text_content = strip_tags(html_content)

to = 'myem...@gmail.com'


msg = EmailMultiAlternatives(self.subject, text_content,
settings.STAFF_FROM_EMAIL, [to])
msg.attach_alternative(html_content, "text/html")

image_file = open('../media/images/banner_admin.gif', 'rb')
msg_image = MIMEImage(image_file.read())
image_file.close()

msg_image.add_header('Content-ID', '')
msg.attach(msg_image)

msg.send()

Template:



{{body|linebreaks}}


-- 
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.