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

FileField #62

Open
Dagur opened this issue Jul 28, 2024 · 1 comment
Open

FileField #62

Dagur opened this issue Jul 28, 2024 · 1 comment

Comments

@Dagur
Copy link

Dagur commented Jul 28, 2024

I have a FileField

flyer = models.FileField(
        _("Flyer"), upload_to="uploads/flyers", max_length=100, null=True, blank=True
    )

and the type generated looks like this:

flyer?: File | null;

Shouldn't it just be a string?

@HasanMajid
Copy link

HasanMajid commented Aug 26, 2024

the best way around it I could think of is to make it a char field in the serializer as such:

@ts_interface()
class MyModelSerializer(serializers.ModelSerializer):
    flyer = serializers.CharField(required=False) # <----- HERE

    class Meta:
        model = MyModel
        fields = ["flyer"]

This way the type will be flyer?: string

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

2 participants