Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline UserProfile id not being passed correctly in Django Admin (Django 1.6, YawdAdmin 0.7.0) #38

Open
jared-l opened this issue Oct 25, 2014 · 1 comment

Comments

@jared-l
Copy link

jared-l commented Oct 25, 2014

Hi there, firstly: great project!

I have a problem using (i.e. editing, updating) models with Yawd-Admin (0.7.0) on Python 2.7.8 when applying modal = True in my Inline Django Admin classes using the Django Proxy model for User Profiles.

Using the following as simplified case (settings.py excluded, as well as INSTALLED_APPS, and associated imports):

# app_name/admin.py
class UserProfileInline(admin.StackedInline):
    model = UserProfile
    max_num = 1
    can_delete = False
    modal = True # This causes the error

class UserProfileAdmin(UserAdmin):
    inlines = (UserProfileInline, )

admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)

admin.autodiscover()
admin_site._registry.update(admin.site._registry)


# app_name/models.py
class UserProfile(models.Model):
    user = models.OneToOneField(User)
    website = models.URLField(blank=True)

I obtain the following error creating / editing a user (e.g.):

MultiValueDictKeyError at /admin/auth/user/3/ "u'userprofile-0-id'"

Since this inline is now associated with User, the extraneous information (website in this example) shows up as a Profile heading in the same page when creating a user (which is expected behavior). If this information (i.e. website) is added, and then saved; on the next page (the edit page), and a save is attempted, you obtain that error. This also occurs when you attempt to edit such a post. The only time you have a successful user creation / edit occurs when you don't modify any info in the class where modal = True is present.

Also, because of the first save when creating a user, the user is added (in the default django auth tables), regardless of the success of entry of extra information via modal = True.

I've looked quite deeply in the Yawd-Admin source, and for the life of me I cannot find why this information isn't passed correctly.

Furthermore, having tried a number of combinations, it seems to be a Yawd-Admin problem with how modal = True loads and passes the information - as the default Django admin has no problem with this. And, when modal isn't present, everything works perfectly as in the default Django admin.

UPDATE: The problem occurs even without modal = True if one follows the sequence: add extra info, and then modify it. It seems to be Yawd-Admin related as django-admin-bootstrap3 has no issues with it - as does the default Django admin site.

I would appreciate any insight anyone can offer on this, please.

Many thanks!

@jared-l jared-l changed the title Inline UserProfile id not being passed correctly in Django Admin (Django 1.6, YawdAdmin 0.7.0) with modal = True Inline UserProfile id not being passed correctly in Django Admin (Django 1.6, YawdAdmin 0.7.0) Oct 25, 2014
@anansi
Copy link

anansi commented May 21, 2015

i also need help on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants