Django

Code

Ticket #3662 (closed: duplicate)

Opened 2 years ago

Last modified 1 year ago

OneToOne edit_inline - can not add new object in Django admin

Reported by: alex@halogen-dg.com Assigned to: nobody
Milestone: Component: Contrib apps
Version: SVN Keywords: OneToOne, edit_inline
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Consider following code snipped (I tried to make it very simple just to explain this bug):

from django.db import models
from django.contrib.sites.models import Site


# Create your models here.

class Article(models.Model):
    title = models.CharField(maxlength=50)
    description = models.TextField()
    class Admin:
        pass
    
class CustomArticle(models.Model):
    fti_contents_list = models.TextField(null=True, blank=True)
    layout = models.CharField(maxlength=1,core=True)
    sites = models.ManyToManyField(Site,core=True)
    article = models.OneToOneField(Article,edit_inline=True)

Here I use OneToOne? field to extend standard Article application with custom data I need to use with particular customer.

The problem:

When I add new product in /admin it fails with error:

File "/usr/lib/python2.4/site-packages/django/db/models/related.py", line 71,

in get_list

if self.field.rel.min_num_in_admin:

AttributeError?: 'OneToOneRel?' object has no attribute 'min_num_in_admin'

The solution: see attached patch

Attachments

AttributeError at _admin_Article_article_add_.html (78.2 kB) - added by alex@halogen-dg.com on 03/06/07 05:29:46.
Complete Error .html
patch.txt (0.8 kB) - added by alex@halogen-dg.com on 03/06/07 05:31:10.
proposed patch

Change History

03/06/07 05:29:46 changed by alex@halogen-dg.com

  • attachment AttributeError at _admin_Article_article_add_.html added.

Complete Error .html

03/06/07 05:31:10 changed by alex@halogen-dg.com

  • attachment patch.txt added.

proposed patch

03/06/07 07:12:43 changed by Simon G. <dev@simon.net.nz>

  • status changed from new to closed.
  • needs_better_patch changed.
  • needs_tests changed.
  • keywords changed from OneToOne to OneToOne, edit_inline.
  • needs_docs changed.
  • resolution set to invalid.

Thanks for the patch, alex. We know that edit_inline has lots of problems (e.g. http://code.djangoproject.com/wiki/FeatureGrouping#edit_inlineIssues), but the new admin changes that will be coming after the 0.96 release should clear this up.

Because of this, I'm marking this as invalid for now, but I've placed it on the FeatureGrouping page, and we'll double check that it's no longer an issue once these changes have gone through.

03/06/07 14:05:49 changed by anonymous

Thanks Simon! I also listed another my bug on almost same combination but on Edit (3188) in this Wike page. Personally I think issues must stay open until they are either fixed or deprecated (as newadmin comes) but lets discuss this out of bug tracking system. I will post my suggestion on django-developers list.

04/05/07 10:29:36 changed by anonymous

I keep getting customer complaints about my software. Installing my patch everywhere helps but its difficult to maintain this.

04/05/07 18:51:21 changed by Simon G. <dev@simon.net.nz>

  • status changed from closed to reopened.
  • resolution deleted.
  • stage changed from Unreviewed to Ready for checkin.

Reopened, see discussion here

04/28/07 09:42:00 changed by mtredinnick

  • has_patch deleted.
  • stage changed from Ready for checkin to Accepted.

This isn't ready for checkin. We aren't applying any patches to existing admin because it will soon be replaced. So we need to wait for the support work to go into newforms-admin and then write a patch against that.

07/13/07 07:27:26 changed by Thomas Güttler <hv@tbz-pariv.de>

  • has_patch set to 1.
  • stage changed from Accepted to Ready for checkin.

This patch is necessary and works. Please commit. As long as newforms-admin is not stable, support for (old) admin must be continued.

09/16/07 13:45:54 changed by ubernostrum

  • status changed from reopened to closed.
  • resolution set to duplicate.

Duplicate of #24.


Add/Change #3662 (OneToOne edit_inline - can not add new object in Django admin)




Change Properties
Action