Is there any pre-done widget to incorporate into my django code which create an very special widget?
Let's say that I have a database with
# this is simplified code to keep only problematic stuff
#model.py
class Company(models.Model):
name = CharField( max_length = 50)
class Person(models.Model):
name = CharField( max_length = 26 , blank = True)
company = ForeignKey ( Company , related_name = 'Persons' )
class Meeting(models.Model):
person = ForeignKey ( Person , related_name = 'Meetings' )
# So, there is a company in the meeting through myItem.person.company.name
So each Person have its own Company and requiring a Company in the Meeting class create a diamond of the death, since the met company is determined by the met Person. But, in real life, before meeting someone I have to go to his/her Company.
I would like to csreate a javascript widget for the 'person' field in the Meeting class that enable to select the contact in two waves.
<select Company> <Select Person in the company in the "Select Company" field>
- First, select the company. OnClick, the second Select fields is updated removing all the contact which are not related to the selected company.
- Then the user can choose between the few remaining contacts in the selected company.
Well, after if the user click again on the first select to choose an other company, I am sure that complicated thinks should happen but let us make it simple at first approach...
I have looked several times on the Internet to find a snippet that can do, but I have to mention that I am experiencing some difficulties to grasp the exact way to find that kind code...
Do you know about such a project, widget? Is there any incorporated and easy way to do that?