Hello,
For one of my clients, I am generating a clients list from the Django Admin. It splits the clients by status: current, acquired, and past.
Currently, the view code for that list is as follows:
def clients_list(request):
current_clients = Client.objects.all().filter(status='current')[:10]
acquired_clients = Client.objects.all()....
We're deploying Django apps with Apache 2.2 + mod_wsgi. Should we enable mod_deflate in Apache or use Django's GZipMiddleware? Which option performs better?
...
Regarding setting Django's USE_I18N = False in settings.py the documentation say:
A boolean that specifies whether
Django's internationalization system
should be enabled. This provides an
easy way to turn it off, for
performance.
and:
If you don’t use internationalization,
you should take the two seconds to set
USE_...
Hi all,
I've got a django model that contains a manytomany relationship, of the type,
class MyModel(models.Model):
name = ..
refby = models.ManyToManyField(MyModel2)
..
class MyModel2(..):
name = ..
date = ..
I need to render it in my template such that I am able to render all the mymodel2 objects that refer to mymodel. Cu...
I can't find a good clean way to lock a critical section in DJango. I could use a lock or semaphore but the python implementation is for threads only, so if the production server forks then those will not be respected. Does anyone know of a way (I am thinking posix semaphores right now) to guarantee a lock across processes, or barring ...
Is there a good way in Django to convert an entire model to a dictionary? I mean, like this:
class DictModel(models.Model):
key = models.CharField(20)
value = models.CharField(200)
DictModel.objects.all().to_dict()
... with the result being a dictionary with the key/value pairs made up of records in the Model? Has anyone els...
So I'm creating a django app that allows a user to add a new line of text to an existing group of text lines. However I don't want multiple users adding lines to the same group of text lines concurrently. So I created a BoolField isBeingEdited that is set to True once a user decides to append a specific group. Once the Bool is True no on...
I imported forms and tried to give in NETBEANS:
name = forms.
It is supposed to list the elements but its giving the error as:
ValidationError
Django validation and HTML form handling. TODO: Default value for field Field labels Nestable Forms FatalValidationError -- short-circuits all other validators on a form ValidationW...
I want to make a static page which will be shown to the user only if he/she clicks on a link provided in one of my models. I can do this by making a Python page alone and calling it, but I want it be called from Django. The user interface should constructed using the Django API only.
Any suggestions?
...
Suppose I have the following models:
class User(models.Model):
pass
class A(models.Model):
user = models.ForeignKey(User)
class B(models.Model):
a = models.ForeignKey(A)
That is, each user owns some objects of type A, and also some of type B. Now, I'm writing a generic interface that will allow the user to view any obj...
In Django, is there a place I can get a list of or look up the models that the ORM knows about?
...
Hi folks,
I'm using django with apache and mod_wsgi and PostgreSQL (all on same host), and I need to handle a lot of simple dynamic page requests (hundreds per second). I faced with problem that the bottleneck is that a django don't have persistent database connection and reconnects on each requests (that takes near 5ms).
While doing a...
Hi, thats my code:
##### models.py #####
class SinglePoint(models.Model):
attributes = models.TextField(blank=True)
name = models.CharField(max_length=100)
geom = models.PointField() #Kartenposition
objects = models.GeoManager()
class Connection(models.Model):
name = models.CharField(max_length=100)
#points = m...
I want to create a new type of field for django models that is basically a ListOfStrings. So in your model code you would have the following:
models.py:
from django.db import models
class ListOfStringsField(???):
???
class myDjangoModelClass():
myName = models.CharField(max_length=64)
myFriends = ListOfStringsField() #
...
I am trying to setup django-timezones but am unfamiliar on how to go about this. The only info that I have found is here: http://www.ohloh.net/p/django-timezones
class MyModel(Model):
timezone = TimeZoneField()
datetime = LocalizedDateTime('timezone')
I also tried looking through the pinax code or any other projects that us...
I'd like to use a number with a decimal point in a Django URL pattern but I'm not sure whether it's actually possible (I'm not a regex expert).
Here's what I want to use for URLs:
/item/value/0.01
/item/value/0.05
Those URLs would show items valued at $0.01 or $0.05. Sure, I could take the easy way out and pass the value in cents so...
Hi all,
This problem probably has been discussed, but this one is slightly different.
I'm using GWT FormPanel + FileUpload widget to upload a file. My backend is python-django.
My problem is, the GWT FormPanel never trigger the SubmitCompleteHandler event. And on the django log, I can see "Broken pipe", which probably indicates that...
I am doing something like this in myproject.myapp.urls:
from django.conf.urls.defaults import *
urlpatterns = patterns('myproject.myapp.views',
(ur'^$', 'index'),
(ur'^browse/$', 'browse'),
(ur'^request/new/$', 'new_request'),
(ur'^(?P<url_key>[-a-zA-Z0-9]+)/$', 'view1'),
(ur'^(?P<url_key>[-a-zA-Z0-9]+)/asdf$', 'vie...
The Django framework easily handles redirecting when a user fails to log in properly. However, this redirection goes to a separate login page. I can set the template to be the same as the page I logged in on, but none of my other objects exist in the new page.
For example, I have a front page that shows a bunch of news articles. On the ...
As far as I know, for a new request coming from a webapp, you need to reload the page to process and respond to that request.
For example, if you want to show a comment on a post, you need to reload the page, process the comment, and then show it. What I want, however, is I want to be able to add comments (something like facebook, wh...