Issue with models.FilePathField in Django 1.7 Admin?

232 views
Skip to first unread message

Benjamin Scherrey

unread,
Sep 10, 2014, 12:36:43 PM9/10/14
to django-users
I have a model with a FilePathField declared as follows:

ftp_path = models.FilePathField(path=settings.BASE_SFTP_DIRECTORY,
                                    max_length=250, allow_files=False,
                                    recursive=True, allow_folders=True, blank=True)

In my save command I do the following to ensure it has content:

if not self.ftp_path:
            self.ftp_path = settings.BASE_SFTP_DIRECTORY + self.slug + '/'

The intent here is to store a path name to a directory where I can import files that have been pushed up via sftp. When I view my objects in the shell they have correct data in this field and refer to existing directories.

When viewed in the Admin, however, I just see a bunch of dashes for their content with a drop down box offering no options. I cannot view or edit the FilePathField content in the Admin whatsoever. The resulting html that is generated looks like this:

<div class="form-row field-ftp_path">
<div>
<label for="id_ftp_path">Ftp path:</label>
<select id="id_ftp_path" name="ftp_path">
<option value="">---------</option>
</select>
</div>
</div>

Kinda stuck about what I'm doing wrong here. Any ideas?

thanx,

  -- Ben Scherrey

--
Chief Systems Architect Proteus Technologies
Personal blog where I am not your demographic.

This email intended solely for those who have received it. If you have received this email by accident - well lucky you!!

Collin Anderson

unread,
Sep 11, 2014, 12:19:48 PM9/11/14
to django...@googlegroups.com
try checking os.listdir(settings.BASE_SFTP_DIRECTORY) to see if python can actually see your files.

Benjamin Scherrey

unread,
Sep 12, 2014, 2:18:26 PM9/12/14
to django-users
Yes that all works. My unit tests and when reviewing the resulting objects via the django shell show everything is absolutely working and the content of my FilePathField data is correct. It's only the Admin UI that is giving me fits.

thanx,

  -- Ben

On Thu, Sep 11, 2014 at 11:19 PM, Collin Anderson <cmawe...@gmail.com> wrote:
try checking os.listdir(settings.BASE_SFTP_DIRECTORY) to see if python can actually see your files.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d3a4e9b1-9e8a-4270-84de-5a339ec2cdd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages