-
Notifications
You must be signed in to change notification settings - Fork 5
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
Allow to define model field name for specific field #17
Comments
Another (maybe better) option is to be able to fully define the Model field name instead of just remove the prefix, so there's more flexibility. |
For a single field there is currently no way to change/remove the prefix. Think of it like that:
We could change the code that prepend the prefix to the I'd have to check if Django does pass the string unchanged or if it causes a validation error because of the included But then... why? I'm confused why you need something like that in the first place? I'm really interested in better understanding your use case. |
Interesting, I didn't know about that, I'll take a look on it :-)
I was thinking on using a dict to keep track of the actual names instead of generate them all the time based on the prefix, but the
I have a Model that inhering from another base one with generic fields, but in the child Model, it makes more sense to have accesible one of the fields as part of one of the Composite Fields, instead of being a Field of the base Model, so I was thinking on having it inside the Composite Field as an alias. |
SystemCheckError: System check identified some issues:
ERRORS:
trcos_rf.Detection: (models.E007) Field 'drone_position' has column name 'position' that is used by another field.
HINT: Specify a 'db_column' for the field.
trcos_rf.HistoricalDetection: (models.E007) Field 'drone_position' has column name 'position' that is used by another field.
HINT: Specify a 'db_column' for the field. So the |
So you basically have two Models:
And If that's indeed the case it's not a If you do want to create a "composite field" with existing fields you don't need this package but can just copy the idea and define your own Proxy class. This is also explained in the "How does it work?" chapter of the documentation: https://django-composite-field.readthedocs.io/latest/usage.html#how-does-it-work You could also try using the There is currently no support for defining the fields outside the composite field and just adding the proxy skipping the creation and adding of the fields. If you need this feature PRs are always welcome. |
At this moment, all the subfields are stored in the Model with a common prefix, that's the name of the CompositeField. I would like for a specific subfield to be stored with a different prefix, or no prefix at all. Something like this:
I can contribute with a PR with some guidance on where I can do this, I have seen there's a reference to the
%s_
prefix in the code but not sure where/how to store/modify it for a single field.The text was updated successfully, but these errors were encountered: