Giter Club home page Giter Club logo

Comments (4)

fmoro avatar fmoro commented on June 12, 2024

OK, that don't solve the problem, I will continue investigating.

from django-mongoengine.

last-partizan avatar last-partizan commented on June 12, 2024

BTW, are you testing everything on your own app or example/tumlelog app?

I just tried to use example and looks like everything is broken. Trying to fix.

from django-mongoengine.

fmoro avatar fmoro commented on June 12, 2024

Yes, I am testing everything on my oun app.
I know that example app doesn't work... :P

from django-mongoengine.

fmoro avatar fmoro commented on June 12, 2024

Ok, with this patch it works as expected. If a FileField (or ImageField) is required, it will be required for save the object, but if this object already has a file you don't have to upload it again since there is one already.

diff -rupN django-mongoengine.orig/django_mongoengine/forms/field_generator.py django-mongoengine/django_mongoengine/forms/field_generator.py
--- django-mongoengine.orig/django_mongoengine/forms/field_generator.py 2015-09-23 16:28:34.090070123 +0200
+++ django-mongoengine/django_mongoengine/forms/field_generator.py  2015-09-24 09:58:35.010007575 +0200
@@ -258,10 +258,24 @@ class MongoFormFieldGenerator(object):
             return f

     def generate_filefield(self, field, **kwargs):
-        return forms.FileField(**kwargs)
+        form_class = forms.FileField
+        defaults = {
+            'required': field.required,
+            'label': self.get_field_label(field),
+            'help_text': self.get_field_help_text(field),
+        }
+        defaults.update(kwargs)
+        return form_class(**defaults)

     def generate_imagefield(self, field, **kwargs):
-        return forms.ImageField(**kwargs)
+        form_class = forms.ImageField
+        defaults = {
+            'required': field.required,
+            'label': self.get_field_label(field),
+            'help_text': self.get_field_help_text(field),
+        }
+        defaults.update(kwargs)
+        return form_class(**defaults)

     def generate_dictfield(self, field, **kwargs):
         #remove Mongo reserved words

from django-mongoengine.

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.