Giter Site home page Giter Site logo

Comments (2)

Chris210634 avatar Chris210634 commented on August 16, 2024

@ravisantoshgudimetla @jbernal0019,

Here's what I think is happening, before perform_create() is called in views.py, serializer.is_valid() is called. is_valid() looks through the methods of PluginInstanceSerializer and looks for methods named validate_<field name>. is_valid() automatically executes these methods. The reason validate_gpu_limit() is called implicitly and not validate_previous is because the field for previous instance ID is named previous_id, not previous.

Two potential solutions are:

  1. rename the functions (easiest way)
  2. remove "plugin" argument from validate_<> function definitions and execute as the first line in validation functions:
plugin = self.context['view'].get_object()

Django's documentation suggests this as well:

Field-level validation

You can specify custom field-level validation by adding .validate_<field_name> methods to your Serializer subclass. These are similar to the .clean_<field_name> methods on Django forms.

These methods take a single argument, which is the field value that requires validation.

Your validate_<field_name> methods should return the validated value or raise a serializers.ValidationError. For example:

[http://www.django-rest-framework.org/api-guide/serializers/]

from chris_ultron_backend.

jbernal0019 avatar jbernal0019 commented on August 16, 2024

That makes sense @Chris210634 @ravisantoshgudimetla. Good catch!

Please modify accordingly

from chris_ultron_backend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.