On 9/22/06, Benedict Verheyen <[EMAIL PROTECTED]> wrote: > I'm not sure how to do those tasks: > > 1. For a model, i want to allow the user to import settings from another > database. For instance, they fill in a number and hit a link or button, > then data is looked up in another database and some of these values > are then filled in the form so that when the user creates an object, > part of the data is prefilled by fetching from another database. > > How can i fill in some fields of a form with data? > I think i'll need to make my own Manipulator, defining the fields and > passing default values, right? > Is there an example around somewhere for this?
I think ajax tech will very suit for these things. Because you can use ajax to get the user info without leaving current web page, and use javascript to fill the form. And for django, you just need to another view method to return the user data. > > 2. A closely related question in regards to user authentication. > I have a model that also stores the user that is logged. > That user field shouldn't be visible on the form and should be automatically > filled in before the form is saved. > I found something about "follow" that allows one to exclude some fields. > If i then insert the correct user before the data gets validated, is that a > good way of dealing with this problem? > > data = self.get_data(request) > if data: > new_data = data.copy() > -> Insert user <- > errors = self.get_validation_errors(new_data) > > Thanks, > Benedict I'm not very clearly about your problem. But I think if the manipulator need the user_id, just insert such one, but you should know the field_name and value format of user field in data. You can first include the user field, and see the html code to get the field_name of user, then disable the user field, and insert the field_name you got before into the data. -- I like python! My Blog: http://www.donews.net/limodou UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad UliPad Maillist: http://groups.google.com/group/ulipad --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---

