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

Use model meta to generate verbose name #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dtcooper
Copy link

@dtcooper dtcooper commented Apr 2, 2024

Render field names of object rather than the word "None"

This is fix for issue #53, since an object may not exist when rendering
templates/admin/change_data.html - ie, if we're greating a new object
when confirm_add = True is set on a ModelAdmin with
the AdminConfirmMixin.

Also makes sure we send an actual object (not the string "None") to the
base template, to remove other instances of the word "None" from
the add view.

Uses capitalize on the string, as that seems to be the pattern in Django admin.

Fixes

Tested via:

image

Render field names of object rather than the word "None"

This is fix for issue TrangPham#53, since an object may not exist when rendering
`templates/admin/change_data.html` - ie, if we're greating a new object
when `confirm_add = True` is set on a `ModelAdmin` with
the `AdminConfirmMixin`.

Also makes sure we send an actual object (not the string "None") to the
base template, to remove other instances of the word "None" from
the add view.
@TrangPham
Copy link
Owner

Thanks for your contribution!

Do tests already exist for this? If not could you add a test case that would have failed before but now passes?

@dtcooper
Copy link
Author

dtcooper commented Apr 2, 2024

Ended up not using the project since it blew up for DecimalFields - so provided as-is! :)

Edit: my DecimalField blow up was my own fault. 😝

I'll look into adding tests.

@TrangPham
Copy link
Owner

Thanks. Let me know if you need support with either the tests or debugging your decimal issue.

If you found the reason you had issues with decimals, can you share that? I'll be able to help others if they face a similar issue if I know what happened.

@dtcooper
Copy link
Author

dtcooper commented Apr 5, 2024

Hi @TrangPham - I ended up not using django-admin-confirm for my project, so I'm not sure I'll have time ot prepare test cases. Thanks!

@TrangPham TrangPham added good first issue Good for newcomers help wanted Extra attention is needed labels Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants