Hi, I think you may need to add a queryset() method on your InlineModelAdmin and filter by user.
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-options You can use the example from ModelAdmin: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.queryset - Andrew. On Thursday, December 6, 2012 2:50:43 PM UTC+8, Detectedstealth wrote: > > See the attachment. > > The dropdown is showing a work experience that was added by a different > user. The dropdown should only show work experience that was entered for > the user that is currently being edited. > > The purpose is to be able to add/edit recommendations that are linked to > any work experience the selected user has entered. > > On Wednesday, December 5, 2012 9:38:37 PM UTC-8, Chris Cogdon wrote: >> >> When you say "recommendations inline lists work history from all users" >> do you mean its showing up as multiple fields, or do you mean the selection >> box that gives you the option of adding a recommendation from the list of >> possible recommendations ? >> >> >> On Wednesday, December 5, 2012 8:06:55 PM UTC-8, Detectedstealth wrote: >>> >>> Hi, >>> >>> I have a custom user who has work experience, and for each work >>> experience there can be multiple recommendations for the work experience. >>> >>> My models: >>> CustomUser >>> >>> class WorkExperience(models.Model): >>> >>> user = models.ForeignKey(CustomUser, verbose_name=_('user profile')) >>> >>> company = models.CharField(_('company name'), max_length=150) >>> >>> location = models.CharField(_('job location'), max_length=150) >>> >>> position = models.CharField(_('position'), max_length=150) >>> >>> start_date = models.DateField(_('started position')) >>> >>> end_date = models.DateField(_('finished position'), null=True, >>> blank=True) >>> >>> description = models.TextField(_('details'), help_text=_('Write a >>> short description about your role and experience when at this position.' >>> )) >>> >>> >>> >>> last_edited = models.DateTimeField(default=timezone.now) >>> >>> date_added = models.DateTimeField(default=timezone.now) >>> >>> >>> >>> def __unicode__(self): >>> >>> return "%s - %s" % (self.company, self.position) >>> >>> >>> >>> class Recommendation(models.Model): >>> >>> user = models.ForeignKey(CustomUser, verbose_name=_('recommended >>> user')) >>> >>> workexperience = models.ForeignKey(WorkExperience, verbose_name=_('work >>> experience')) >>> >>> details = models.TextField(_('recommendation')) >>> >>> approved = models.BooleanField(default=False) >>> >>> is_spam = models.BooleanField(default=False) >>> >>> date_added = models.DateTimeField(default=timezone.now) >>> >>> admin.py >>> >>> class ExperienceInline(admin.StackedInline): >>> >>> model = WorkExperience >>> >>> fieldsets = ( >>> >>> (None, { >>> >>> 'fields': ( >>> >>> 'company', >>> >>> 'position', >>> >>> 'location', >>> >>> ('start_date','end_date'), >>> >>> 'description' >>> >>> ) >>> >>> }), >>> >>> ) >>> >>> class RecommendationInline(admin.StackedInline): >>> >>> model = Recommendation >>> >>> class CustomUserAdmin(UserAdmin): >>> >>> ... >>> inlines = [ExperienceInline, RecommendationInline] >>> >>> >>> The problem is the recommendations inline lists work history from all >>> users instead of showing only the work experience from the selected user. >>> Is it possible to list only work experience belong to the selected user? >>> >>> -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Ygha58BbmcoJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.