Dear All ..
I Try to write a custom auth backend.
It'll use external user model/table, let's call it 'myuser'
With this scenario, the LogEntry will receive a user_id that not exist
in default User model.
So it will generate exception.
I read that we can do a 'pre_save' signal receiver for LogEntry
http://stackoverflow.com/questions/4176238/django-extending-logentry
Now, I have this ini myproject/management/__init__.py
------START---------
from django.db.models.signals import pre_save
from django.dispatch import receiver
from django.contrib.admin.models import LogEntry
print 'THIS IS LOGENTRY PRE-SAVE'
@receiver(pre_save, sender=LogEntry)
def mypresave(change, **kwargs):
print 'PRE SAVE, CHANGE ', kwargs
------STOP----------
and when I 'runserver', looks like it is loaded
----START-------
^Cbino@bino-pata:~/Documents/django/mas/mas01$ python ./manage.py
runserver
THIS IS LOGENTRY PRE-SAVE
THIS IS LOGENTRY PRE-SAVE
Validating models...
0 errors found
Django version 1.4.3, using settings 'mas01.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
----STOP--------
But when I try to do some change on my data, the debug console didn't
print any thing form 'mypresave'
Kindly please tell me how to do it properly.
and also ...how to tell LogEntry to do nothing for any signal from
some specific models ?
Since I plan to make a model that have one-to-one relation to
LogEntry, and want logentry do nothing when something write to this
model.
Sincerely
-bino-
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment