Hi.
I have a query I am trying to perform in the ORM and I'm not sure how to do
it.
I have two models: Target and Property with a one-to-many relationship. One
Target can have many Properties.
I want to list all targets along with their latest properties (as stored
under Property.export_date) so
On Fri, Sep 9, 2011 at 9:28 AM, Pewpewarrows wrote:
> Tim Shaffer's response would have you doing N+1 queries, and having to loop
> through all of your Target objects in-memory. Technically it would work, but
> as soon as you have a decently sized amount of data in there it'd slow to a
> crawl.
>
I'm having trouble with a particular query under the Django ORM.
I have two models: Ticket and Target which have a many-to-many relationship.
I want to list the cross-product of the two.
For instance let say that Tickets Ref001 and Ref002 are both linked to
Targets Tgt001, Tgt002 and Tgt003, I wa
I'm trying to create a custom form field and I'm not succeeding at it so
far.
I want to create an autocomplete field with jquery. It would be used on
models that refer another model via a foreign key where the linked model
have an id and a name (unique). I would like to render the name of the
link
The first one uses a jquery plugin that's discontinued and the second one
works only in the admin.
Also, I feel I'm missing something that's not so complex...
On Wed, Apr 20, 2011 at 10:48 AM, Shawn Milochik wrote:
> Maybe just save your time and re-use some tasty open-source.
>
> Examples:
>
>
I'm trying to create a Form Field, not a Model Field.
The doc about creating a custom one is a tiny paragraph at the end of this
page: http://docs.djangoproject.com/en/1.3/ref/forms/fields/
I read the source code of django but I'm having trouble even finding where
exactly is the value stored in t
So far, I have the following code:
from django.forms.widgets import TextInput
from django.forms.fields import Field
class AutoCompleteWidget(TextInput):
def render(self, name, value, attrs=None):
if hasattr(value, 'name'):
v = value.name
else:
v = Non
wrote:
> On Wed, Apr 20, 2011 at 11:48 AM, Daniel Gagnon
> wrote:
> > So far, I have the following code:
> > from django.forms.widgets import TextInput
> > from django.forms.fields import Field
> > class AutoCompleteWidget(TextInput):
> > def render(self,
ified = DateTimeField(auto_now=True, editable=False)
On Wed, Apr 20, 2011 at 12:35 PM, DrBloodmoney wrote:
> On Wed, Apr 20, 2011 at 12:30 PM, Daniel Gagnon
> wrote:
> > Thanks
> > It still doesn't work though. I found out through logging that value that
> is
> > rec
New code:
from django.forms.widgets import Select
from django.forms.models import ModelChoiceField
from Server_Automation.target_mgmt.models import Target
class AutoCompleteWidget(Select):
def render(self, name, value, attrs=None, choices=()):
logger.debug(value) # Logs 1 (the i
>
>
> It probably is related to the this being a foreign key field and in
> order for it to produce a valid object instance from the Target model,
> it needs a queryset. Try to subclass from ModelChoiceField[1] and see
> if that works.
>
> [1]
> http://code.djangoproject.com/browser/django/trunk/dj
11 matches
Mail list logo