I want to make the slug field as read_only depending on the other field 
value like "lock_slug". 

Means There will be Two conditions.

1) When value of "lock_slug" is false then the slug field directly 
prepopulated from the field "title".

    prepopulated_fields = {"slug": ("title",),}

2) When value of "lock_slug" is true then the slug field make as readonly.

    def get_readonly_fields(self, request, obj = None):
        if obj and obj.lock_slug == True:
            return ('slug',) + self.readonly_fields        
        return self.readonly_fields

These two works fine independently, but problematic when used both.

Means when I try to add get_readonly_fields() on edit then it gives error 
because of prepopulated_fields.These two crashes with each other.

There will be any solution for working both on admin side?

I also refer below links

http://stackoverflow.com/questions/11601148/making-a-field-readonly-in-django-admin

http://stackoverflow.com/questions/4343535/django-admin-make-a-field-read-only-when-modifying-obj-but-required-when-adding

But not working these both at the same time.

Thanks,

Meenakshi

-- 
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+unsubscr...@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.


Reply via email to