﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30373	"""Save as new"" with read-only fields."	Nicola Zilio	nobody	"I want to implement the ""Save as new"" feature in Django's admin for a model such as this one:


{{{
class Plasmid (models.Model):
    name = models.CharField(""Name"", max_length = 255, blank=False)
    other_name = models.CharField(""Other Name"", max_length = 255, blank=True)
    selection = models.CharField(""Selection"", max_length = 50, blank=False)
    created_by = models.ForeignKey(User)
}}}


In the admin, if the user who requests a Plasmid object is NOT the same as the one who created it, some of the above-shown fields are set as read-only. If the user is the same, they are all editable. For example:

{{{
class PlasmidPage(admin.ModelAdmin):

    def get_readonly_fields(self, request, obj=None):

        if obj:
            if not request.user == obj.created_by:
                return ['name', 'created_by',]
            else:
                return ['created_by',]
        else:
            return []

    def change_view(self,request,object_id,extra_context=None):

        self.fields = ('name', 'other_name', 'selection', 'created_by',)
        return super(PlasmidPage,self).change_view(request,object_id)
}}}

The issue I have is that when a field is read-only and a user hits the ""Save as new"" button, the value of that field is not 'transferred' to the new object. On the other hand, the values of fields that are editable (not read-only) are transferred.

I don't understand if this is a bug or a (security?) feature. In either case does anybody why, or how I could solve this problem? I want to transfer the values of both read-only and non-read-only fields to the new object."	Bug	closed	contrib.admin	dev	Normal	wontfix			Unreviewed	0	0	0	0	0	0
