image05 image06 image07

300x250 AD TOP

Pages

Gallery

SEARCH

Popular Posts

Ads

Web hosting

Feature Label Area

Friday, 31 January 2014

Tagged under: , , , ,

HORIZONTAL MENUS TUTORIAL



MENUS (TUTORIAL)

HORIZONTAL MENUS




Horizontal menus can be easily created with use of an unordered list and anchor tags.

Simple Horizontal Menu:                               



A horizonatal menu with no sub-menu or dropdowns is the easiest to create. First create an unordered list (ul) with the menu items as the list-items (<li>). Inside the list-items create anchor tags (<a>) to hold the links. Here is the html for that:


   <ul>
<li><a href="#">Home</a></li>
<li><a href="#">Contact</a></li> 
<li><a href="#">About Us</a></li>
<li><a href="#">Profile</a></li> 
</ul>

This creates a simple list of items. Now the only thing left to make it look like a horizontal menu is to add css to the html. To make the list horizontal add list-style-type : none; the list horizon to the <ul> style. To make it look as above, below is the final html and css:

Html:
<div class="horizontal1">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Contact</a></li>
<li class="selected"><a href="#">About Us</a></li>
<li><a href="#">Profile</a></li>
</ul>
</div>

CSS:

.horizontal1{
  display: inline-block;
}

.horizontal1 ul{
  font-size: 14px;
  width:100%;
  padding:0;
  margin:0;
  list-style-type:none;
}

.horizontal1 a{
  float:left;
  width:6em;
  text-decoration:none;
  padding:7px 5px 5px 5px;
  background: #232323;
  color: #FFF;
  border-bottom: solid thick #232323;
}

.horizontal1 a:hover {
  background-color: #1b7d5a;
  border-bottom: solid thick #1b7d5a;
}

.horizontal1 a:visited {
  color: #FFF;
}

.horizontal1 li {display:inline;}

.horizontal1 .selected a{
  border-bottom: solid thick #1b7d5a;
}


Horizontal Menu With Dropdown:     



A horizontal menu with dropdowns can be created using multiple unorderd lists (<ul>). Required depth can be achieved as per needed. Below is the required html code:

Html:
<div class="horizontal2">
<ul>
<li><a href="#" class="top_parent">Item 1</a>
<ul>
<li><a href="#">Item 1.1</a></li>
<li><a href="#" class="parent">Item 1.2</a>
<ul>
<li><a href="#">Item 1.2.1</a></li>
<li><a href="#">Item 1.2.2</a></li>
<li><a href="#">Item 1.2.3</a></li>
</ul>
<li><a href="#">Item 1.3</a></li>
</ul>
</li>
</ul>
<ul>
<li class="selected"><a href="#" >Item 2</a></li>
</ul>
<ul>
<li><a href="#" >Item 3</a>
<ul>
<li><a href="#">Item 3.1</a></li>
<li><a href="#" class="parent">Item 3.2</a></li>
<li><a href="#">Item 3.3</a></li>
</ul>
</li>
</ul>
<ul>
<li><a href="#" >Item 4</a></li>
</ul>
</div>

CSS:

.horizontal2
{
  font-size: small;
  font-family: arial, helvetica, sans-serif;
  display: inline-block;
}
    
.horizontal2 a
{
  text-align: center;
  display:block;
  white-space:nowrap;
  margin:0;
  padding: 0.3em;
}
  
.horizontal2 a:link, .horizontal2 a:visited, .horizontal2 a:active 
{
  color: white;
  background-color: #232323;   
  text-decoration:none;
  font-size: 15px;
}
  
.horizontal2 a:hover          
{
  background-color: #1b7d5a;
  
.horizontal2 a.top_parent, .horizontal2 a.top_parent:hover 
{
  background-position: right center;
  background-repeat: no-repeat;
}
  
.horizontal2 a.parent, .horizontal2 a.parent:hover  
{
  background-position: right center;
  background-repeat: no-repeat;
}

.horizontal2 ul
  {
  list-style:none;
  margin:0;
  padding:0;
  float:left;
  width:9em; 
  }

.horizontal2 .selected a{
  border-bottom: solid thick #1b7d5a;
}

.horizontal2 li
{
  position:relative;
  min-height: 1px;    
  vertical-align: bottom;   
}

.horizontal2 ul ul
{
  position:absolute;
  z-index:500;
  top:auto;
  display:none;
  padding: 1em;
  margin:-1em 0 0 -1em;
}

.horizontal2 ul ul ul
{
  top:0;
  left:100%;
}

div.horizontal2 li:hover
{
  cursor:pointer;
  z-index:100;
}

div.horizontal2 li:hover ul ul,
div.horizontal2 li li:hover ul ul,
div.horizontal2 li li li:hover ul ul,
div.horizontal2 li li li li:hover ul ul
{display:none;}

div.horizontal2 li:hover ul,
div.horizontal2 li li:hover ul,
div.horizontal2 li li li:hover ul,
div.horizontal2 li li li li:hover ul
{display:block;}














Tuesday, 29 October 2013

Tagged under: , , , , , , , , , , , , , , ,

COOL PYTHON BLOGS TO FOLLOW

Ok so here is the list of Python blogs that I have been following since the time I started learning python. I have found out some pretty amazing stuff here. So, I guess a list of them would be helpful for those searching for some good resources:


          This is the official blog of Guido van Rossum (creator of Python, not that this mention was needed).


          This blog presents you with a tour of the Python standard library through short examples which is           pretty good for begginers. Well, ofcourse there is Python Docs to serve this purpose but it has               some nice explanations too.

          This one is not a blog in itself but has link to all nice and essential python blogs to explore.


          This is the blog of Armin Ronacher: Writer of the Flask and Werkzeug frameworks.

          It is a series of articles on the history of the Python programming language and its community.
          (It was started by Guido van Rossum)

Monday, 28 October 2013

Tagged under: , , , , , , , ,

ENEWSPAPER DOWNLOAD SCRIPT(PYTHON) [COOL PYTHON SCRIPTS]



Here is a simple script that took me about 30 minutes to write which can download the Hindi newspaper Dainik Jagran in pdf format. The code is a bit messy but it does the work. Here is the code:

import os
from pyPdf import PdfFileWriter, PdfFileReader
import urllib2
import shutil

def make_date():
 from datetime import date, timedelta
 today = str(date.today())
 yesterday = date.today() - timedelta(1)
 yesterday = yesterday.day
 if yesterday in range(10):
  yesterday = '0'+str(yesterday)
 else:
  yesterday = str(yesterday)
 return ''.join(reversed(today.split('-'))), yesterday

def create_dir(city):
 directory = 'C:\Users\Agnes\Desktop\' + city
 if os.path.exists(directory):
  shutil.rmtree(directory)
 os.makedirs(directory)
 os.chdir(directory)

def make_pages(city, url_date, url_val, city_short, page):
 continue_loop = True
 output = PdfFileWriter()
 while continue_loop:
  url = "http://epaper.jagran.com/epaperimages/" + url_date + "/" + city + "/" + url_val + city_short +"-pg"+ str(page) +"-0.pdf"
  print url
  try:
   request = urllib2.urlopen(url)
   print("Downloading %s page number %s \n" % (city, page))
   data = request.read()
   FILE = open('Page-' + str(page) + '.pdf', "wb")
   FILE.write(data)
   FILE.close()
   input1 = PdfFileReader(file("Page-"+ str(page)+".pdf", "rb"))
   output.addPage(input1.getPage(0))
  except urllib2.HTTPError, err:
   if err.code == 404:
    continue_loop = False
  page +=1
 outputStream = file("Full-Paper.pdf", "wb")
 output.write(outputStream)
 outputStream.close()
 print("Download for %s completed!!!\n\n\n" % city)


def make_pdf(city):  
 make_pages(city, date, day) 
 
 
########################## Execution ##################
date, day =  make_date()

create_dir("Delhi")
make_pages("delhi", date, day, 'del', 1)
create_dir("Jhajjar")
make_pages("panipat", date, day, 'jhr', 1)
It can download any city edition provided by the website. All you need to do is replace the city name in "make_page" function at the end to the the desired city name. The 4th parameter of the function needs to be setaccording to url city code. The 5th parameter takes the page no. argument which can be set to any page.

The code makes use of additional module that doesn't come within python libraries which is pyPdf to save the PDFs.

This code is Windows OS specific but can used on any other platforms easily by changing the directory paths in the code.


Sunday, 27 October 2013

Tagged under: , , , , , , , ,

MY FAVORITE RICH TEXT EDITORS


So recently I have been trying to add a Rich Text Editor to my Django-powered project. I tried and tested the vast majority of editors available. Here are the ones that are easy to use and I liked the most:


  1. TinyMCE
  2. It is free, opensource and has an active community for its maintenance. This is how it looks.
    To include it it in your project all you need to do is add this to your template:
<html>
<head><!-- CDN hosted by Cachefly -->
<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
<script>
        tinymce.init({selector:'textarea'});
</script>
</head>
<body>
        <textarea>Your content here.</textarea>
</body>
</html>
TinyMCE comes with many free plugin which you can use to customise your editor.

Pros:

  • Opensource and free
  • Large Community
  • Easy to use

Cons:

  • The only problem with TinyMCE is to write your own handler for file/image uploads which can be quite frustrating and time consuming if you are new to it.
Also, if you are looking for an app that already does the all the work for you then here it is.


2. The next one to make it to the list is Redactor.
This is how it looks:


The best possible way to use it according to me is with this django-app. It does all the work for you from adding redactor your project to file handling and much more. All you need to do is download and add it your INSTALLED_APPS setting.
Pros:

  • Beautiful and complete. One stop for all your needs.

Cons:

  • Not FREE


Tagged under: , , , , ,

DJANGO-TAGGING TUTORIAL



In this post I write a simple django app which uses the django-tagging app. First you need to install django-tagging from this link or you can install it with pip installer using:

pip install django-tagging

Next add 'tagging' to INSTALLED_APPS setting in settings.py. To add tags to a your model say 'Entry' in models.py, you'll need to import a custom field type defined in django-tagging, so add following import statement in yout models.py file:

from tagging.fields import TagField

Next, create the Entry model:

from django.db import models
class Entry(models.Model):
   title = models.CharField(max_length=250)
   slug = models.SlugField(unique_for_date='pub_date') 
   body = models.TextField()
   tags = TagField()

This implements the tagging feature. Next you can setup your views and templates.


Tagged under: , , ,

COOL DJANGO APPS TO EXPERIMENT WITH

Its been three months since I started learning Django. Here is one of the  Django-Packages that I have experimented with since then:

 Django-Oscar

Its an full-fledged ecommerce app and is very well documented. Its features include:
  1. Paying for an order with multiple payment sources (e.g., using a bankcard, voucher, gift card and business account).
  2. Complex access control rules governing who can view and order what.
  3. Supporting a hierarchy of customers, sales reps and sales directors - each being able to “masquerade” as their subordinates.
  4. Multi-lingual products and categories.
  5. Digital products.
  6. Dynamically priced products (eg where the price is provided by an external service).
Its easy to setup and comes with a sandbox site and a demo site. 
The only problem I have come across is product images uploading which is caused due to improper settings of 'MEDIA_URL' and 'MEDIA_ROOT'. Also, it may arise because of the wrong installation of Pillow. If PIL is installed in your system before and without pillow then you may encounter this problem. I resolved this with the help of this handy tutorial.
Here are some of the screenshots of the sandbox site:


Saturday, 14 September 2013

Tagged under:

ABOUT ME

Something About Me and my Blog

Thanks for landing on the ‘About’ page of djangoexplorations.
Welcome.

About PYTHON-DJANGO EXPLORATIONS


It was started back in September 2013
The main purpose of starting this blog is to share my learning and explorations with other interested fellas.
My name is Ninja Agnes — the person behind this blog.
A Computer Science student and a young part-time blogger.
Here I’m sharing some random things about me here. You might find them interesting! :D

Some random things  about me.

  • I like to spend most of my time online, if I am not online I’ll be either taking rest or playing games with my friends
  • I love Blogging but I do not like writing.
  • I don’t like to watch movies though I like to listen music (sometimes!)
  • I love internet. I’ve got so many fans and followers, best friends, online reputation, money.

Contact Info

I always do my best to respond to all the emails.
You can also contact me on
Thank you for dropping by.:)