uploadcare/pyuploadcare

Unable to make an image field optional

kunxin-chor opened this issue · 5 comments

Code:

class Course(models.Model):
    title = models.CharField(blank=False, max_length=255)
    desc = models.TextField(blank=False)
    number_of_hours = models.IntegerField(blank=False)
    instructor = models.ForeignKey('Instructor', blank=True, null=True, on_delete=models.SET_NULL)
    image = ImageField(null=True, blank=True, manual_crop="")
    
    def __str__(self):
        return self.title

Output:
image

Using:

  • Django version 2.2.6
  • Python 3.6
  • Form rendered with django_crispy_forms v1.8 using Bootstrap 4

can you show HTML instead?

Does this happen if you don't use django_crispy_forms?
"Cover Photo" string comes from somewhere else, as well as asterisk (probably indicating a required field). Is there some implicit or explicit from connected to the model?

Hi I removed Crispy Django forms and I still have the issue.


  | <!doctype html>
-- | --
  | <html lang="en">
  | <head>
  | <!-- Required meta tags -->
  | <meta charset="utf-8">
  | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  |  
  | <!-- Bootstrap CSS -->
  | <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
  |  
  | <title></title>
  |  
  | <script type="text/javascript" src="https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js"></script>
  |  
  | </head>
  | <body>
  | <div class="container">
  |  
  |  
  |  
  |  
  | <form method="POST">
  | <input type="hidden" name="csrfmiddlewaretoken" value="DE6ozAmMij1dfCQiIOvFYwDLAfHnb3enGVI6Slq63uiYvU65EfP3AE5HPO2D8L96">
  | <p><label for="id_title">Title:</label> <input type="text" name="title" value="as" maxlength="255" required id="id_title"></p>
  | <p><label for="id_desc">Desc:</label> <textarea name="desc" cols="40" rows="10" required id="id_desc">
  | as</textarea></p>
  | <p><label for="id_ISBN">ISBN:</label> <input type="text" name="ISBN" value="ass" maxlength="255" required id="id_ISBN"></p>
  | <p><label for="id_genre">Genre:</label> <select name="genre" required id="id_genre">
  | <option value="">---------</option>
  |  
  | <option value="1" selected>Fantasy</option>
  |  
  | <option value="3">Science-Fiction</option>
  |  
  | </select></p>
  | <p><label for="id_tags">Tags:</label> <select name="tags" required id="id_tags" multiple>
  | <option value="1" selected>thick</option>
  |  
  | </select></p>
  | <p><label for="id_owner">Owner:</label> <select name="owner" required id="id_owner">
  | <option value="">---------</option>
  |  
  | <option value="1" selected>admin</option>
  |  
  | </select></p>
  | <ul class="errorlist"><li>This field is required.</li></ul>
  | <p> <input type="hidden" name="image" role="uploadcare-uploader" data-public-key="4466d9d01bb2d6e11378" data-integration="Django/2.2.6; PyUploadcare-Django/2.7.0" data-crop="free" data-images-only="" required id="id_image"></p>
  | <input type="Submit"/>
  | </form>
  |  
  | </div>
  |  
  |  
  | <!-- Optional JavaScript -->
  | <!-- jQuery first, then Popper.js, then Bootstrap JS -->
  | <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
  | <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
  | <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
  |  
  | </body>
  | </html>


Hi. I know it's probably too late, but we've published new major version — https://github.com/uploadcare/pyuploadcare/releases/tag/v3.0.0. Re-open the issue if it doesn't help. :-)