I've got a fairly basic doctestable file:
class Foo():
"""
>>> 3+2
5
"""
if __name__ in ("__main__", "__console__"):
import doctest
doctest.testmod(verbose=True)
which works as expected when run directly through python.
However, in iPython, I get
1 items had no tests:
__main__
0 tests in 1 items.
0 passe...
Hi,
is there anything built-in in Django templates that will allow me to compare two values? Similar to ifequal.
If not - what is the best solution for this?
...
HI guys. I was trying to configure my django project in a subdirectory of the root, but didn't get things working.(LOcally it works perfect). I followed the django official django documentarion to deploy a project with mod_python. The real problem is that I am getting "Page not found" errors, whenever I try to go to the admin or any view...
I'm attempting to expose a single API call using three different authentication mechanisms: django's login_required , HTTP basic auth, and OAuth. I have decorators for all three but can't quite figure out how to have them all get along smoothly.
The required logic is to allow access to the view if any of the decorators / authentication ...
Okay so I have this mode:
class Posts(db.Model):
rand1 = db.FloatProperty()
#other models here
and this controller:
class Random(webapp.RequestHandler):
def get(self):
rand2 = random.random()
posts_query = db.GqlQuery("SELECT * FROM Posts WHERE rand1 > :rand2 ORDER BY rand LIMIT 1")
#Assigning values for Django templa...
I have just learned that splitting model classes into different files breaks many of django's built-in functionalities.
I am coming from a java background. There, it is not accepted as a good practice writing very long class files. But django's enforcement of single file for all model classes will probably cause programmer to write ver...
I have a small multithreaded script running in django and over time its starts using more and more memory. Leaving it for a full day eats about 6GB of RAM and I start to swap.
Following http://www.lshift.net/blog/2008/11/14/tracing-python-memory-leaks I see this as the most common types (with only 800M of memory used):
(Pdb) objgraph....
I have a custom field called HourField, which lets you enter "1:30" to represent one and a half hours. The clean() method turns it into 1.5 for the FloatField in the model. This all works fine. Now I'm having a problem where when I want to create a formset, that field gets rendered as "1.5" instead of "1:30" which is what I want.
Is the...
In my models.py i have something like:
class LocationGroup(models.Model):
name = models.CharField(max_length=200)
class Report(models.Model):
name = models.CharField(max_length=200)
locationgroups = models.ManyToManyField(LocationGroup)
admin.py (standard):
admin.site.register(LocationGroup)
admin.site.register(Report)
...
Hello,
How can i redirect user to different app on save ?
I have two app say app1 and app2.If user click on save in app2 then it should be redirected to app1 rather then the default page
I want in admin not in customform
...
#models.py
class Legs:
left = TextField(default='-')
right = TextField(default='-')
class Animal:
#possibly, more fields
description = TextField()
front_legs = OneToOneField(Legs, related_name='front_animal')
back_legs = OneToOneField(Leg,s related_name='back_animal')
#forms.py
class LegsForm(ModelForm):
""""
Not needed...
I'm building a site where registered users can upload files. Those files are then served via Apache. Only users who are logged in should be able to access those files.
I have read this page but it seems that people would have to log in twice to access both the site and the media, each time using a different type of login box.
Is there ...
After installing Djapian ten different ways and following 5 completely different tutorials, it's time to ask for help.
Ok, the vanilla way: I go to http://code.google.com/p/djapian/wiki/Installation and follow the instructions to a tee, installing Djapian 2.0.
joshua@staging-server:/var/www$ python pri*/pro*/my*/manage.py shell
Python ...
I'm having a problem with TinyMCE and Django. I'm using the TinyMCE module for basic Form field support.
The problem comes when TinyMCE wants to use a popup:
In my development environment, static pages are served from
static.wdw.ms.local:8888
and Django pages are served from wdw.ms.local:8000
(In production, the .local:XXXX is dropp...
I'm trying to get a queryset to issue its query over a different DB connection, using a different cursor class. Does anyone know if that's possible and if so how it might be done? In psuedo-code:
# setup a new db connection:
db = db_connect(cursorclass=AlternateCursor)
# setup a generic queryset
qset = blah.objects.all()
#...
Hi there,
I have a model that holds user address. This model has to have first_name and last_name fields since one would like to set address to a recipient (like his company etc.). What I'm trying to achieve is:
if the fist_name/last_name field in the address is filled - return simply that field
if the fist_name/last_name field in the...
url(r'^([a-zA-Z0-9/_-]+):p:(?P<sku>[a-zA-Z0-9_-]+)/$', 'product_display', name='product_display'),
url(r'^(?P<path>[a-zA-Z0-9/_-]+)$', 'collection_display', name='collection_display'),
That's my current regex:
My problem is this: I want to be able to match the product_display's regex without using :p: in the regex. I can do this by pu...
In the same way that Articles can have a relationship with Sites (OneToOne/ManyToMany), I'd like to be able to assign a User permission to work on a certain Site (or Sites).
...
I'm trying to model a "what's hot right now" like function for a video library (i.e a Most-viewed related to time - Clustering views (in time) will cause a higher rating), but I can't quite get my head around how do to it properly in Django without causing a multitude of database queries. I realize there's no one right answer to this, bu...
I am attempting to use the far future expires method to cut down my site's load time.
However when I access static files in firefox, the server still responds with HTTP/1.x 304 NOT MODIFIED. The request shouldn't even be made if the files are cached right?
Here are the relevant httpd.conf lines I have for apache 2.2:
LoadModule expir...