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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange "AttributeError: can't set attribute" while using "index" as field name #25

Closed
paviano opened this issue Dec 30, 2020 · 5 comments

Comments

@paviano
Copy link

paviano commented Dec 30, 2020

Hi!
I noted that django-admin creation page throw an "AttributeError" while using "index" as field name.

I'm using Python 3.8.5 and Django 3.0.8

don't know if that can be considered a problem.

Really nice package anyway 馃榿馃榿

@fabiocaccamo
Copy link
Owner

Hi @paviano, thank you for reporting this.

Could you describe better the problem and the steps to follow to reproduce it please?

@paviano
Copy link
Author

paviano commented Dec 30, 2020

Ciao allora:

-aggiungere un campo "int" di nome "index" a un modello

-implementazione standard per l'admin page

"@admin.register(Impostazione)
class ImpostazioneAdmin(TreeNodeModelAdmin, ImportExportModelAdmin):
treenode_display_mode = TreeNodeModelAdmin.TREENODE_DISPLAY_MODE_ACCORDION
form = TreeNodeForm"

Ecco uno screenshot della traccia

immagine

@fabiocaccamo
Copy link
Owner

As you can see in the documentation, in the TreenodeModel there is already a getter property named index, so your field name clashes with the existing property, you should name it with another name.

@paviano
Copy link
Author

paviano commented Dec 30, 2020

Yep,

but note that:

"The TreeNodeModel abstract class adds many fields (prefixed with tn_ to prevent direct access) and public methods to your models."

So its in conflict with the verbose name? 馃槉

@paviano paviano closed this as completed Dec 30, 2020
@fabiocaccamo
Copy link
Owner

fabiocaccamo commented Dec 30, 2020

You are right, initially property getters were located in an optional model mixin, but after I merged the mixin into the main model.
Maybe it would be useful to add a setting to avoid the use of property getters.

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