Showing posts with label django. Show all posts
Showing posts with label django. Show all posts

Sunday, May 8, 2011

Django-misc

And hi there again,

There are django-misc application, that I want to talk about.
First, I developed it with my friend - Vlad Frolov. We started to working on it couple years ago.
It was like a part of every project, we've done since than. We always used misc/ app as place, where all "strange", "not know were to put" code were placed.
And recently I published it on GitHub, and to PyPi (it was my first experience - and it turned out pretty easy).
So if you want latest version:
pip install git+git://github.com/ilblackdragon/django-misc.git
and stable version:
pip install django-misc

If you want to use bbcodes - install postmarkup, and if you want html clearer (remove javascript, iframes, etc - make html safe) - install BeautifulSoup.

After installation, you can add it to INSTALLED_APPS if you want template tags and management commands:
INSTALLED_APPS = (
   ...
   'misc',
   ...
)

From this I'll got:

  •  template tags misc_tags, bbcode_tags, html_tags, share_buttons
  • command - create_app - that will create application in apps/ folder
  • post_sync event that will create Site object from settings.SITE_NAME and SITE.DOMAIN
  • Middlewares: SpacelessMiddleware that removes spaces from response html; StripCookieMiddleware - remove google analytics cookies (to enable django cache for full page).
Plus I'll have (even without adding to INSTALLED_APPS):
  • json_encode.py : json_encode, json_response and json_template functions
  • views.py : server_error, redirect_by_name
  • decorators.py: to_template (render_to), receiver (standard on django 1.3)
  • utils.py: HttpResponseReload,  custom_spaceless, render_bbcode, strip_bbcode, str_to_class, get_alphabets (russian and english)
  • html clearer: html.clear.clear_html_code

This application still under development, so we'll add more functionality later. But it already have plenty a lot of cool stuff, so I add this application on all projects I create.
On full documentation I'll work later.

Django-manager

Hi there,

Today's topic - django-manager. This app were created because recently I needed to create couple django projects from scratch, and that wasn't fun.
So decision was - to create some app, that will have just simple "create project" script, and it will done all stuff, that I need to do, before and after standard "django-admin.py startapp".

Plus, one time I faced problem, that I haven't root access, so I can't install any application (like django) at all. So django-admin doesn't need to install at all/
So, lets start from start :)
1) Install django-manager from https://ilblackdragon@github.com/ilblackdragon/django-manager.git
git clone git+https://ilblackdragon@github.com/ilblackdragon/django-manager.git

2) Go to django-manager folder and run create_project.py
cd django-manager/
./create_project.py your_project_name [path/to/project]

This will create:
- Virtual environment for your project
- Create project folder for new django project
- Create new project with some stuff already made:
- apps/ folder - for your django applications
- apps/auth_ext - contains code for profiling, and you can change it whatever you want
- deploy/ - folder for your deploy scripts, requirements.txt, etc
- developer/ - place for scripts (for start update.sh & update.bat scripts)
In requirements.txt you'll find: django, mysql-python, south, django-misc, django-uni-form and some other useful python libraries.
Configured urls and settings for work with admin and auth_ext.
- Create git repository in project directory, and commits changes.

Plus, when I'll issue update of django-manager (and I'll), you can update you project by using update_project.py:
./update_project path/to/your_project

This will apply patches, that I'll create if I'll make any changes.

Personally, I'm not recommend Windows users to use virtual environments. That is why I'll shortly add keywords for create_project to disable virtual environment and git work.

PS Use Linux for your python\django development - it rulezzz ;)