I have a general question regarding the ordering in
the ManyRelatedManager object. For example,
There are two classes in my model: one is
called Book for books and another is Author for authors.
A many-to-many field is defined in class Book
authors = models.ManyToManyField(Author)
In database, the many-to-many relationship
is de...
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...
Hi (sorry for my bad english :p)
Imagine these models :
class Fruit(models.Model):
# ...
class Basket(models.Model):
fruits = models.ManyToManyField(Fruit)
Now I would like to retrieve Basket instances related to all fruits.
The problem is that the code bellow returns Basket instances related to any fruits :
baskets = Baske...
Suppose my models.py is like so:
class Character(models.Model):
name = models.CharField(max_length=255)
is_the_chosen_one = models.BooleanField()
I want only one of my Character instances to have is_the_chosen_one == True and all others to have is_the_chosen_one == False . How can I best ensure this uniqueness constraint is re...
Model: http://dpaste.com/96349/
View:
def game_list(request):
return render_to_response('games/game_list.html',
{ 'object_list': GameList.objects.published.all().order_by('position')})
Template:
AttributeError at /games/
'Manager' object has no attribute 'published'
Would seem my view does...
I need create the following relationship:
One "Rule" can have many users, but one user can be only one rule.
Using ForeignKey and a ModelForm, I get a select box to select just ONE user, but I want to select many users. It's not a ManyToMany relationship because one user never can be more than one rule.
Here are my model definitions:...
I'm developing a portfolio application. Within this application, I have a model called "Project" which looks something like this:
class Project(models.Model):
...
images = models.ManyToManyField(Image)
...
so, basically, this Project can contain a set of images (any of these images may belong to another Project as well).
...
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 guys, im trying moderation comment form the book of James Bennett, i think that all is fine, but the moderation comment is just for SPAM and the comments are public.. so , how ill put the comments always not public, i need that just the administrator can do public the comments.
Thanks
import datetime
from Paso_a_Paso.akismet import...
Hello (please excuse me for my bad english ;) ),
Imagine the classes bellow:
models.py
from django import models
class MyModel(models.Model):
content_type = models.ForeignKey(ContentType, verbose_name=_('content type'))
object_id = models.PositiveIntegerField(_('object id'))
content_object = generic.GenericForeignKey('con...
Actually, somewhere in the view:
dif = datetime.timedelta(days=1)
today = datetime.date.today()
yesterday = today - dif
ex = Fact.objects.filter(fecha_fact__lte=today ,fecha_fact__gte=yesterday )
It results to this SQL Query:
SELECT `facts_fact`.`id` ...
FROM `facts_fact`
WHERE (`facts_fact`.`fecha_fact` >= 2009-09-21 AND `facts_fac...
I'm attempting to extend django's contrib.auth User model, using an inline 'Profile' model to include extra fields.
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
class Profile(models.Model):
user = models.ForeignKey(User, unique=True, related_name='profil...
Hello.
I'm trying to implement row-based security checks for Django models. The idea is that when I access model manager I specify some additional info which is used in database queries so that only allowed instances are fetched from database.
For example, we can have two models: Users and, say, Items. Each Item belongs to some User an...
I have a situation where I want to offload an xml fragment (an atom event) each time a model instance is saved, updated or deleted. The fragment needs to include information about related objects.
I can't find an event that lets me use information from related objects after saving my object. The post_save signal seems o be triggered bef...
I have a model:
class MyModel(models.Model):
...
def save(self):
print "saving"
...
def delete(self):
print "deleting"
...
The save()-Method is triggered, but the delete() is not. I use the latest svn-Version (Django version 1.2 pre-alpha SVN-11593), and concerning the documentation at http://w...
Hello,
I'm learning Django and I have a problem. I want to have django user profile where the user can add some objects (he can add more than one) e.g. his addresses, his products and theirs description and so on. I've no idea how to do that. Thanks for any help.
Best regards,
LH
...
EDIT!!! - The casting of the value to a string seems to work fine when I create a new object, but when I try to edit an existing object, it does not allow it.
So I have a decimal field in one of my models of Decimal(3,2)
When I query up all these objects and try to set this field
fieldName = 0.85
OR
fieldName = .85
It will throw a ...
I have a table called Mytable in home/models.py and using django aep
I reference is as Mytable.all().
It shows up in the Data Viewer as home_mytable
Now, for some urls within app.yaml I have a separate handler
that processes these requests. (This is in fact a google wave
robot handler).
Within this handler I want to reference the tabl...
As an example, let's say there's a Tshirt model on a shopping site, and it will have "summary" markup with a thumbnail, name and price:
<div>
<a href="detailspage">Awesome TShirt!</a>
<img src="thumbnail.jpg" />
<span class="price">$55.99</span>
</div>
Since this will be on many different pages, I don't want to have to typ...