Opened 7 years ago

Closed 6 years ago

#9650 closed (duplicate)

Initial value for CharField primary key is not hidden in admin's inline form

Reported by: Tarken Owned by: nobody
Component: contrib.admin Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Given the following:

from django.db import models
from django.contrib import admin

class Client(models.Model):
    client_name = models.CharField(max_length=255)

class ClientDomain(models.Model):
    domain_name = models.CharField(max_length=255, primary_key=True)
    client = models.ForeignKey(Client)

class DomainInline(admin.TabularInline):
    model = ClientDomain
    extra = 1

class ClientAdmin(admin.ModelAdmin):
    inlines = (DomainInline,)

admin.site.register(Client, ClientAdmin)

The following HTML is generated in the "extra" inline:

<td class="original">
  <input id="id_domains-0-domain_name" type="text" class="vTextField" name="domains-0-domain_name" maxlength="255" />
  <input type="hidden" name="domains-0-client" value="1" id="id_domains-0-client" />
</td>
<td class="domain_name">
  <input id="id_domains-0-domain_name" type="text" class="vTextField" name="domains-0-domain_name" maxlength="255" />
</td>

And for existing record inlines:

<td class="original">
  <p>localhost</p>
  <input name="domains-0-domain_name" value="localhost" class="vTextField" maxlength="255" type="text" id="id_domains-0-domain_name" />
  <input type="hidden" name="domains-0-client" value="1" id="id_domains-0-client" />
</td>
<td class="domain_name">
  <input name="domains-0-domain_name" value="localhost" class="vTextField" maxlength="255" type="text" id="id_domains-0-domain_name" />
</td>

I am using the 1.0.X SVN branch.

Change History (1)

comment:1 Changed 6 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #8903

Note: See TracTickets for help on using tickets.
Back to Top