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

Django admin inline processing #666

Open
AlexFoxalt opened this issue May 19, 2023 · 0 comments
Open

Django admin inline processing #666

AlexFoxalt opened this issue May 19, 2023 · 0 comments

Comments

@AlexFoxalt
Copy link

AlexFoxalt commented May 19, 2023

Django admin pass not all fields to model creation process

Code

Admin model

@admin.register(SuggestChange)
class SuggestChangeAdmin(admin.ModelAdmin):
    list_display = (
        "reviewId",
        "applied",
        "accepted",
        "new",
        "country",
        "source",
        "author",
        "normalized_modified_attributes",
        "normalized_deleted_attributes",
        "normalized_added_attributes",
    )
    list_display_links = None
    list_editable = ("accepted",)
    search_fields = ("reviewId",)
    ordering = ("-timestamp",)

Mongo model

class SuggestChange(mongomodels.Model):
    _id = mongomodels.ObjectIdField()
    reviewId = mongomodels.CharField(max_length=100)
    country = mongomodels.CharField(max_length=100)
    category = mongomodels.CharField(max_length=100)
    source = mongomodels.CharField(max_length=100)
    timestamp = mongomodels.CharField(max_length=100)
    author = mongomodels.CharField(max_length=100)
    attributes = mongomodels.EmbeddedField(AttributeEmbedded, null=True)
    addedAttributes = mongomodels.ArrayField(AddedAttributeEmbedded, null=True)
    applied = mongomodels.BooleanField()
    accepted = mongomodels.BooleanField()
    new = mongomodels.BooleanField()

    class Meta:
        _use_db = "nonrel"
        db_table = "changes_to_review"

    def __str__(self):
        return self.reviewId

    def full_clean(self, exclude: Optional[Collection[str]] = ..., validate_unique: bool = ...) -> None:
        pdb.set_trace()

Traceback

The reason why i am here that when i run submit changes request in my admin panel, all 17 ORM objects passed to full_clean() func, but there are only 1 field that have some data, it is field that was changed.
For example:

-> pdb.set_trace()
(Pdb) self._id
(Pdb) self.author
''
(Pdb) self.accepted
False
(Pdb) c

For some reason in 'exlude' var passed all fields that are empty

-> pdb.set_trace()
(Pdb) exclude
['_id', 'reviewId', 'country', 'category', 'source', 'timestamp', 'author', 'attributes', 'addedAttributes', 'applied', 'new']

Why these fields are empty? I really need only 2 fields presented for my program: _id and accepted, but no idea how to pass them to model functions.

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

1 participant