MEDIA_ROOT = 'c:\\stats_portal\\myproject\\myproject\\media\\' doesn't work. I've parsed the path to get this working for the time being, thanks for your help.
Regards, Nigel Legg 07914 740972 http://twitter.com/nigellegg http://uk.linkedin.com/in/nigellegg On 21 June 2013 19:09, Jacky Tian <xjtia...@gmail.com> wrote: > Have you set your MEDIA_ROOT appropriately in settings.py? Since > fileview.py is where your original exception originated, can you post the > relevant parts of the source in that file (whatever function line 5 belongs > to). Did you get the exception under runserver or a "real" webserver? > > You shouldn't need to change the slashes in your path, Python handles that > for you. > > -Jacky Tian > > On Friday, June 21, 2013 11:34:16 AM UTC-4, Nigel Legg wrote: > >> In the path shown in my previous email, documents is a subdirectory of >> the media directory, which is set in settings.py. >> >> views.py: >> from myproject.myapp.forms import DocumentForm >> >> def list(request): >> # Handle file upload >> if request.method == 'POST': >> form = DocumentForm(request.POST, request.FILES) >> if form.is_valid(): >> newdoc = Document(docfile = request.FILES['docfile']) >> newdoc.save() >> >> # Redirect to the document list after POST >> return HttpResponseRedirect(reverse('** >> myproject.myapp.views.list')) >> else: >> form = DocumentForm() # A empty, unbound form >> >> # Load documents for the list page >> documents = Document.objects.all() >> >> # Render list page with the documents and the form >> return render_to_response( >> 'myapp/list.html', >> {'documents': documents, 'form': form}, >> context_instance=**RequestContext(request) >> ) >> >> models.py: >> from django.db import models >> >> class Document(models.Model): >> docfile = models.FileField(upload_to='**documents/%Y/%m/%d') >> >> this section works fine - ie files yesterday were uploaded to >> c:\\....\\myproject\\media\\**documents\\2013\\06\\20\\file.**csv. >> I need now to be able to access them. This error suggests I need to >> convert documents/%Y/%m/%d' to documents\\2013\\06\\20\\ to be able to do >> so. Is that correct? >> >> Regards, >> Nigel Legg >> 07914 740972 >> http://twitter.com/nigellegg >> http://uk.linkedin.com/in/**nigellegg<http://uk.linkedin.com/in/nigellegg> >> >> >> >> On 21 June 2013 16:25, Jacky Tian <xjti...@gmail.com> wrote: >> >>> What does your project directory tree look like? I suspect the error has >>> to do with where your documents/ directory is located in relation to the >>> working directory. Try loading the document using a path relative to your >>> project root. >>> >>> -Jacky Tian >>> >>> >>> >>> On Friday, June 21, 2013 9:29:20 AM UTC-4, Nigel Legg wrote: >>>> >>>> New to Django(ish). I'm not sure whether my error is coding or OS >>>> related: >>>> I am getting the following error message: >>>> >>>> IOError at /myapp/file_view/4/ >>>> >>>> [Errno 2] No such file or directory: >>>> 'documents/2013/06/20/**testdata**1.csv' >>>> >>>> Request Method: GET Request URL: http://127.0.0.1:8000/myapp/**fi** >>>> le_view/4/ <http://127.0.0.1:8000/myapp/file_view/4/> Django Version: >>>> 1.5.1 Exception Type: IOError Exception Value: >>>> >>>> [Errno 2] No such file or directory: >>>> 'documents/2013/06/20/**testdata**1.csv' >>>> >>>> Exception Location: >>>> C:\stats_portal\myproject\**mypr**oject\myapp\fileview.py >>>> in filedata, line 5 Python Executable: c:\python27\python.exe Python >>>> Version: 2.7.5 Python Path: >>>> >>>> ['C:\\stats_portal\\myproject'****, >>>> 'c:\\python27\\lib\\site-**packa**ges\\python_dateutil-1.5-**py2.**7.egg', >>>> >>>> 'c:\\python27\\lib\\site-**packa**ges\\django_directupload-**0.0.**11-py2.7.egg', >>>> 'C:\\windows\\system32\\**python**27.zip', >>>> 'c:\\python27\\DLLs', >>>> 'c:\\python27\\lib', >>>> 'c:\\python27\\lib\\plat-win', >>>> 'c:\\python27\\lib\\lib-tk', >>>> 'c:\\python27', >>>> 'c:\\python27\\lib\\site-**packa**ges'] >>>> >>>> Server time: Fri, 21 Jun 2013 14:09:20 +0100 >>>> Is the file not found problem because the upload has recorded it as >>>> documents/2013/06/... even though I am working on Windows, so python / >>>> django should have ... documents\\2013\\06\\... etc? I am developing on >>>> Windows, but will deploy on Linux. >>>> Or have I made an error elsewhere? >>>> >>>> >>>> Regards, >>>> Nigel Legg >>>> 07914 740972 >>>> http://twitter.com/nigellegg >>>> http://uk.linkedin.com/in/**nige**llegg<http://uk.linkedin.com/in/nigellegg> >>>> >>>> -- >>> 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...@**googlegroups.com. >>> To post to this group, send email to django...@googlegroups.com. >>> >>> Visit this group at >>> http://groups.google.com/**group/django-users<http://groups.google.com/group/django-users> >>> . >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >>> >>> >> >> -- > 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. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- 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. For more options, visit https://groups.google.com/groups/opt_out.