Use class attribute to guide RDN creation #205
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So in #175 it was mentioned that, ideally, the whole process of creating the RDN should be separate from designating primary keys for the database table.
@Natureshadow mentioned they were not keen on such a major rewrite, though.
But looking at the code, I believe there's quite an easy path, namely a simple class attribute, for which I propose
rdn_fields
, taking a list of field names. The code forbuild_rdn
is trivial to change.As far as the user is concerned:
primary_key
field, they got an error when saving. Now, if they do not add the class attribute, they get the exact same error at the exact same time.In short, as far as user experience goes, I do not see this as a major difference.
Is it backwards compatible? Well, not as I wrote it, no. But you can easily turn the if slightly more complicated to achieve that:
if field.db_column and (field.primary_key or field.name in self.rdn_fields):