Hi,
I am trying to save file using file field but ran into problem.
Here is my code:

***********model************

class CronEmail(models.Model):
    subject = models.CharField( max_length = 200)
    message = models.CharField( max_length = 200)
    sender = models.CharField( max_length = 200)
    send_to = models.CharField(max_length = 200)
    attach = models.FileField(upload_to='example', null = True)
    created_on = models.DateTimeField(auto_now_add=True)
    updated_on = models.DateTimeField( auto_now = True)


****************form******************
class SendMailForm(forms.Form):
 attach = forms.FileField(required= False)
 subject = models.CharField( max_length = 200)
 message = models.CharField( max_length = 200)
    sender = models.CharField( max_length = 200)
    send_to = models.CharField(max_length = 200)


****************settings.py********
MEDIA_ROOT = os.path.join('/home/laspal/work/test/', 'static/media')
MEDIA_URL = '/static/media/'

*******view**************

emailform = SendMailForms(request.POST, request.FILES)
 ........
  cronemail = CronEmail()
  attach = request.FILES['attach']
   cronemail.subject = subject
   and so on
   cronemail.save()

So my problem how can I save attach file with the other info in
cronemail.
I tried cronemail.save_attach_fiel( filename, filecontent) but it
gives me error.

So can some one help me out in saving file.
and also I  wanted to know how can I get the stored file and delete
it?
Thanks.
--~--~---------~--~----~------------~-------~--~----~
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