Managed to do it by overriding the form:
class ActivityAdminForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ActivityAdminForm, self).__init__(*args,
**kwargs)
self.fields['place'].queryset = ....
class ActivityAdmin(admin.ModelAdmin):
form = ActivityAdminForm
On Jan 21, 6:16 pm, Hazzadous <[email protected]> wrote:
> Seehttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri...
>
> Just make kwargs['queryset'] as you need it. You may also consider
> refactoring your Place, and moving some properties to separate
> entities where it makes sense and f you still hit the memory issue.
>
> On Jan 21, 3:17 pm, ekampf <[email protected]> wrote:
>
>
>
> > I have two models: Activity and Place.
> > The Activity model has a ReferenceProperty to the Place model.
>
> > This was working fine until the Place table started growing and now
> > when trying to edit an Activity via django admin I get a memory error
> > from Google (it doesnt happen if I remove that field from the Activity
> > admin's fieldsets)
>
> > The widget used to edit the RefrenceProperty uses Place.all() to get
> > the possible values.
> > As both Activity and Place are sharded by a city property I would like
> > to optimize the wodget's choice query from Place.all() to just the
> > relevant places, for example Place.all().filter("city =", <city of the
> > currently edited Activity>)
>
> > I couldnt find a way to override the query in the docs and I was
> > wondering if the above is even possible? and if so, how?
--
You received this message because you are subscribed to the Google Groups
"app-engine-patch" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/app-engine-patch?hl=en.