I would basically like to do the same as this question, but grouping by combinations of two values, rather than just one:
SELECT player_type, team, COUNT(*) FROM players GROUP BY player_type, team;
Does anyone know whether, and how, this is possible in Django? I'm using 1.2.
...
i have a Reply class:
class Reply(models.Model):
reply_to = models.ForeignKey(New)
creator = models.ForeignKey(User)
reply = models.CharField(max_length=140,blank=False)
a replay form:
class ReplyForm(ModelForm):
class Meta:
model = Reply
fields = ['reply']
where New is the Post class (containing users posts...
In Django there is a settings file that defines the middleware to be run on each request. This middleware setting is global. Is there a way to specify a set of middleware on a per-view basis? I want to have specific urls use a set of middleware different from the global set.
...
Django's documentation specifies for each model field type the corresponding default form field type.
Alas, I couldn't find in the documentation, or anywhere else, what form field types are possible per model field type. Not all combinations are possible, right?
Same question for widgets...
...
cache.set(key, value, 9999999)
But this is not infinite time...
...
cache.set(key, Biglist, 3600)
print cache.get(key)
When my "Biglist" is a huge list of lots of content, it doesn't seem to store.
But when I change it to small text like "abc", it stores.
What do I have to configure so that I can set my memcache to accept unlimited size of key/value?
...
We recently launched a new Django-powered website, and we are experiencing the oddest bug:
The site is running under Apache with mod_fastcgi. Everything works fine for a while, and then the URL tag and reverse() functionality stops working. Instead of returning the expected URL, they return "".
We haven't noticed anything in Apache's ...
I'm using the smartif tag from this snippet (I'm holding on with regards to upgrading to 1.2) in my template for a certain boolean field like so:
{% if payment.extends_membership == "True" %}
{% trans "Yes" %}
{% else %}
{% trans "No" %}
{% endif %}
But whatever the value of extends_membership I get only No as the output. What ...
I need to be able to create forms from admin panel. Process would look like this:
I click on "Add form" then I enter email to which the form should be sent and of course several fields (probably thanks to inlines) consisting of field name, type and if it is required. User should be able to view and fill the form and submit it and the dat...
this_category = Category.objects.get(name=cat_name)
gives error: get() takes exactly 2 non-keyword arguments (1 given)
I am using the appengine helper, so maybe that is causing problems. Category is my model. Category.objects.all() works fine. Filter is also similarily not working.
Thanks,
...
Hi,
I want to apply ckeditor on specific textarea in django admin form not on all the text areas.
Like snippet below will apply ckeditor on every textarea present on django form:
class ProjectAdmin(admin.ModelAdmin):
formfield_overrides =
{models.TextField: {'widget': forms.Textarea(attrs={'class':'ckeditor'})}, }
class...
The following code snippet in a Django template (v 1.1) doesn't work.
{{ item.vendors.all.0 }} ==> returns "Test"
but the following code snippet, doesn't hide the paragraph!
{% ifnotequal item.vendors.all.0 "Test" %}
<p class="view_vendor">Vendor(s): {{item.vendors.all.0}} </p><br />
{% endifnotequal %}
Any tips on what's wrong...
Hello, I'm looking for some good app to handle visitor statistics for a Django project. Any hints?
...
instead of User.
def myview(request):
return render_to_response('tmpl.html', {'user': User.objects.get(id=1})
works fine and passes User to template.
But
def myview(request):
return render_to_response('tmpl.html', {}, context_instance=RequestContext(request))
with a context processor
def user(request):
from djang...
Symfony has very useful feature - view component, this is small action code and template that you could embed anywhere inside view template:
<?php include_component('news') ?>
for example in above code mews component executes query in db and display results as block on a site page.
http://www.symfony-project.org/book/1_0/07-Inside-t...
Does anyone have any clue why this doesn't work as expected.
If i use the python shell and do
team.game_set
or
team.games
It returns an error
AttributeError: 'Team' object has no attribute 'game'
If i create a Game object and call
game.home_team
it returns the correct team object
Heres my model
class Team(models.Model):
...
I'm trying to make a form that handles the checking of a domain: the form should fail based on a variable that was set earlier in another form.
Basically, when a user wants to create a new domain, this form should fail if the entered domain exists.
When a user wants to move a domain, this form should fail if the entered domain doesn't ...
Is it possible to have Apache htaccess rewrites take effect before it hits django?
I want to be able to specify RewriteRules in an htaccess file that take precedence over django, and if nothing matches then it gets dispatched to mod_wsgi/django.
We're using apache2 with mod_wsgi and the apache vhost looks like this:
<VirtualHost *:80>...
I have this simple Post model:
class Post(models.Model):
title = models.CharField(_('title'), max_length=60, blank=True, null=True)
body = models.TextField(_('body'))
blog = models.ForeignKey(Blog, related_name="posts")
user = models.ForeignKey(User)
I want that when I insert in the form the links, then these lin...
I'm trying to get the 'hello world' of streaming responses working for Django (1.2). I figured out how to use a generator and the yield function. But the response still not streaming. I suspect there's a middleware that's mucking with it -- maybe ETAG calculator? But I'm not sure how to disable it. Can somebody please help?
Here's ...