Hi guys. Could you help me please with understanding of FileField behaviour. I'm slightly confused.
For test purposes i use this simple model <code> class Test(models.Model): name = models.CharField(max_length=255) template = models.FileField(upload_to='upload') </code> Then i'm trying to test this functionality in console on local windows machine and here is the output: <code> ... >>> f = open('Z:/home/django/media/upload/test.xls', 'rb') >>> f = File(f) >>> t = Test.objects.create(name='test', template=f) >>> t.template <FieldFile: Z:/home/django/media/upload/test.xls> >>> t.template.url Traceback (most recent call last): File "<console>", line 1, in <module> File "d:\webservers\usr\local\python\lib\site-packages\django\db \models\fields\files.py", line 54, in _get_url return self.storage.url(self.name) File "d:\webservers\usr\local\python\lib\site-packages\django\core \files\storage.py", line 213, in url return urlparse.urljoin(self.base_url, name).replace('\\', '/') File "d:\webservers\usr\local\python\lib\urlparse.py", line 254, in urljoin urlparse(url, bscheme, allow_fragments) File "d:\webservers\usr\local\python\lib\urlparse.py", line 154, in urlparse tuple = urlsplit(url, scheme, allow_fragments) File "d:\webservers\usr\local\python\lib\urlparse.py", line 194, in urlsplit i = url.find(':') AttributeError: 'File' object has no attribute 'find' </code> The main question is what should i pass in this field on object creation? As you can see i've tried to pass django.core.files.File object, but in this case it seems that upload_to parameter is totally ignored and 'template' field writes uncorretly. May be someone can share a simple snippet of how to handle this field type. Thanks in advance :)) --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---