Hi, The best idea I can come up with is to override admin.ModelAdmin's save_model method, which would require only about 10 lines of code and IMHO it's pretty clean.
------------------------ Xia Kai(夏恺) xia...@gmail.com http://blog.xiaket.org -------------------------------------------------- From: "Łukasz Balcerzak" <lukaszbalcer...@gmail.com> Sent: Wednesday, December 30, 2009 7:23 PM To: <django-users@googlegroups.com> Subject: Storing user's IP while using admin site > Hi there, > > I wonder if there is some easy and clean way of achieving this (hooking > custom admin views in urls > maybe is not that hard but definitely is not clean). > > Let's assume we have simply model: > > class Page(models.Model): > title = models.CharField(max_length=64) > author = models.ForeignKey(User) > author_ip = models.IPAddressField() > # ... everything else > > I want to store user's IP. In my custom views its quite easy - > request.META['REMOTE_ADDR']. > > But how about admin site? I would like to edit Page instances in my admin > site > and it should automatically update 'author_ip' field with IP address. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.