Coder Social home page Coder Social logo

Comments (4)

ankane avatar ankane commented on August 30, 2024 3

Thanks @ethagnawl and @jerinpetergeorge! Pushed a fix in the commit above.

from pgvector-python.

jerinpetergeorge avatar jerinpetergeorge commented on August 30, 2024 1

Thanks @ethagnawl and @jerinpetergeorge! Pushed a fix in the commit above.

Unfortunately, In my testing, a couple of things were failing.

  • Admin wasn't working at all
  • Updating the data via Django admin wasn't working

These two issues have been taken care of by #22

from pgvector-python.

jerinpetergeorge avatar jerinpetergeorge commented on August 30, 2024

It seems to be the package is not supported via forms and templates. The issue can be reproduced with the below setup.

# models.py

from pgvector.django import VectorField


class Vector(models.Model):
    test = VectorField(dimensions=3)

    def __str__(self):
        return str(self.test)
# forms.py

from django import forms


class VectorForm(forms.ModelForm):
    class Meta:
        model = Vector
        fields = ["test"]

Execution

vf = VectorForm(data={"test":[1,2,3]})
vf.is_valid()

Traceback

ValueError                                Traceback (most recent call last)
Cell In[3], line 1
----> 1 vf.is_valid()

File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/forms/forms.py:201, in BaseForm.is_valid(self)
    199 def is_valid(self):
    200     """Return True if the form has no errors, or False otherwise."""
--> 201     return self.is_bound and not self.errors

File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/forms/forms.py:196, in BaseForm.errors(self)
    194 """Return an ErrorDict for the data provided for the form."""
    195 if self._errors is None:
--> 196     self.full_clean()
    197 return self._errors

File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/forms/forms.py:435, in BaseForm.full_clean(self)
    433 self._clean_fields()
    434 self._clean_form()
--> 435 self._post_clean()

File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/forms/models.py:486, in BaseModelForm._post_clean(self)
    483     self._update_errors(e)
    485 try:
--> 486     self.instance.full_clean(exclude=exclude, validate_unique=False)
    487 except ValidationError as e:
    488     self._update_errors(e)

File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/db/models/base.py:1470, in Model.full_clean(self, exclude, validate_unique, validate_constraints)
   1467     exclude = set(exclude)
   1469 try:
-> 1470     self.clean_fields(exclude=exclude)
   1471 except ValidationError as e:
   1472     errors = e.update_error_dict(errors)

File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/db/models/base.py:1522, in Model.clean_fields(self, exclude)
   1520     continue
   1521 try:
-> 1522     setattr(self, f.attname, f.clean(raw_value, self))
   1523 except ValidationError as e:
   1524     errors[f.name] = e.error_list

File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/db/models/fields/__init__.py:777, in Field.clean(self, value, model_instance)
    771 """
    772 Convert the value's type and run validation. Validation errors
    773 from to_python() and validate() are propagated. Return the correct
    774 value if no error is raised.
    775 """
    776 value = self.to_python(value)
--> 777 self.validate(value, model_instance)
    778 self.run_validators(value)
    779 return value

File ~/.local/share/virtualenvs/generic-django-example-Kc6WXfau/lib/python3.9/site-packages/django/db/models/fields/__init__.py:767, in Field.validate(self, value, model_instance)
    764 if value is None and not self.null:
    765     raise exceptions.ValidationError(self.error_messages["null"], code="null")
--> 767 if not self.blank and value in self.empty_values:
    768     raise exceptions.ValidationError(self.error_messages["blank"], code="blank")

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

from pgvector-python.

ethagnawl avatar ethagnawl commented on August 30, 2024

That was fast, @ankane. Thanks!

from pgvector-python.

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.