Repository: dj-stripe/dj-stripe

Issue:
Can't save/create Products of type=service in admin, because goods-specific fields shown as required
The dj-stripe admin page for my type=service product won't save because of required fields that only apply to type=good.

Eg, I create a product using the stripe python api as follows:

```
import stripe  
stripe.api_key = "sk_test_blahblah"
product = stripe.Product.create(name="example service", type="service", statement_descriptor="myapp subscription")
```
This correctly triggers the dj-stripe webhook and is saved into the database, and is visible in Django admin, with stripe id, created,  name, type etc fields populated.

But I'm unable to save the product in admin because the following fields are shown as required:

- attributes
- caption
- deactive_on
- images
- package_dimensions
- url

even though their helptext says they only apply to type="good".

Environment:

dj-stripe==1.2.3
stripe==2.10.1

stripe API version 2018-05-21


Discussion:
This also occurs on master (at 70f3e264424de4e2d90cef45aaf34abc8bad18a4), though on master it's only the attributes and url fields
Having made those changes I notice that creating or editing a Product in admin doesn't sync back changes to Stripe - is it intended to?

If not maybe this issue is redundant.
Yeha it is. Duplicate of #452. Closing.

Resolving patch:
diff --git a/djstripe/migrations/0001_initial.py b/djstripe/migrations/0001_initial.py
--- a/djstripe/migrations/0001_initial.py
+++ b/djstripe/migrations/0001_initial.py
@@ -448,13 +448,13 @@ class Migration(migrations.Migration):
                 ('name', models.CharField(help_text="The product's name, meant to be displayable to the customer. Applicable to both `service` and `good` types.", max_length=5000)),
                 ('type', djstripe.fields.StripeEnumField(enum=djstripe.enums.ProductType, help_text='The type of the product. The product is either of type `good`, which is eligible for use with Orders and SKUs, or `service`, which is eligible for use with Subscriptions and Plans.', max_length=7)),
                 ('active', models.NullBooleanField(help_text='Whether the product is currently available for purchase. Only applicable to products of `type=good`.')),
-                ('attributes', djstripe.fields.JSONField(help_text='A list of up to 5 attributes that each SKU can provide values for (e.g., `["color", "size"]`). Only applicable to products of `type=good`.', null=True)),
+                ('attributes', djstripe.fields.JSONField(help_text='A list of up to 5 attributes that each SKU can provide values for (e.g., `["color", "size"]`). Only applicable to products of `type=good`.', null=True, blank=True)),
                 ('caption', models.CharField(help_text='A short one-line description of the product, meant to be displayableto the customer. Only applicable to products of `type=good`.', max_length=5000, null=True, blank=True)),
                 ('deactivate_on', djstripe.fields.JSONField(blank=True, help_text='An array of connect application identifiers that cannot purchase this product. Only applicable to products of `type=good`.')),
                 ('images', djstripe.fields.JSONField(blank=True, help_text='A list of up to 8 URLs of images for this product, meant to be displayable to the customer. Only applicable to products of `type=good`.')),
                 ('package_dimensions', djstripe.fields.JSONField(help_text='The dimensions of this product for shipping purposes. A SKU associated with this product can override this value by having its own `package_dimensions`. Only applicable to products of `type=good`.', null=True, blank=True)),
                 ('shippable', models.NullBooleanField(help_text='Whether this product is a shipped good. Only applicable to products of `type=good`.')),
-                ('url', models.CharField(help_text='A URL of a publicly-accessible webpage for this product. Only applicable to products of `type=good`.', max_length=799, null=True)),
+                ('url', models.CharField(help_text='A URL of a publicly-accessible webpage for this product. Only applicable to products of `type=good`.', max_length=799, null=True, blank=True)),
                 ('statement_descriptor', models.CharField(help_text="Extra information about a product which will appear on your customer's credit card statement. In the case that multiple products are billed at once, the first statement descriptor will be used. Only available on products of type=`service`.", max_length=22, null=True, blank=True)),
                 ('unit_label', models.CharField(max_length=12, null=True)),
             ],
diff --git a/djstripe/models/core.py b/djstripe/models/core.py
--- a/djstripe/models/core.py
+++ b/djstripe/models/core.py
@@ -1304,7 +1304,7 @@ class Product(StripeModel):
         )
     )
     attributes = JSONField(
-        null=True,
+        null=True, blank=True,
         help_text=(
             "A list of up to 5 attributes that each SKU can provide values for "
             '(e.g., `["color", "size"]`). Only applicable to products of `type=good`.'
@@ -1349,7 +1349,7 @@ class Product(StripeModel):
     )
     url = models.CharField(
         max_length=799,
-        null=True,
+        null=True, blank=True,
         help_text=(
             "A URL of a publicly-accessible webpage for this product. "
             "Only applicable to products of `type=good`."


Test patch: