Reputation: 255
It might be that this question sounds pretty silly but I can not figure out how to do this I believe the simplest issue (because just start learning Django).
What I know is I should create a middleware file and connect it to the settings. Than create a view and a *.html page that will show these requests and write it to the urls.
I would be really thankful for any insights and elucidates.
P.S. One more time sorry for a dummy question.
Upvotes: 1
Views: 2172
Reputation: 37876
First, as you said, you need a model to save request information in database. After you have created and migrated your new model, you write your custom middleware and do what you want in process_request
method:
from yourapp.models import YourModel
class CustomDebugMiddleware_first(object):
def process_request(self, request):
new_http_information = YourModel(http_info=INFO_YOU_WANT_TO_SAVE)
new_http_information.save()
and then put the path to this middleware in your settings.py into MIDDLEWARE_CLASSES
Upvotes: 3
Reputation: 4940
You can implement your own RequestMiddleware
(which plugs in before the URL resolution) or ViewMiddleware
(which plugs in after the view has been resolved for the URL).
In that middleware, it's standard python. You have access to the filesystem, database, cache server, ... the same you have anywhere else in your code.
Showing the last N requests in a separate web page means you create a view which pulls the data from the place where your middleware is storing them.
Upvotes: 2