February 17, 2015

Using django as a microframework, like flask.

February 17, 2015 0
Today me and my friend were discussing about the flask and django. We were arguing over flask is microframework and django is not and all other topics related to pros and cons.
I'm not going to start comparing these two great frameworks, but I've created a django-microsite project for a test.
I break down the settings.py, urls.py, views.py in one file. I googled about all these and finally achieved it.
Below is sample code. filename : django-microsite.py
Requirement : Django Framework and Python

#########################################
# A Pythonic Django Microsite example
# Inspired by Flask and Bottle framework
#########################################


import sys
from django.conf import settings

settings.configure(
 DEBUG=True,
 SECRET_KEU='secretkeygoeshere',
 ROOT_URLCONF = __name__,
 MIDDLEWARE_CLASSES = (
     'django.middleware.common.CommonMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
 ),
)

from django.conf.urls import url
from django.http import HttpResponse
from django.shortcuts import render_to_response

def index(request):
 return HttpResponse("Hey see this! It's working.")

urlpatterns = ( 
 url(r'^$', index,name="index_page"),
)

if __name__ == "__main__":
 from django.core.management import execute_from_command_line
 execute_from_command_line(sys.argv)


You will think, how to run this ? It's a django project :) use runserver command.
python django-microsite.py runserver
you can find the code on https://github.com/ashish2py/django-microsite.
for configuration, please read the following doc django-configurations

I'll explain about the codes later by updating the same blogpost.
Read more...

December 24, 2014

Things which I do after installing Crunchbang #! Linux.

December 24, 2014 0
Configure your Crunchbang #!.

5 Things that I do after installing the #! and this will also help you.
If you are a developer then obviously you require more packages to install in your system.

1. Update your #! source-list to install non-free packges.

ashish@crunchbang:~$ sudo nano /etc/apt/sources.list

## CRUNCHBANG
## Compatible with Debian Wheezy, but use at your own risk.
deb http://packages.crunchbang.org/waldorf waldorf main
deb-src http://packages.crunchbang.org/waldorf waldorf main

## DEBIAN
deb http://http.debian.net/debian wheezy main contrib non-free
deb-src http://http.debian.net/debian wheezy main contrib non-free

## DEBIAN SECURITY
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main
Now update your #! crunchbang and install 32-bit library packages which is gonna help you with the installation of skype, teamviewer, android development kit etc.

sudo dpkg --add-architecture i386  
apt-get update
sudo apt-get install ia32-libs
#! comes with linux a media player, let's install a Clementine(music player). I prefer this because of it's simplicity.

sudo apt-get install clementine

2. Change your login screen wallpaper. I don't prefer to use default login wallpaer which comes with the #!. So I change it using the below method.

ashish@crunchbang:cd /usr/share/slim/themes
ashish@crunchbang:/usr/share/slim/themes$ sudo thunar
It will open file browser where all the themes are located. Open any one of them and you will find the "background.png", this image file is used as login-background.
I'm going to use "default" theme as my login-theme.
1. Replace "default/background.png" file with your wallpaper images.
2. Rename "default/background.png" to "default/background_backup.png.".
3. Place your desired wallpaper in "default" directory and change your wallpaper name as "background.png".
4. Cross check, make sure you are doing all these stuff inside "/usr/share/slim/themes/default/" directory.
5. If you know little bit photo editing tool "gimp", then you can modify "panel.png" image(your login panel).
6. Activate the theme and logout to check the effect.
Activate : super[windows btn] + space[btn] >>> System >>> User Login Settings >>> select Theme as "default".
3. Beautify your conky.
super[windows btn] + space[btn] >>> Settings >>> Conky >>> edit .conkyrc
Replace your conky settings with the below text.

# conky configuration
#
# The list of variables has been removed from this file in favour
# of keeping the documentation more maintainable.
# Check http://conky.sf.net for an up-to-date-list.
#
# For ideas about how to modify conky, please see:
# http://crunchbanglinux.org/forums/topic/59/my-conky-config/
#
# For help with conky, please see:
# http://crunchbanglinux.org/forums/topic/2047/conky-help/
#
# Enjoy! 
##############################################
# Settings
##############################################
background yes
use_xft yes
xftfont HandelGotD:size=8
xftalpha 0.5
update_interval 4.0
total_run_times 0
own_window yes
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
minimum_size 200 5
maximum_width 220
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
default_color grey
default_shade_color red
default_outline_color green
alignment top_right
gap_x 5
gap_y 45
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale no

TEXT
CPU $alignr ${cpu cpu0}%
${cpugraph cpu0}

MEM $alignc $mem / $memmax $alignr $memperc%
$membar

swap $alignc $swap / $swapmax $alignr $swapperc%
${swapbar}

/ $alignc ${fs_used /} / ${fs_size /} $alignr ${fs_free_perc /}%
${fs_bar /}

global $alignc ${fs_used /home/karlos/global} / ${fs_size /home/karlos/global} $alignr ${fs_free_perc /home/karlos/global}%
${fs_bar /home/karlos/global}

$processes processes ($running_processes running)

NAME $alignr PIDCPU
${top name 1} $alignr ${top pid 1} ${top cpu 1}
${top name 2} $alignr ${top pid 2} ${top cpu 2}
${top name 3} $alignr ${top pid 3} ${top cpu 3}
${top name 4} $alignr ${top pid 4} ${top cpu 4}
${top name 5} $alignr ${top pid 5} ${top cpu 5}
${top name 6} $alignr ${top pid 6} ${top cpu 6}
${top name 7} $alignr ${top pid 7} ${top cpu 7}
${top name 8} $alignr ${top pid 8} ${top cpu 8}
${top name 9} $alignr ${top pid 8} ${top cpu 9}

Inbound $alignr ${downspeed eth0} kb/s
${downspeedgraph eth0}
Outbound $alignr ${upspeed eth0} kb/s
${upspeedgraph eth0}

Wifi Inbound $alignr ${downspeed wlan0} kb/s
${downspeedgraph wlan0}
Wifi Outbound $alignr ${upspeed wlan0} kb/s
${upspeedgraph wlan0}


Alt+F2$alignr Run Dialog
Alt+F3$alignr Alt Menu
Super+space$alignr Main Menu
Super+t$alignr Terminal
Super+f$alignr File Manager
Super+e$alignr Editor
Super+m$alignr Media Player
Super+w$alignr Web Browser
Super+g$alignr Graphics Editor
Super+l$alignr Lock Screen
Super+v$alignr Volume Control
Super+x$alignr Logout
PrtSc$alignr Screenshot

There are more yet to come.... Thanks for reading.
Read more...

November 20, 2014

Signature Spider at National Park.

November 20, 2014 0
I found this spider at Borivali National Park. When I clicked the pic I never knew that this is the signature spider, on of my friend told me about this so I googled it and here is the information. For me it's a WEB DEVELOPER who don't forget to mention copyrights on his web-site. :) These spiders make certain zig-zag pattern on web therefore also known as writer or signature spider.This spider weaves four zig zag stripes in its web, and holds its legs together in pairs. It holds its legs in pairs to disguise itself as a four legged creature; it does this to not appear to look like a spider. These spiders have many names around the world, they are known as an Argiope, a Black and Yellow Garden Spider or a Writing Spider in North America. It is known as Wasp Spider in Germany and the rest of Europe and the St Andrews Cross spider in Austrailia. They know it as KOGANE-GUMO in Japan and east asia. There are 75 different species of this spider but they all look the same. Their colours vary in between their stripes but they all keep the black and yellow stripes, They distribute also Sri Lanka, Maldives,India, Pakistan.Their habitats are Moist Deciduous forests in the sunny parts.
Read more...

June 26, 2014

Alternative of google-map API, making request more than 2500.

June 26, 2014 0
I was looking for a free api which can help me to get latitude/longitude on the basis of Postcode.

I tested pygeocoder and other api librearies which can help me, but none of them allowed me to query more than 25,000/day cause everyone is belongs to Google.

So I did an old school coding by using Mechanize and BeautifulSoup.
I used http://services.gisgraphy.com/public/geocoding.html. It's a free, I think they are providing 30,000 requests for demo user, I didn't tested 30,000 requests cause I've 29,000 records to generate lat/long. I don't want to waste my hits for a day. I'll test and update here.

Code is not clean, cause it's a test.

Keep Coding .


import mechanize
from bs4 import BeautifulSoup 

for x in xrange(30000):

    print '----------------- searching ---------------'
    br = mechanize.Browser()
    br.open("http://services.gisgraphy.com/public/geocoding.html")
    
    add = '81100'
    con='Malaysia'
    
    br.select_form(nr=0)
    
    br.form["address"] = add
    for i in range(0, len(br.find_control(type="checkbox").items)):
        br.find_control(type="checkbox").items[i].selected =True
    br.form["country"]=["MY"]
    
    print 'hitting --- ',x
    response = br.submit()
    soup = BeautifulSoup(response)
    
    
    links = soup.find_all('li')
    print '--------- getting list ----------'
    
    li = soup.find('div', {'class': 'summary'})
    
    print '---------- looking for latitude and longitude -------------'
    list= []
    children = li.findChildren()
    for child in children:
        list.append(str(child))

    print ' found latitude and longitude at point -->  ',x
    
    latitude = list[0]
    longitude = list[1]
    
    lat = latitude[9+5:len(latitude)-5].split()
    lng = longitude[9+6:len(longitude)-5].split()
    
    print str(lat).replace(',','.')
    print str(lng).replace(',','.')

#for f in br.forms():
#    print f



Source Code : https://bitbucket.org/ashish2py/quickhack/



Read more...

December 03, 2013

Changing wallpapers in Crunchbang #! Linux .

December 03, 2013 0
I'm using crunchbang #! when it was #!-9 around in 2010 , now using #!-11. Between these period I tested out many linux distros but never feel that any linux is stable as #! is now, because it drops Ubuntu and using Debian-stable :) .
As per the heading of this post to change wallpaper in Crunchbang we need to copy paste the wallpapers( images ) into following directory./home/[username]/images/wallpapers/shared/
But "shared" folder is locked, so we need to copy-paste the images as a "sudo" user. Please Follow the steps.
1 Press "alt+f2" then enter "sudo thunar" and enter your password.
2 Now copy your wallpaper(images) and paste it into "/home/[username]/images/wallpapers/shared/" directory.
3 "Right-click" on the desktop and navigate to " settings > Choose Wallpaper ".
4 Now you can easily see the images and set the wallpaper by selecting images and clicking on "apply" button.

Here is my wallpaper link

Wait for the next crunchbang post. Keep Coding :)

Read more...

August 07, 2013

Network Manager not running on Ubuntu12.04 at boot-time

August 07, 2013 0
I was configuring PPPOE connection manually by command line using "sudo pppoeconf", and by mistake I changed some settings. So after I restarted my laptop, I was getting an boot time error "waiting for network configuration" and after some time "waiting upto 60 seconds more for network configuration.."
Also there are possibilities to get this error while upgrading the system.
I solved these problem by using 2 methods.
After logged into Ubuntu.
Open terminal, type
First : not a permanent solution
  sudo /etc/init.d/network-manager start
Second : permanent solution
  sudo gedit /etc/network/interfaces
And remove the lines after
  auto eth0
  iface eth0 inet loopback
Make sure to save the file before closing it.Reboot the system
Read more...

July 31, 2013

Sending Email : Django Terminal Test.

July 31, 2013 1

While I was making contact-us form in PHP for my client then I thought about to do same in Djago-Python. Target was to get the form input and email it. Here I'm going to test only the DjangoEmail module using shell.
Edit settings.py with code below:
    #settings for django email( writing for gmail)
    EMAIL_USE_TLS = True
    EMAIL_HOST = 'smtp.gmail.com'
    SITE_HOST = '127.0.0.1:8000'
    DEFAULT_FROM_EMAIL ='Dotorbit Team '
    EMAIL_PORT = 587
    EMAIL_HOST_USER = 'dotorbit.dev@gmail.com'
    EMAIL_HOST_PASSWORD = 'your-password'
    #Run interactive mode, 
    python manage.py shell
    #Import the EmailMessage module,
    >>>from django.core.mail import EmailMessage
    #Send the email,
    >>>email = EmailMessage('Subject goes here ', ' Body goes here ', to=['reciever@email.com'])
    >>>email.send()
    >>>1

This will return 1, means everything is working fine. form and view, I'll write in next post.
Read more...

December 08, 2012

Configure LAMP and How to fixing Apache issue ServerName issue.

December 08, 2012 0

There are lots of tutorials available for Apache,MySql and PHP installation on linux and Windows. But I prefer the simple one for Debian.Command will not work without caret(^). sudo apt-get install lamp-server^ Now,This will download and install the Apache,PHP and MySql. step1 : test "localhost" in browser. Works !!
step2 : run the apache2 service. $ sudo service apache2 restart
or
$ sudo /etc/init.d/apache2 restart
If it works !! You are champ.
For me ,It throws an error --
codeleaf@dotorbit-backbox:/media/Development/Developer/HEROKU/DotOrbit$ sudo service apache2 restart
* Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
I googled about it and found the solution,
By default "httpd.conf" file will be blank. Now, simply add the following line to the file. $ sudo gedit /etc/apache2/httpd.conf Add the following line to "httpd.conf" and save it . ServerName localhost Now restart the server. $ sudo service apache2 restart
$ * Restarting web apache 2 server
... waiting
Woohoo.. It works
step3 - Test whether PHP is working or not ? Create "test.php" in /var/www/ directory. $ sudo gedit /var/www/test.php and add following line " < ?php phpinfo(); ? > step 4 - Test localhost/test.php and you will get the info page. e.g "PHP Version 5.3.10-1ubuntu3.4"
Read more...

May 27, 2012

How to install 686-PAE kernel on Linux Mint Debian Edition-i486?

May 27, 2012 2

Before using Linux Mint Debiab Edition(LMDE) I was using Ubuntu-12.04LTS .
It was my worst experience with ubuntu. It looks like Ubuntu12.04LTS is not matured. I've faced lots of problems like touchpad freezes , after updates system get crashed , lots of bug reporting etc . Anyway I'm not anti-ubuntu .
In frustration I removed Ubuntu12.04 and installed LMDE on my Dell Vostro-1540 (core-i3).
Since the kernel is built with LMDE 201 109 486, then the default kernel is only able to detect a single core . Result was ,I've experienced some sort have 'hang' during my Android application development .
I decided to install the kernel 686, exactly 686-PAE. This kernel is the best solution for running LMDE on 'multi-core' system .
No need to worry about it .
Simple steps are here to install linux-kernel-i686.
 $ sudo apt-get update
 $ sudo apt-get install linux-image-686 linux-headers-686-pae
for i486.
 $ sudo apt-get update
 $ sudo apt-get install linux-image-486 linux-headers-486
for amd64.
 $ sudo apt-get update
 $ sudo apt-get install linux-image-amd64 linux-headers-amd64
Read more...

May 22, 2012

April 29, 2012

send tweets from pythom , using python-twitter ...simple way ( 5 steps )

April 29, 2012 0
Today morning around 4am , when I was designing my codeleaf blog site I just thought of tweeting something interesting but I dont wanted to tweet from the twitter Page. Instead, I wanted to tweet from terminal where I was doing other programming stuffs... So I decided to write a python-script to Post a tweet from my Terminal .
So I googled about "tweet from python" and I came across python-twitter and I started following Wiki for implementing that thing .
Steps that need to be followed are as follows ::
1. Register an Application on Twitter Dev-Center
Set your application's "Access level : Read, write, and direct messages "
Otherwise you will get an error for "Access level : Read Only"(TwitterError: Read-only application cannot POST.)

2. Copy your
 consumer_key = 'consumer_key',
 consumer_secret = 'consumer_secret',
 access_token_key = 'access_token_key',
 access_token_secret = 'access_token_secret'
and paste on some TextEditor ,because we will use this later .
3. Installation ( Python-Twitter )

Install the dependencies:
If your python-version > python2.7.2 , then skip first two library and directly install the third-one(python-oauth2) .
Download the latest python-twitter library from:
Extract the source distribution and run:
 $ python setup.py build
   $ python setup.py install
 

4 . create a python file and write the below code on it .

  
 import twitter
 api  = twitter.Api()

 #tweet
 def tweet(tweet_status):
  status = api.PostUpdate(tweet_status)
  print "Posted successfully"
  print status.text

 # OAuth authentication
 api = twitter.Api(
  consumer_key = 'consumer_key',
  consumer_secret = 'consumer_secret',
  access_token_key = 'access_token_key',
  access_token_secret = 'access_token_secret'
 )

 tweet_status = raw_input("Tweet Status : ")
 tweet(tweet_status)

5. Thats it . Now run the script , and Terminal(command prompt) will ask you to enter your "Tweet" .

 $ python pytweet.py 
   Tweet Status : I love Python-Twitter .
   Posted successfully
 Tweet Status : I love Python-Twitter .

Read more...

April 18, 2012

Deploying Django app on Heroku platform

April 18, 2012 1
Before using Heroku , I used Django-nonrel with Appengine , Django-Appengine , Google Appenigne , FluxFlex , Gondor hosting and Alwaysdata . From my knowledge I think Django-app deployment on Heroku is easier than others . When I was following official tutorial of django app deployment on Heroku , I got some errors so I googled and fixed all those errors . This is Heroku's official Documentation .Deploy Djang on heroku . Lets Start 
Install Heroku-toolbelt
wget -qO- https://toolbelt.heroku.com/install.sh | sh
1.Create folder called Heroku and move into it . $ mkdir Heroku && cd Heroku
2. Create a virtualenv and Activate your virtual environment
$ virtualenv --no-site-packages venv $ source venv/bin/activate This will change your prompt to include the project name. (You must source the virtualenv environment for each terminal session where you wish to run your app.)
3. Install dependencies with pip: $ pip install Django psycopg2 This step was failed for me , During Installation of "pip install psycopg" I got "Error: pg_config executable not found."
Linux User(debian based) : Make sure that u have "libpq-dev python-dev " packages installed . I used following command to install the above libraries $ sudo apt-get install libpq-dev python-dev for Windows User click here :
4.Great job ! Now Its time to create a Django app in the current directory: $ django-admin.py startproject greetingheroku .
5. Test the app runs locally by starting up the Django development webserver: $ python manage.py runserver
6. Create a pip requirements file which declares our required Python modules: $ pip freeze > requirements.txt All packages required should be declared explicitly in requirements.txt:
  $ nano requirements.txt
    Django==1.4
    psycopg2==2.4.5
now type ctrl+o(save) and ctrl+x(exit)
7. Commit to Git create .gitignore file and Exclude Virtualenv , because we don't want to push our local envirnment to heroku :
  $ nano .gitignore
    venv
    *.pyc
use ctrl+o(save) & ctrl+x(exit) . You will use Git to deploy code to Heroku
8. Initialize a Git repo and commit the project (if you aren’t already tracking your project with Git):
  $ git init
    Initialized empty Git repository in /home/ashish/developer/Heroku/greetingheroku/.git/
  $ git add .
  $ git commit -m "my django app" 
  $ heroku keys:add

9. Deploy to Heroku Create an app on the Cedar stack:
  $ heroku create --stack cedar
    Creating simple-spring-9999... done, stack is cedar
    http://simple-spring-9999.herokuapp.com/ | git@heroku.com:simple-spring-9999.git
    Git remote heroku added

10. Deploy your app: $ git push heroku master If "git push heroku master" gives you an error something like "heroku does not appear to be a git repository ." Then run the following command to add heroku as a git repository . Mostly this will happen , when u changed your app name from "Heroku dev center " $ git remote add heroku git@heroku.com:your-app-name.git
11. Check to see that your web process is up, to start $ heroku ps View your logs: $ heroku logs
12. finally visit your app on the web. $ heroku open
13. Syncing Database $ heroku run python manage.py syncdb 14. Using Django Shell $ heroku run python manage.py shell
For more information please visit > Deploy Djang on heroku .
My heroku app dotorbit.herokuapp.com
Read more...

November 05, 2011

How To Reset Unity in Ubuntu-11.10 .

November 05, 2011 0
Today I installed Ubuntu-11.10 and I was playing around with Ubuntu, trying different themes, different engines, different window managers,file-managers(dolphin-one of my favorite), etc.
After installing CompizFusion, I started playing with themes and bymistakly, I removed my unity-panel.
So there was no shortcut to run app with "Alt+f2" key.
Thank god,I had installed Awn-dock , then I started firefox and googled about it and finally I did reset my unity2d settings to default.

Reset Unity
If you want to reset Unity (this will only reset the Unity settings in CompizConfig Settings Manager and leave the other CCSM settings intact), open a terminal (or press ALT + F2) and enter:
$ unity --reset
Reset Unity Launcher icons
$ unity --reset-icons
Here are some useful links which is more about " Customization "
Install Docky
Docky will be added under Accessories in the Applications menu.
$ sudo add-apt-repository ppa:docky-core/ppa
$ sudo apt-get update
$ sudo apt-get install docky

*If i will find some more interesting links,i will post here .
Read more...

September 08, 2011

How to add django-color-schemes in KomodoEditor ?

September 08, 2011 0
I'm using komodo6.1 with dark colour scheme for my django-python coding,I've tried to make many different schemes manually but all no-one can excites me to use then i googled about "django-python colour theme for Komodo Edit".

I came across the  "KolorModo.com" site and I like DjangoInspire theme on KolorModo. I love the color combination and the background because it looks like django's theme.This Site has lots of colour schemes are available.

I downloaded the "djangoinspire.ksf" file,this themes looks like below,


To install it on your Komodo Edit,

1. Download the file from "KolorModo/djangospire"
2. Save the djangoinspire.ksf file.
3. Copy the file to Komodo’s application data folder for you account.
For Windows XP >
C:\Documents and Settings\<username>\Application Data\ActiveState\KomodoEdit\\schemes
4. For Linux >
$/home/<username>/.komodoedit/<version>/schemes/
5. Start Komodo Edit.
6. Go to Edit -> Preferences -> Fonts and Colors then select a scheme from the dropdown menu
7. Enjoy.
Read more...

August 12, 2011

Simple way to get the "facebook message stream" on "Google+" .

August 12, 2011 0
Get the facebook message stream on google plus.

Download the extension Click here
For Google-Chrome Chrome extension
It's simple, easy to set up.
This extension support Internet Explorer 7+, Firefox 3.5+ and Chrome.
Install the extension and restart the WebBroser,you will get the "Facebook" button on Google+.

Here is my G+ account snapshot .
















Tutorial video from CrossRider


To get more information Click here


Read more...

June 13, 2011

Django-nonrel with mongoDB

June 13, 2011 2
Hi friends , I'm working with Borgets Solution. Recently I made a simple application on Django-nonrel with backend mongoDB.
Django-nonrel is an independent branch of Django that adds NoSQL database support to the ORM.Read more about the django-nonrel Django-Nonrel ...
I feel its somewhere bit complex to configure mongodb as backend on "Django-Nonrel" and make "Django-Administration" working.
lets start.

Installation


If you like to use Virtual-environment , then you can use it . Install pymongo
You need setuptools for installing pymongo , dont worry dunring installation of Pymongo , autamatically setuptools should be downloaded .
  • Download pymongo
    extract pymongo.tar.gz folder and install .
    	ashish@developer:~/Downloads $  tar -xzvf pymongo.tar.gz
    	ashish@developer:~/Downloads $  cd pymongo 
    	ashish@developer:~/Downloads/pymongo $ sudo python setup.py install 
    
  • or you can use $ easy_install pymongo

Install djangotoolbox
  • Download SourceCode of djangotoolbox and extract it > DjangoToolBox
    extract django-toolbox zip file and install .
    	ashsih@developer:~/Downloads$ unzip wkornewald-djangotoolbox-.zip
    	ashsih@developer:~/Downloads$ cd wkornewald-djangotoolbox-
    	ashsih@developer:~/Downloads/wkornewald-djangotoolbox- $ sudo python setup.py install
    

Install Django-nonrel
  • Download SourceCode of Django-Nonrel and extract it > Django-Nonrel
    	ashsih@developer:~/Downloads $ unzip wkornewald-django-nonrel-.zip 
    	ashsih@developer:~/Downloads $ cd wkornewald-django-nonrel- 
    	ashsih@developer:~/Downloads/wkornewald-django-nonrel- $ sudo python setup.py install 
    
Install MongoDB
  • Download MongoDB from official site of MongoDB and extract the Tar.gz package .
    I am using 32-bit . please prefer MongoDB installation on Linux
    	ashsih@developer:~/Downloads$ tar -xzvf mongodb-linux-.tgz 
    	ashsih@developer:~/Downloads$ cd mongodb-linux- 
    
  • Create a data directory
    	$ sudo mkdir -p /data/db/
    	$ sudo chown `id -u` /data/db
    
    You can also tell MongoDB to use a different data directory, with the --dbpath option.
    Run and connect to the server make sure that you are in MongoDB package folder .
    	ashsih@developer:~/Downloads$ cd mongodb-linux-/bin/
    	ashsih@developer:~/Downloads/mongodb-linux-/bin/ $ ./mongod				
    

Install django-mongodb-engine
  • Download source code of django-mongodb-engine from here > Django-MongoDB-Engine and extract it .
    	ashish@developer:~/Downloads$ unzip django-nonrel-mongodb-engine-.zip 
    	ashish@developer:~/Downloads$ cd django-nonrel-mongodb-engine-
    	ashish@developer:~/Downloads/django-nonrel-mongodb-engine-$ sudo python setup.py install
    

Phew !!! .. finally we completed .... :)

Let's start developing Django applcation


create new django Project
	$ django-admin.py startproject djangobookmarks
	$ cd djangobookmarks/ && python manage.py runserver
Open your browser and check > "localhost:8000" address
create new django application
	$ django-admin.py startapp bookmarks

Configuration

Database setup is easy as native django with sqlite3. Open "settings.py" and setup database "mongodb_engine".

DATABASES = {
'default': {
'ENGINE': 'django_mongodb_engine', # Add 'postgresql', 'mysql', 'sqlite3' etc.
'NAME': 'newdb', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '27017', # Set to empty string for default. Not used with sqlite3.
}
}

Lets start mongodb engine

$mongod
$mongo

Run server
$python manage.py runserver



Yeah,Now start developing your application as other databases.Here I'm not going to teach in details.please read "django docs"

Django Admin Activation.

If you want to use Django Administration,Than it is bit tricky..
Open "settings.py" and add "django.contrib.admin" in INSTALLED_APPS.

INSTALLED_APPS = (
...default apps...
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin doc.:
# 'django.contrib.admindocs',
'bookmarks',
)

Open "urls.py" and "uncomment the lines to enable django administration"

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

from bookmarks.views import *

urlpatterns = patterns('',
.....
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)

Here is my "models.py" .

from django.db import models
from django.contrib.auth.models import User

# Create your models here.
class Link(models.Model):
url=models.URLField(unique=True)
def __unicode__(self):
return self.url

Bookmark(models.Model):
title=models.TextField(max_length=100)
user=models.ForeignKey(User)
link=models.ForeignKey(Link)
def __unicode__(self):
return self.title


create "admin.py" in application directory and register the models in django admin.

#!/usr/bin/env python
from django.contrib import admin
from bookmarks.models import Link,Bookmark #Models
admin.site.register(Link)
admin.site.register(Bookmark)


It will works without "django site".

Django Site registration
For more information visit django's documentation for The "Site" framework

Open "settings.py" and set SITE_ID for django_site(django administration).

Note :
Default SITE_ID is "1".That's for SQL based databases,but NoSql based DB generates Alphanumeric object Id.so we need to set that id here.
Open terminal and write.(for mongoDB)

$mongoexport -d (database_name) -c django_site
#example
$mongoexport -d mydatabase -c django_site

now,copy "id={}" and set SITE_ID="xxxxxxxxx" in "settings.py".
SITE_ID = '4dbea69bc9ce44192b00001d'



$python manage.py mongod
$python manage.py syncdb
$python manage.py runserver



Download Django_bookmark code
Thanking You !!!
Read more...

April 18, 2011

Testing with Google Appengine.

April 18, 2011 0
Yesterday in the evening ,
When i was seated in front of my computer than suddenly something comes in my mind.....
From a long time i never used Google App Engine ,Lets check my appengine knowledge.
With Appengine Docs i started writing the application and finally i did.

check it-Greeting App Engine

Its a simple greeting application based on GAE's helloworld example...
Also U can use ur gmail id to post greetings.

Lol.... ;-)
Still I know GAE..ye yippeee.....
Source code on bitbucket.

Read more...

April 13, 2011

My first play-framework application : DentoX2 - A System For Dentist

April 13, 2011 0
Hey everyone,
Thanks to all members of Play-googlegroups and my friends Priyanka & Pavan who help me to solve my technical doubts.
Finally i finished my Academic project in Play-Framework,It was most pleasing days of developing application with play,and really the result was probably the best.
The Project is "Dental Clinic Management System" with the name DentoX2 (suggested by priyanka )

UI theme for Administrator>Pillu-Web app theme

For more information
on DentoX2 visit the link....
    1. Dentox2 design
    2. DentoX2 Presentation
    3. DentoX2 Documentation

    Website :



    Blogging support :



    Administration Login :



    Administration Home Page :



    Patient List :



    Patient Form : with JQuery Date and time picker.



    FaceSheet :



    Appointment :with JQuery Calender .




    Read more...

    July 16, 2010

    Another adventures and experiments with Play on my Linux !!

    July 16, 2010 0
    Hey everyone,
    Along with my recent adventures and experiments with Play, I decided to force myself to become more proficient with Play. For all those who don't know what “Play” is , I will give u all a just of it..

    The Play framework is a clean alternative to bloated Enterprise Java stacks.

    I think its very nice framework to make web-based application by using any editor like Komodo or Emacs,and it provides libraries for database access,error handling,templating framework and session management,security,an automated test suite, a shiny web interface and an administration area and it also provides the codes for reuse.


    so, if u still feel like I need to be set straight,any suggestion or any question,Send me an email.

    Anyway,
    I have been using Linux since about 2007.
    I had JAVA self extracting file which was given to me by Mr. Jitendra Vishwakarma.
    So,I tried to run play in my Linux with the help of documentation.
    I had java ,but "i don't know how to install it?"

    Ever since I first started using Linux, I have been using Terminal for installing most of software's and applications...even today I do so.. ,
    really I don't know many commands of Linux.


    So, once again I started searching on Google about "how to install java in Linux ". I found solution for it and I dabbled with a tutorial here and there...and finally I get the java on my Path.

    My recent experiment with JAVA Installation has proved to be very fruitful, I say so to myself.

    If anyone is much interested to know "how to install the java in Linux?",then follow the instruction and commands.

    ~~~~~~~~~~~~~~~~~~~~~~~~
    Download and copy jdk-6-linux-i586.bin to $HOME/src (or a location of your choice).
    type>>
    % su -

    (some linux use "su" command and some don’t. So in such a case, use the "sudo" command and it will prompt you for a enter admin password. once u have entered the password it will not ask u again and again during the editing, deleting, moving the files .)

    "I don't know much about the RedHat and the Solaries,but as I have worked on ubuntu based linux, it accept the "sudo" command...."

    ~~~~~~~~~~~~~~~~~~~~~~~~

    #su (or sudo)
    # mkdir /usr/java (if it doesn't exist or start the line with "sudo")
    # mv $HOME/src/jdk-6-linux-i586.bin /usr/java (if it doesn' start line with "sudo")
    # cd /usr/java (if it doesn' start line with "sudo")
    # chmod +x jdk-6-linux-i586.bin (if it doesn' start line with "sudo")
    # ./jdk-6-linux-i586.bin

    ~~~~~~~~~~~~~~~~~~~~~~~~
    It will extract all the files of java and install it in your system.
    ~~~~~~~~~~~~~~~~~~~~~~~~
    Set the PATH and JAVA_HOME environment variables: (/etc/profile, $HOME/.bashrc or $HOME/.bash_profile).

    PATH=$PATH:/usr/java/jdk1.6.0/bin
    JAVA_HOME=/usr/java/jdk1.6.0
    export PATH

    ~~~~~~~~~~~~~~~~~~~~~~~~
    for more information about Java Installation try this "Enterprise Java for Linux HOWTO".

    After installing the java,I started developing the Simple Web-Application in Play.
    Here are the steps of creating application.

    Installation of play is very simple.
    Just download the latest binary package from the Play download page and unzip it to any path. Play uses command line a lot for creating,running and testing the application,it’s better to use a Linux or MacOS ,if you are using windows,its also fine.

    Play is correctly installed,now start Creating a Play application is pretty easy and fully managed by the Play command line utility.That allows for standard project layouts between all Play applications.

    Open a new command line and type:

    $python play new helloworld

    It will creates a new helloworld application.
    now we need to test it if its working or not?

    For run the application>Open a new command line and type:

    $python play run helloworld/

    Play will now load the application and start a Web server on port 9000.
    You can see the new application by opening a browser to
    http://localhost:9000


    Here is the snap of the simple " hello-world "application and "how to set the JAVA_HOME path in snap"

    And follow the Documentation for making "helloworld" application.

    Click On the Image
    To See The Tested "Hellowrld" Application.

    Read more...

    Follow Us @soratemplates