Thank to this post I'm able to easily do count and group by queries in a Django view:
http://stackoverflow.com/questions/327807/django-equivalent-for-count-and-group-by
What I'm doing in my app is displaying a list of coin types and face values available in my database for a country, so coins from the UK might have a face value of "1 f...
Is there a third party django app for eaily importing rss items (specifically wordpress blog posts) in google-code? I've been searching for 20 minutes and can't pull anything up.
Ideally the end result would be something like:
def news(request):
most_recent_post = ??? #get most recent rss post from http://feeds.feedburner.com/codi...
In a view in django I use random.random(). How often do I have to call random.seed()?
One time for every request?
One time for every season?
One time while the webserver is running?
...
Hi guys, im asking again :), i don't know how make this.
My English is not too good, but ill try to asking this:
how ill validate a form and go back to the preview url (the same view form) and show the validation errors?, im asking this because i have 2 form's, the first form's action is going to a second form (POST), but in this secon...
Apologies, I am completely new to Django and Python.
I have 2 questions. First, how would I go about getting the last object created (or highest pk) in a list of objects? For example, I know that I could use the following to get the first object:
list = List.objects.all()[0]
Is there a way to get the length of List.objects? I've trie...
So, I've been noodling about with Django's generic views, specifically the object_list view. I have this in my urls.py:
from django.conf.urls.defaults import *
from django.views.generic import list_detail
from diplomacy.engine.models import Game
game_info = {
"queryset": Game.objects.filter(state__in=('A', 'P')),
"template_obj...
How can I see the current urlpatterns that "reverse" is looking in?
I'm calling reverse in a view with an argument that I think should work, but doesn't. Any way I can check what's there and why my pattern isn't?
...
I've got a URLs pattern like this:
urlpatterns = (
url(r'^$', list_titles, name='list'),
url(r'^(?P<tag>[a-z\-0-9]+?)/$', list_titles, name='filtered-list'),
url(r'^(?P<title>\S+?)/$', show_title, name='title'),
)
The filtered-list and title match the same things.
If there is is a available list of things matching the tag...
Hi to all!
Just begin my Python/Django experience and i have a problem :-)
So i have a model.py like this:
from django.db import models
class Priority(models.Model):
name = models.CharField(max_length=100)
class Projects(models.Model):
name = models.CharField(max_length=30)
description = models.CharField(max_length=150)
...
Hi guys, i have a simple search in my project, but my project is in Spanish , we have a lot of word with accents, and my search dont bring this word with accents.... there's any django /python function for this?
view.py
def search(request):
categorias = Categoria.objects.filter(parent__isnull=True) # menu
query = request.GET.ge...
Hello (please excuse me for my ugly english :p),
Imagine these two simple models :
from django.contrib.contenttypes import generic
from django.db import models
class SomeModel(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField(_('object id'))
content_object = generic.Generi...
I have a simple view that I'm using to experiment with AJAX.
def get_shifts_for_day(request,year,month,day):
data= dict()
data['d'] =year
data['e'] = month
data['x'] = User.objects.all()[2]
return HttpResponse(simplejson.dumps(data), mimetype='application/javascript')
This returns the following:
TypeError at /sc...
Hi,
I want to submit a form (by POST) that will submit N (unknown) user_id's.
Can I make a view receive those ids as a list?
For example
def getids(request,list):
for id in list:
usr = User.objects.get(pk=id);
//do something with it.
usr.save()
Is
for id in request.POST['id']:
even possible?
I'm lookin...
I'd like to build a view that allows the user to get a list of things that are happening around a certain time.
What is the best way to build this request? E.g. If I wanted to get all of the events that are happening right now I could post to /events/2009/09/29/8/23/
That seems rather tedious especially if I want to have multiple date...
Hello - I am using jQuery to do some inline form validation during user registration to prevent form errors after posting by checking to see if:
username is available
email has not already been registered
The idea is to give the user feedback before the form is submitted to prevent frustration. The code is at the bottom.
Question...
In my view to render my template I receive different parameters through my request.
According to these parameters I need to render different "part" in my templates.
For example let say that if I receive in my request
to_render = ["table", "bar_chart"]
I want to render a partial template for table and an other for bar_chart
to_rende...
Hi!
Please regard the following Django models:
ParentModel(models.Model):
...
ChildModel(models.Model):
parent = models.ForeignKey(ParentModel, related_name='children')
Let's assume there is certain subset of all children in the database available as a queryset (call it the 1st set).
Now, I'd like to gain access to the sub...
I have a couple special use cases for Django admin, and I'm curious about other peoples' opinions:
I'd like to use a customized version the admin to allow users to edit certain objects on the site (customized to look more like the rest of the site). At this point users can only edit objects they own, but I'll eventually open this up to...
I have a Postgresql databese with data. I want to create a django app with that database.
How can i import the tables to django models and/or views?
...
I have a situation that requires redirecting users who are already logged in away from the login page to another page. I have seen mention that this can be accomplished with decorators which makes sense, but I am fairly new to using them. However, I am using the django login and a third party view (from django-registration). I do not ...