Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilePathField #3520

Closed
biggosh opened this issue Oct 19, 2015 · 9 comments
Closed

FilePathField #3520

biggosh opened this issue Oct 19, 2015 · 9 comments
Assignees

Comments

@biggosh
Copy link

biggosh commented Oct 19, 2015

I tried to use this field in the model and rest framework always raises an error:

init() missing 1 required positional argument: 'path'

Is this field type supported?

Thanks

@jpadilla
Copy link
Member

@biggosh could you perhaps share what your model and serializer look like?

@biggosh
Copy link
Author

biggosh commented Oct 22, 2015

Sorry for the delay. This is the the serializer and the original model.
Thanks

class TemplatesSerializer(serializers.ModelSerializer):
    class Meta:
        model = Templates

class Templates(models.Model):
    # file_path = models.CharField(max_length=1000, null=False, blank=False)
    file_path = models.FilePathField(path="tmp")
    title = models.CharField(max_length=100, null=False, blank=False)
    description = models.TextField(null=True, blank=True)
    code = models.CharField(max_length=10, null=False, blank=False)
    owner = models.ForeignKey('auth.User', related_name='templates')

    def __str__(self):
        return self.title

@jpadilla
Copy link
Member

@biggosh we're probably not passing along the model field's definition along to the mapped serializer field. Could you try explicitly setting the field in your serializer like so:

class TemplatesSerializer(serializers.ModelSerializer):
    file_path = serializers.FilePathField(path='tmp')

    class Meta:
        model = Templates

@biggosh
Copy link
Author

biggosh commented Oct 22, 2015

Ok, now it's working.

thanks

@tomchristie
Copy link
Member

we're probably not passing along the model field's definition along to the mapped serializer field.

Although there's a work around it appears that this issue isn't resolved until we do deal with the above, right?

@jpadilla
Copy link
Member

@tomchristie sure thing. I'll get to it.

@jpadilla jpadilla self-assigned this Oct 23, 2015
@jpadilla
Copy link
Member

@tomchristie should we map all of the field's options: path, match, recursive, allow_folders, and max_length?

@tomchristie
Copy link
Member

I guess whichever we support, yeah.

@jpadilla
Copy link
Member

Closed by #3536

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants