Downloading log files django






















Add Templates folder that points to the location of Django templates that will contain the download link to file.

If you already have created another folder for all the templates and specified it in settings. Open views. You can change file name and path as per your requirement.

If you want to download the file via template, just add the hyperlink to the file as shown below in any template. In this case, you need to modify the views. Asked 4 years, 7 months ago. Active 1 year, 8 months ago. Viewed 9k times. Improve this question. Jens Testing man Testing man 10 10 silver badges 25 25 bronze badges.

Add a comment. Active Oldest Votes. You need to read that file. Serve it using HttpResponse along with proper content type.

Project links Homepage. Maintainers imankarimi. Why Django Log Reader? Reading files based on Linux commands speeds up the display of file content Download the result of the content Display all files according to the pattern defined in the settings.

If there is no filter, the system reads the default file. Set the number of lines you want to read to this value. Project details Project links Homepage. In this trial code the exact filename and extension is hard coded in the path variable. Here is a way you can serve a file through Django although it is usually not a good approach, the better one is to serve files with a webserver like nginx etc - for performance reasons :. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Downloading a file using Django Ask Question. Asked 3 years, 7 months ago. Active 3 years, 7 months ago. Viewed 3k times. Improve this question.



0コメント

  • 1000 / 1000