On Thu, Nov 10, 2011 at 3:25 PM, Asif Jamadar <asif.jama...@rezayat.net> wrote:
> Suppose I have choicefield in my django model which consist of several 
> choices. Now in future if I changed the existing choice (option) with some 
> other name (choice), then whether the existing records in model with that 
> choice(option)  will also change? Or In admin page I need to set that new 
> option manually?

No, they won't change automatically. There is no reasonable
way for the system to intuit that this change was made. You
would need to manually edit the existing object instances in
the database, either through the admin. interface, or through
a "python manage.py shell" script. Something along the lines
of:

from myapp.models import MyModel

for obj in MyModel.objects.all():
    if obj.mychoicefield == 'Old value':
        obj.mychoicefield = 'New value'
        obj.save()

Regards,
Gora
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to