Hi Guys, Django newbie here, I'm using
render_to_response('example.html', {
'error_message': error_message,
}, context_instance=RequestContext(request))
How do I use the request in the template? (e.g. the request.host etc.)
...
Hi,
Python's math module contain handy functions like floor & ceil. These functions take a floating point number and return the nearest integer bellow or above it. However these functions return the answer as a floating point number. For example:
In [1]: import math
In [2]: f=math.floor(2.3)
In [3]: f
Out[3]: 2.0
What is the safest w...
HI all
I am trying to use SWIG to export C++ code to Python.
The C sample I read on the web site does work but I have problem with C++ code.
Here are the lines I call
swig -c++ -python SWIG_TEST.i
g++ -c -fPIC SWIG_TEST.cpp SWIG_TEST_wrap.cxx -I/usr/include/python2.4/
gcc --shared SWIG_TEST.o SWIG_TEST_wrap.o -o _SWIG_TEST.so -lstdc+...
I have a table describing files with a datetime field. I want to somehow create a report that gives me the number of files grouped by each year, number of files grouped by each year and month and number of files grouped by each year, month and day. I just want records where count(*) > 0. Preferably using the ORM in django or if that`s no...
How can I make as "perfect" a subclass of dict as possible? The end goal is to have a simple dict in which the keys are lowercase.
It would seem that should be some tiny set of primitives I can override to make this work, but all my research and attempts have made it seem like this isn't the case:
If I override __getitem__/__setitem__...
I thought
import sys
sys.path.append("/home/me/mydir")
is appending a dir to my pythonpath
if I print sys.path my dir is in there.
Then I open a new command and it is not there anymore.
But somehow Python cant import modules I saved in that dir.
What Am I doing wrong?
I read .profile or .bash_profile will do the trick.
Do I hav...
from django.conf.urls.defaults import *
from django.conf import settings
from Website.Blog.models import Post
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
index = {
'queryset': Post.objects.all(),
'date_field': 'created_on',
'template_name':...
So, the problem is with creating processes - all of them immediately return with exit code -9.
I tried to use subprocess.Popen module and os.popen2, os.system and some other. Nothing helps.
I'm using python 2.5.
I have a python binary executable built on 32bit platform with 32bit python using pyinstaller. This is very important and I kn...
I'm searching for a free and open source library for electrical network simulation.
In (Per preference order) : Python, Ruby, Javascript, PHP, C++ (with Qt if it exist) or bash (ahah).
Do you know one ?
...
Hello,
Is there an elegant and more Python-like way to check if a package is installed on Debian?
In a bash script, I'd do:
dpkg -s packagename | grep Status
Suggestions to do the same in a Python script?
Thanks,
...
This is the settings.py file for python. I set mysql up via macports (mysql5 & mysqldb) The problem is that I am unsure if I have settings.py configuration correct before I sync the db. Should the PORT be left blank? I believe it should. I know on my Mamp install I have it set to 3306. Thanks....
DATABASES = {
'default': {
'...
Ultimately, my goal is to extend Django's ModelAdmin to provide field-level permissions—that is, given properties of the request object and values of the fields of the object being edited, I would like to control whether or not the fields/inlines are visible to the user. I ultimately accomplished this by adding a can_view_field() method ...
def CreateDirectory(pathName):
if not os.access(pathName, os.F_OK):
os.makedirs(pathName)
versus:
def CreateDirectory(pathName):
if not os.path.exists(pathName):
os.makedirs(pathName)
I understand that os.access is a bit more flexible since you can check for RWE attributes as well as path existence, but is th...
Does gzip work on the python development server for appengine? How can I test this in the future?
Note: I've used Firebug to look at my HTTP requests from the browser, and I see that Accept-Encoding is set to "gzip,deflate".
...
Hello
Assume I have a such model:
class Entity(models.Model):
start_time = models.DateTimeField()
I want to regroup them as list of lists which each list of lists contains Entities from the same date (same day, time should be ignored).
How can this be achieved in a pythonic way ?
Thanks
...
Hi, I have a function that looks like this:
def getColumn(self, name, type, **args):
Now I would like to have a function
def getColumns(self, columns)
where I can pass a tuple that contains a tuple, where each entry in that tuple represents the
arguments to be passed go getColumn. However, I'd like not to have to use named paramete...
I am getting the following errors when running a basic Selenium test script in Python:
======================================================================
ERROR: test_untitled (__main__.TestTesting)
----------------------------------------------------------------------
Traceback (most recent call last):
File "TestTesting.py", line ...
I've tried Google, but I can't find the answer to this simple question.
I hate myself for not being able to figure this out, but here we go.
How do I write an if statement with or in it?
For example:
if raw_input=="dog" or "cat" or "small bird":
print "You can have this animal in your house"
else:
print "I'm afraid you can't h...
I am primarily a PHP developer, and I have been browsing the source code of a few open-source applications recently(Mozilla Bespin in particular), to find that some of them use a Python "back-end." I was just wondering what the purpose of this back-end is. I am assuming it is the same thing as the model in an MVC framework and is used ...
Hi there,
Do you know how I could get one of the IPv6 adress of one of my interface in python2.6. I tried something with the socket module which lead me nowhere.
Thanks.
...