M
M
maestro072017-04-12 09:57:58
Django
maestro07, 2017-04-12 09:57:58

How to make django pdf file upload?

How to make pdf file upload through django admin?
models.py

class PostLecture(models.Model):
    title = models.CharField(max_length = 200)
    pdf = models.FileField()
    time = models.DateTimeField(auto_now_add = True)


    def __unicode__(self):
        return self.title

    def get_absolute_url(self):
        return reverse("posts:detail", kwargs={"id": self.id})

    class Meta:
        ordering = ['-time']

how to change save path? to save to a specific folder.
and how to make it so that it can be downloaded from the web page?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
devalone, 2017-04-12
@devalone

https://docs.djangoproject.com/en/1.11/topics/files/
And url can be obtained using obj.pdf.url

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question