Skip to main content

Posts

Showing posts with the label regexp

Django Log Files Viewer documents

Django Log File Viewer. This is a PYPI package django-log-file-viewer  documents. Github repo:  django-log-file-viewer@garmoncheg.github.com Usage: Useful to add log files view functionality to your Django admin web site. Instead of using database log files storage, it gives you ability to store/view log files through GUI. It requires a directory with Django log files to function. E.g. directory structure: $ project_dir / logs / : applog . log applog . log . 2012 - 09 - 22 . . . errors . log applog . log . 2012 - 09 - 22 . . . Screenshots: To parse/display these log files you need: 1. Install an app and add it to your settings.py INSTALLED_APPS section: # settings.py INSTALLED_APPS = ( # ... 'django-log-file-viewer' , # ... ) 2. Set UP 2 django variables in settings.py: # settings.py: LOG_FILES_DIR = '/path/to/your/log/directory' # Relative or static path string o...

Django: Unittest for HttpResponseRedirect method recipe

I like to invent bicycles in my code. They often come in handy and you basically do not rely on Django version... So upon updating your project's Django version in future times you will not have to refactor half of all the code. So... How do you test http redirects? I usually restrict my time in thinking and write code like if redirect target is hardcoded. And it really is in most of the times. But imagine if you decide to redirect your view response in several places. Or imagine if you're not the only one who owns you'r project's code and there are many collaborators that can change things without warning... And you need to have a test for that view that will test redirects and complex code behavior. I used to check redirects like so: response = self . cliet . get ( '/myview' ) self . assertEqual ( response . status_code , 302 ) # View redirected... All ok... But  if you have some view that can redirect to things that you need to check. How would y...