#16328: FilePathField should include blank option even when required=True
----------------------------+------------------------------------------
     Reporter:  ringemup@…  |                    Owner:  Mahmoud Nasser
         Type:  Bug         |                   Status:  closed
    Component:  Forms       |                  Version:  1.3
     Severity:  Normal      |               Resolution:  fixed
     Keywords:              |             Triage Stage:  Accepted
    Has patch:  0           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  1
----------------------------+------------------------------------------
Changes (by Mahmoud Nasser):

 * resolution:   => fixed
 * status:  assigned => closed

Comment:

 I already tested this ticket and the blank option is working fine.

 I made the test with the following models:

 {{{
 class Parent(models.Model):
     name = models.CharField(max_length=100)

     def __str__(self):
         return self.name


 class Child(models.Model):
     parent = models.ForeignKey(Parent, on_delete=models.CASCADE,
 related_name="children")
     # FilePathField with blank=True but required by form — we simulate it
     file_path = models.FilePathField(path="/tmp", match=".*\.txt$",
 recursive=False, blank=True)
     choices_field = models.CharField(max_length=100, choices=[("name",
 "name")])

     def __str__(self):
         return self.file_path or "No File"
 }}}

 And with the following admin:

 {{{
 # admin.py
 from django.contrib import admin
 from .models import Parent, Child

 class ChildInline(admin.TabularInline):
     model = Child
     extra = 1  # Shows one empty inline form
     can_delete = True

 @admin.register(Parent)
 class ParentAdmin(admin.ModelAdmin):
     inlines = [ChildInline]
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/16328#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070197a6dc7642-9b20bfe3-094b-43b6-8155-9a7386cae83a-000000%40eu-central-1.amazonses.com.

Reply via email to