views:

53

answers:

2

I am building a web app that allows our field staff to create appointments. This involves creating a record that contains many foreign keys, of which some come from very large tables. For example, the staff will need to select one of potentially thousands of customers.

What's the best way of doing this in Django?

  • A pop-up box that allows the users to search for customers, gives them the results, the user selects the results, then fills out the main appointment form and then disappears?
  • Changing the appointments form to a customer selection page that then reloads the appointments page with the data in a hidden form? Or holding the data in some session variables?
  • Some from of Ajax approach.
  • A wizard where the flow is: a customer search page, a list of results and they select from results, then a search page for the next option (for example product selection), etc etc

(I'd like to keep it as simple as possible. This is my first Django project and my first web project for more years than I care to remember)

ALJ

+2  A: 

Imho you should consider some kind of autocomplete fields. I think this results in the best usability for the user. Unfortunately, this always involves Ajax. But if you think that all users have JS turned on this is no problem.

E.g.

django-autocomplete

or what is probably more powerful:

django-ajax-selects


If you do the wizard approach, it will take longer for the user to accomplish the task and makes it harder to change selections.

Edit:

Well with django-ajax-selects you can define how the results should look like. So you can e.g. add the address behind the name.

Quote:

Custom search channels can be written when you need to do a more complex search, check the user's permissions, format the results differently or customize the sort order of the results.

Felix Kling
Hi, That would be a good idea, however, I need a little bit more flexibility. For example, many of the customer names are the same (eg Acme Ltd) but with different addresses. Also, I might want to vary the search options. For example search for a freelancer by last work date, or location etc.Sorry for being so difficult!Those references are great btw. I'll be checking them out as well.
Astley Le Jasper
A: 

I have done this before by integrating a jQuery autocomplete plugin. But, seeing as this is your first project and your desire to keep it simple, I suppose you could go with the session data option. For instance, you could show a search page where users could search for and select a customer. You could then store the, say, ID of the selected customer object as session data, and use it to pre-populate the corresponding field in the form when displaying the form. That's what I think offhand.

ayaz