 <p>I did it finally. for example i have a file in <code>localjost:8000/media/1.jpg</code> and i want to get ip of the user who enters this url to load the <code>1.jpg</code>.</p> <p>I added this line in my urls : <code>url(r'^media/(?P&lt;path&gt;.*)$', 'project.views.serve','document_root': settings.MEDIA_ROOT,}),</code> and i set the MEDIA_ROOT already. then in <code>project.views.serve</code> i called <code>django.views.static.serve</code> and i returned the result of that as a HttpResponse. i have a request argument in my <code>project.views.serve</code> and i did this to get the user's ip from that :</p> <pre><code>x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') if x_forwarded_for: ip = x_forwarded_for.split(',')[-1].strip() else: ip = request.META.get('REMOTE_ADDR') print ip </code></pre>