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.:)
Tagged under:

PRIVACY POLICY

PRIVACY POLICY


This Privacy Policy governs the manner in which DJANGO EXPLORATIONS collects, uses, maintains and discloses information collected from users (each, a "User") of the http://djangoexplorations.blogspot.in/ website ("Site"). This privacy policy applies to the Site and all products and services offered by DJANGO EXPLORATIONS.

Personal identification information

We may collect personal identification information from Users in a variety of ways, including, but not limited to, when Users visit our site, subscribe to the newsletter, and in connection with other activities, services, features or resources we make available on our Site.. Users may visit our Site anonymously. We will collect personal identification information from Users only if they voluntarily submit such information to us. Users can always refuse to supply personally identification information, except that it may prevent them from engaging in certain Site related activities.

Non-personal identification information

We may collect non-personal identification information about Users whenever they interact with our Site. Non-personal identification information may include the browser name, the type of computer and technical information about Users means of connection to our Site, such as the operating system and the Internet service providers utilized and other similar information.

Web browser cookies

Our Site may use "cookies" to enhance User experience. User's web browser places cookies on their hard drive for record-keeping purposes and sometimes to track information about them. User may choose to set their web browser to refuse cookies, or to alert you when cookies are being sent. If they do so, note that some parts of the Site may not function properly.

How we use collected information

DJANGO EXPLORATIONS may collect and use Users personal information for the following purposes:
  • - To improve our Site
    We may use feedback you provide to improve our products and services.
  • - To run a promotion, contest, survey or other Site feature
    To send Users information they agreed to receive about topics we think will be of interest to them.
  • - To send periodic emails
    We may use the email address to respond to their inquiries, questions, and/or other requests. If User decides to opt-in to our mailing list, they will receive emails that may include company news, updates, related product or service information, etc. If at any time the User would like to unsubscribe from receiving future emails, we include detailed unsubscribe instructions at the bottom of each email.
How we protect your information

We adopt appropriate data collection, storage and processing practices and security measures to protect against unauthorized access, alteration, disclosure or destruction of your personal information, username, password, transaction information and data stored on our Site.

Sensitive and private data exchange between the Site and its Users happens over a SSL secured communication channel and is encrypted and protected with digital signatures.

Sharing your personal information

We do not sell, trade, or rent Users personal identification information to others. We may share generic aggregated demographic information not linked to any personal identification information regarding visitors and users with our business partners, trusted affiliates and advertisers for the purposes outlined above.

Google Adsense

Some of the ads may be served by Google. Google's use of the DART cookie enables it to serve ads to Users based on their visit to our Site and other sites on the Internet. DART uses "non personally identifiable information" and does NOT track personal information about you, such as your name, email address, physical address, etc. You may opt out of the use of the DART cookie by visiting the Google ad and content network privacy policy at http://www.google.com/privacy_ads.html

Changes to this privacy policy

DJANGO EXPLORATIONS has the discretion to update this privacy policy at any time. When we do, we will revise the updated date at the bottom of this page. We encourage Users to frequently check this page for any changes to stay informed about how we are helping to protect the personal information we collect. You acknowledge and agree that it is your responsibility to review this privacy policy periodically and become aware of modifications.

Your acceptance of these terms

By using this Site, you signify your acceptance of this policy. If you do not agree to this policy, please do not use our Site. Your continued use of the Site following the posting of changes to this policy will be deemed your acceptance of those changes.

Contacting us

If you have any questions about this Privacy Policy, the practices of this site, or your dealings with this site, please contact us at:
DJANGO EXPLORATIONS
http://djangoexplorations.blogspot.in/
ninjaagnes@gmail.com

This document was last updated on September 14, 2013

Privacy policy created by Generate Privacy Policy