Hello, I want to be able to add files inside a model to test that model. However, I'm unable to find in the documentation any mention on how to do so. I asked on IRC and somebody suggested the following:
from django.core.files import File from myproject.myapp.models import MyModel fd = open('/path/to/file') f = File(fd) obj = MyModel.objects.create(file_field=f) f.close() fd.close() However, when I try to access obj, I get the following exception: SuspiciousOperation: Attempted access to '/path/to/file' denied. Is it how one is supposed to "attach" file into a model? If so, what could be causing my problem? Thanks, Vincent --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---