0

I'm trying to change the labels of my form but for some reasons it does not work.

models.py

class Csv(models.Model):
    file_name = models.FileField(upload_to='csvs', max_length = 100)
    public = models.BooleanField(default = False)
    process_data = models.BooleanField(default = False)
    user = models.ForeignKey(User, on_delete = models.CASCADE, null = True)
    dataset_name = models.CharField(max_length = 100)
    library = models.CharField(max_length = 100, null = True)

views.py

class CsvFormView(SuccessMessageMixin, CreateView):
    model = Csv
    template_name = 'upload/upload.html'
    success_url = '/upload'
    success_message = "File Successfully uploaded."
    fields = ['file_name']
    labels = {'file_name' : 'Browse'} 

upload.html

<form action = "" method = "POST"  enctype="multipart/form-data">
    {% csrf_token %}
    {{form}}
    <button type = "submit">Upload File</button>
</form>

instead of labeling file_name as "browse", django just labels it as "File name"

Gaven
  • 953
  • 2
  • 8
  • 14

0 Answers0