from django.contrib import admin

from . import models


@admin.register(models.Package)
class PackageAdmin(admin.ModelAdmin):
    list_display = ['billing_type', 'duration', 'price']

from django import forms
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from timed.forms import DurationInHoursField

from . import models


class PackageForm(forms.ModelForm):
    model = models.Package
    duration = DurationInHoursField(
        label=_('Duration in hours'),
        required=True,
    )


@admin.register(models.Package)
class PackageAdmin(admin.ModelAdmin):
    list_display = ['billing_type', 'duration', 'price']
    form = PackageForm

Configure duration field on subscription package in hours
Configure duration field on subscription package in hours

+ from django import forms
  from django.contrib import admin
+ from django.utils.translation import ugettext_lazy as _
+ 
+ from timed.forms import DurationInHoursField
  
  from . import models
+ 
+ 
+ class PackageForm(forms.ModelForm):
+     model = models.Package
+     duration = DurationInHoursField(
+         label=_('Duration in hours'),
+         required=True,
+     )
  
  
  @admin.register(models.Package)
  class PackageAdmin(admin.ModelAdmin):
      list_display = ['billing_type', 'duration', 'price']
+     form = PackageForm
  
Configure duration field on subscription package in hours
## Code Before:
from django.contrib import admin

from . import models


@admin.register(models.Package)
class PackageAdmin(admin.ModelAdmin):
    list_display = ['billing_type', 'duration', 'price']

## Instruction:
Configure duration field on subscription package in hours
## Code After:
from django import forms
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from timed.forms import DurationInHoursField

from . import models


class PackageForm(forms.ModelForm):
    model = models.Package
    duration = DurationInHoursField(
        label=_('Duration in hours'),
        required=True,
    )


@admin.register(models.Package)
class PackageAdmin(admin.ModelAdmin):
    list_display = ['billing_type', 'duration', 'price']
    form = PackageForm
