Admin formfield_for_foreignkey is defeating me

2017-07-12 Thread Mike Dewhirst
Would some kind person please point out where I'm going wrong with formfield_for_foreignkey? (Admin code below) It is not eliminating records with display = False from otherwise available choices in a dropdown list as outlined below. Essentially, the dropdown is showing everything.

[Not solved] formfield_for_foreignkey difficulty

2015-11-26 Thread Mike Dewhirst
On 27/11/2015 8:38 AM, Mike Dewhirst wrote: On 27/11/2015 8:19 AM, Mike Dewhirst wrote: On 26/11/2015 11:24 PM, Mike Dewhirst wrote: I have formfield_for_foreignkey working for a couple of fields in my substance model but find a brick wall when I try to restrict choices in an inline m2m

[Solved] formfield_for_foreignkey difficulty

2015-11-26 Thread Mike Dewhirst
On 27/11/2015 8:19 AM, Mike Dewhirst wrote: On 26/11/2015 11:24 PM, Mike Dewhirst wrote: I have formfield_for_foreignkey working for a couple of fields in my substance model but find a brick wall when I try to restrict choices in an inline m2m foreign key. It was late last night and I forgot

Re: formfield_for_foreignkey difficulty

2015-11-26 Thread Mike Dewhirst
On 26/11/2015 11:24 PM, Mike Dewhirst wrote: I have formfield_for_foreignkey working for a couple of fields in my substance model but find a brick wall when I try to restrict choices in an inline m2m foreign key. It was late last night and I forgot to mention Django 1.8.7 Admin, Python 3.4

formfield_for_foreignkey difficulty

2015-11-26 Thread Mike Dewhirst
I have formfield_for_foreignkey working for a couple of fields in my substance model but find a brick wall when I try to restrict choices in an inline m2m foreign key. The m2m relation is substance<-m2m->substance where any substance can be an ingredient in a mixture (also a substance).

Re: Django formfield_for_foreignkey

2014-11-02 Thread Collin Anderson
Hi Cristian, Maybe you could call traceback.print_stack() to see why it's being called each time. Thanks, Collin -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email

Django formfield_for_foreignkey

2014-10-29 Thread Cristian Vargas
As i stated in this question i am trying to follow something like this example . Basically i am tryin

formfield_for_foreignkey: kwargs is empty?

2013-12-11 Thread Antony Seedhouse
I'm trying to use formfield_for_foreignkey to filter the dropdown of a ModelAdmin with Django 1.6 on Python 2.7.6, following https://docs.djangoproject.com/en/1.6/ref/contrib/admin/ class CupAdmin(admin.ModelAdmin): ... # hide inactive distributions def formfield_for_forei

Re: formfield_for_foreignkey field.name-generic

2011-08-17 Thread Tom Evans
On Wed, Aug 17, 2011 at 8:54 AM, andrepar wrote: > How can apply DRY to the following lines? > > def formfield_for_foreignkey(self, db_field, request, **kwargs): >        if db_field.name == "field1": >            kwargs["queryset"] = > Fi

formfield_for_foreignkey field.name-generic

2011-08-17 Thread andrepar
How can apply DRY to the following lines? def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == "field1": kwargs["queryset"] = Field1.objects.filter(owner=request.user) return super(MyModelAdmin, self).form

formfield_for_foreignkey

2011-08-17 Thread andrepar
def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == "field1": kwargs["queryset"] = Field1.objects.filter(owner=request.user) return super(MyModelAdmin, self).formfield_for_foreignkey(db_field, request, **kwar

Question regarding formfield_for_foreignkey in admin.py

2011-03-20 Thread Matteius
I have an Announcement class in my project that has an author field. I have a custom formfield_for_foreignkey which gets all staff users for any super user, and I do the same thing for other staff users. Ideally however we could set this to be only the existing author (if any) or the current user

Re: formfield_for_foreignkey: how to know if we are modifyng an entry

2010-06-27 Thread drakkan
On 27 Giu, 18:00, Walt wrote: > I'm not sure if it works in this context but have you tried > self.instance.id? No it doesn't work in my context, other ideas? > > Walt > > -~ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this gro

Re: formfield_for_foreignkey: how to know if we are modifyng an entry

2010-06-27 Thread Walt
I'm not sure if it works in this context but have you tried self.instance.id? Walt -~ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send ema

formfield_for_foreignkey: how to know if we are modifyng an entry

2010-06-26 Thread drakkan
Hi, I'm customizing the django admin and I need to do a particular filter for a foreign key if I'm modifying a model, I'm using the following method, it works but it seems to me an hack, is there a better way to do the same thing? def formfield_for_foreignkey(self, db_field, re

Trying to limit a ForeignKey in the admin site, but formfield_for_foreignkey isn't working

2009-12-15 Thread Eric Chamberlain
', related_name='provider_partners', blank=True, null=True) class PartnerAdmin(ModelAdmin): list_display = ('name', 'type', 'url') list_filter = ('type',) exclude = ['calls','providers' ] raw_id_fields = ('ad

Re: formfield_for_foreignkey

2009-09-02 Thread Václav Řehák
I'm not sure I understand your question. The formfield_for_foreignkey method takes the field_name as an argument so you can have different (or same) action for any of them, see http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey

formfield_for_foreignkey

2009-09-02 Thread paulh
I have used formfield_for_foreignkey in the admin and it works well. However, suppose you have two foreign keys in your model and you want to restrict the choices on both of them? Paul Hide --~--~-~--~~~---~--~~ You received this message because you are

formfield_for_foreignkey help needed.

2009-01-18 Thread mweather
e example in the admin docs: class AffiliateProductAdmin(admin.ModelAdmin): def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == "product": kwargs["queryset"] = Product.object.filter(pk=?) return db_field.formfie