Thursday, October 23, 2014

Starting a procedure when opening a model in the admin interface

I use Django 1.7, admin interface, and PostgreSQL.
I have, among other things, the following model:

### models.py
class Patients(models.Model):
surname = models.CharField(max_length=60, db_index=True)
name = models.CharField(max_length=60, db_index=True)
address = models.CharField(max_length=150)
city = models.CharField(max_length=120)
zipcode = models.CharField(max_length=15)
def __unicode__(self):
return u"%s %s" % (self.surname, self.name)
class Meta:
db_table = u'patients'
ordering=['surname', 'name']

In this phase of test this model is fed by a python procedure which reads the fields in a a query from an Oracle DB. This procedure for the time being is run manually from time to time when I need to refresh the content of the model.

In production context I would like to start this same python procedure automatically each time a user clicks on the model Patients in the list of models proposed by the admin interface (I mean the one that appears when you call http://localhost:8000/admin) before opening the model itself in order to have its content refreshed to the very last item.

How can I do it?
What kind of signal, if any, should I use?

Ciao
Vittorio

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/D997970F-6532-489D-87FD-EB7E6BCFCBA9%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment