Text manipulation in django as soon as user/admin enters it?

The easiest way to do this is to add a method that listens on the pre_save signal.

The easiest way to do this is to add a method that listens on the pre_save signal. Here is a sample you can use (this code goes in your models. Py for the app) from django.db.models.

Signals import pre_save from django. Dispatch import receiver # Your models go here def process_text(mystring): return len(mystring) @receiver(pre_save, sender=Article) def my_handler(sender, **kwargs): if not kwargs'raw': obj = kwargs'instance' obj. Custom_name = process_string(obj.Name) The signals documentation has more information on signals, and the pre_save documentation lists what arguments the method expects.

If you have form with those fields then you can use some javascript to update the second field when the first lost focus. Then when someone will enter something in to the first field and leave the field, js can calculate length and put the value in second field. If this should be done in the backend level - then you can for example override model's save() method.

More here - https://docs.djangoproject. Com/en/dev/topics/db/models/#overriding-predefined-model-methods Cheers.

In my opinion the best option is to set the value on the form validation stage.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions