[Fixed]-Uploading files using Django Admin


Nothing special to do, django-admin has it already.


class Router(models.Model):
    specifications = models.FileField(upload_to='router_specifications')


from django.contrib import admin
from my_app import models


You’ll see a file upload field in your model’s admin now. If already a file for the model instance, you’ll see a link to it as well.

When rendering a view to a user, pass the model(s) in the view’s context and use the field’s url property to link to the file.

<a href="{{ my_model_instance.specifications.url }}">Download PDF</a>

Leave a comment