1

Im using Django 1.11.6 and trying to limit the choices of projectLeader in my Project class to a list of AbstracUser which have the Projects id in their ManytoMany field workingproject.

class Project in models.py of one app

class Project (models.Model):
    projectLeader = models.ForeignKey('anmeldung.AbstractUser', blank=True, null=True, limit_choices_to={'workingproject': limit},)

class AbstractUser in models.py of application named "anmeldung"

class AbstractUser(AbstractBaseUser, PermissionsMixin):
    workingproject = models.ManyToManyField('szenario.Project', blank=True)

For 'limit' i've used several things like self.id, obj.id but cant figure out whats correct. I'm quite new to Django and all the similar questions i've found didnt help me (could be i just didnt get the answers).

Rubick
  • 139
  • 3
  • 11
  • 1
    Possible duplicate of [Use field value in limit\_choices\_to in Django](https://stackoverflow.com/questions/28901089/use-field-value-in-limit-choices-to-in-django) – user2390182 Dec 12 '17 at 13:52
  • @schwobaseggl i see the similarity but in the example the fields are in the same class, in my case the fields are in different classes. – Rubick Dec 13 '17 at 10:01

0 Answers0