I'm using django.test.client.Client to test whether some text shows up when a user is logged in. However, I the Client object doesn't seem to be keeping me logged in.
This test passes if done manually with Firefox but not when done with the Client object.
class Test(TestCase):
def test_view(self):
user.set_password(passwor...
I have a requirement to print an existing PDF file from a Python script.
I need to be able to specify the printer in the script. It's running on Windows XP.
Any ideas what I could do?
This method looks like it would work except that I cannot specify the printer:
win32api.ShellExecute (
0,
"print",
filename,
None,
".",
0
...
I am writing a program in Python, and want to get it to make the OS open the current working directory, making for instance Windows open explorer.exe and navigating to the wanted directory. Any ideas on how to do this?
The directory is already given by os.getcwd.
Cross platform methods preferred :)
...
I want to make a function that converts mixed numbers and fractions (as strings) to floats. Here's some examples:
'1 1/2' -> 1.5
'11/2' -> 5.5
'7/8' -> 0.875
'3' -> 3
'7.7' -> 7.7
I'm currently using this function, but I think it could be improved. It also doesn't handle numbers that are already in decimal representation
def mixedt...
I'm currently involved in a hardware project where I am mapping triangular shaped LED to traditional bitmap images. I'd like to overlay a triangle vector onto an image and get the average pixel data within the bounds of that vector. However, I'm unfamiliar with the math needed to calculate this. Does anyone have an algorithm or a link th...
Can someone help me with Localization? I put {% trans "..." %} in my template, I filled in my django.po after running "makemessages".
#: templates/main_content.html:136
msgid "Go to page"
msgstr "▒~C~Z▒~C▒▒~B▒▒~L~G▒~Z"
#: templates/main_content.html:138
msgid "Page"
msgstr "▒~C~Z▒~C▒▒~B▒"
#: templates/main_content.html:154
msgid "Ne...
heya,
I'm trying to find a decent IDE that supports Python 3.x, and offers code completion/in-built Pydocs viewer, Mercurial integration, and SSH/SFTP support.
Anyhow, I'm trying Pydev, and I open up a .py file, it's in the Pydev perspective and the Run As doesn't offer any options. It does when you start a Pydev project, but I don't w...
I'm using multicast UDP over localhost to implement a loose collection of cooperative programs running on a single machine. The following code works well on Mac OSX, Windows and linux. The flaw is that the code will receive UDP packets outside of the localhost network as well. For example, sendSock.sendto(pkt, ('192.168.0.25', 1600)) ...
I'm brand new to Python and trying to learn it by replicating the following C++ function into python
// determines which words in a vector consist of the same letters
// outputs the words with the same letters on the same line
void equivalentWords(vector <string> words, ofstream & outFile) {
outFile << "Equivalent words\n";
// ...
I want to someone to be able to login using twitter,
Is there a framework that you have used to do this?
Thanks
...
I'm working through the book "The Definitive Guide to Django" and am stuck on a piece of code.
This is the code in my settings.py:
ROOT_URLCONF = 'mysite.urls'
I have the following code in my urls.py
from django.conf.urls.defaults import *
from mysite.views import hello, my_homepage_view
urlpatterns = patterns('', ('^hello/$', hell...
I wrote this code:
import urllib
proxies = {'http': 'http://112.65.135.54:8080/'}
opener = urllib.FancyURLopener(proxies)
r = opener.open("http://www.python.org/")
print r.read()
and when I execute it this program works fine, and send for me source code of python.org But when i use this:
import urllib
proxies = {'http': 'http://80...
I am trying to install postgrepsql to cygwin on a windows 7 machine and want it to work with django.
After built and installed postgrepsql in cygwin, I built and installed psycopg2 in cygwin as well and got no error, but when use it in python with cygwin, I got the "no such process" error:
import psycopg2
Tracebac...
Hey guys ! i'm fairly new at web development scene and i was wondering if you guys can help me break up the pros and cons of using python django vs asp.net mvc besides the maturity level of its framework. I have intermediate experience with JAVA. As of right now, i'm leaning towards python but i just wanted to make sure i am making the r...
Code in test.py:
class Base(object):
def __init__(self, l=[]):
self.l = l
def add(self, num):
self.l.append(num)
def remove(self, num):
self.l.remove(num)
class Derived(Base):
def __init__(self, l=[]):
super(Derived, self).__init__(l)
Python shell session:
Python 2.6.5 (r265:79063, A...
I know Python but I've never used Django.
What do I need to know about Django 1.2 to port my typical PHP CRUD web application in one weekend? (Yes I've read Joel Spolsky's Netscape article :-))
I'm reading this tutorial right now and it's excellent. I'm already playing around with inspectdb to generate my models from the existing sch...
I want to be able to call a global function from an imported class, for example
In file PetStore.py
class AnimalSound(object):
def __init__(self):
if 'makenoise' in globals():
self.makenoise = globals()['makenoise']
else:
self.makenoise = lambda: 'meow'
def __str__(self):
return self.makenoise...
Hi Guys,
Could someone tell me a way to get a system language in the ISO 639 (3 letter code) format in a cross platform way?
Thanks.
I found a list of three letter country codes.
...
Am running into ValueError, here is the full traceback, the end of which is:
Exception Type: ValueError at /admin/blog/post/add/
Exception Value: invalid literal for int() with base 10: 'treef'
I'm using AutoSlugField from django-command-extensions.
I am trying to get django-tagging working, this is my models.py:
class Post(mod...
I am creating an application that lets users login using Google, Facebook and the website's native login. The site is being built in Python / Django.
What would be the best way to handle login, session management and user authentication?
I do not want to use the in-built Django user management. I am using Django very sparingly(URLs, te...