in my settings 
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = "/media/"


my view to accept files.
def request_page(request):
 #todo since sqlite my get stuck between 2 submittion at the same time,
 # submit, if it cant try again  and then message that ask the user to try 
in 5 mins.
 try:
  if request.method == "POST":
   form = Submit_Form(request.POST, request.FILES)
   if form.is_valid():
    email = form.cleaned_data["email"]
    file = request.FILES["file"]
    # we make the message true or false so we can display color in the html 
template.
    if file.name.endswith(".ini"):
     per = Person(email=email, date_submitted=datetime.datetime.now(), 
file=file)
     per.save()
     message = ["Thanks, we receive your file:    " + email, "True"]
     forma = Submit_Form()
    else:
     message = ["its not the appropriate type of file, please verify.", 
"False"]
     forma = Submit_Form()




and this is how I am making my model
def content_file_name(instance, filename):
here is where I think is the problem,  windows like \ and Linux /  but even 
using os.path.join   I wasn't able to make it work, 
I also try hard code the path using \\.join instead
 if os.name == "nt":
  # path = "\\".join(["submitted_ini_files", filename + "___" + 
str(instance.email) + "___" + str(datetime.datetime.now())])
  path = os.path.join("submitted_ini_files", filename + "___" + 
str(instance.email) + "___" + str(datetime.datetime.now()))
  print path
  print MEDIA_URL
  # path = os.path.join("submitted_ini_files", filename + "___" + 
str(instance.email) + "___" + str(datetime.datetime.now() ))
  return path
 else:
  print "other than nt"
  return "/".join(["submitted_ini_files", filename + "___" + 
str(instance.email) + "___" + str(datetime.datetime.now())])


class Person(models.Model):
 email = models.EmailField(blank=True, null=True)
 file = models.FileField(blank=True, null=True, upload_to=content_file_name)
 date_submitted = models.DateTimeField(blank=True, null=True)

any tips on how to make this work?  thanks.  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8c9548cd-304a-4d06-bf84-ada8504612d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to