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

from robots.models import Url, Rule
from robots.forms import RuleAdminForm


class RuleAdmin(admin.ModelAdmin):
    form = RuleAdminForm
    fieldsets = (
        (None, {'fields': ('robot', 'sites')}),
        (_('URL patterns'), {
            'fields': ('allowed', 'disallowed'),
        }),
        (_('Advanced options'), {
            'classes': ('collapse',),
            'fields': ('crawl_delay',),
        }),
    )
    list_filter = ('sites',)
    list_display = ('robot', 'allowed_urls', 'disallowed_urls')
    search_fields = ('robot', 'allowed__pattern', 'disallowed__pattern')

admin.site.register(Url)
admin.site.register(Rule, RuleAdmin)

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

from robots.models import Url, Rule
from robots.forms import RuleAdminForm


class RuleAdmin(admin.ModelAdmin):
    form = RuleAdminForm
    fieldsets = (
        (None, {'fields': ('robot', 'sites')}),
        (_('URL patterns'), {
            'fields': ('allowed', 'disallowed'),
        }),
        (_('Advanced options'), {
            'classes': ('collapse',),
            'fields': ('crawl_delay',),
        }),
    )
    list_filter = ('sites',)
    list_display = ('robot', 'allowed_urls', 'disallowed_urls')
    search_fields = ('robot', 'allowed__pattern', 'disallowed__pattern')
    filter_horizontal = ('allowed', 'disallowed')

admin.site.register(Url)
admin.site.register(Rule, RuleAdmin)

Add filter_horizontal for for allowed and disallowed
Add filter_horizontal for for allowed and disallowed

  from django.contrib import admin
  from django.utils.translation import ugettext_lazy as _
  
  from robots.models import Url, Rule
  from robots.forms import RuleAdminForm
  
  
  class RuleAdmin(admin.ModelAdmin):
      form = RuleAdminForm
      fieldsets = (
          (None, {'fields': ('robot', 'sites')}),
          (_('URL patterns'), {
              'fields': ('allowed', 'disallowed'),
          }),
          (_('Advanced options'), {
              'classes': ('collapse',),
              'fields': ('crawl_delay',),
          }),
      )
      list_filter = ('sites',)
      list_display = ('robot', 'allowed_urls', 'disallowed_urls')
      search_fields = ('robot', 'allowed__pattern', 'disallowed__pattern')
+     filter_horizontal = ('allowed', 'disallowed')
  
  admin.site.register(Url)
  admin.site.register(Rule, RuleAdmin)
  
Add filter_horizontal for for allowed and disallowed
## Code Before:
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from robots.models import Url, Rule
from robots.forms import RuleAdminForm


class RuleAdmin(admin.ModelAdmin):
    form = RuleAdminForm
    fieldsets = (
        (None, {'fields': ('robot', 'sites')}),
        (_('URL patterns'), {
            'fields': ('allowed', 'disallowed'),
        }),
        (_('Advanced options'), {
            'classes': ('collapse',),
            'fields': ('crawl_delay',),
        }),
    )
    list_filter = ('sites',)
    list_display = ('robot', 'allowed_urls', 'disallowed_urls')
    search_fields = ('robot', 'allowed__pattern', 'disallowed__pattern')

admin.site.register(Url)
admin.site.register(Rule, RuleAdmin)

## Instruction:
Add filter_horizontal for for allowed and disallowed
## Code After:
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from robots.models import Url, Rule
from robots.forms import RuleAdminForm


class RuleAdmin(admin.ModelAdmin):
    form = RuleAdminForm
    fieldsets = (
        (None, {'fields': ('robot', 'sites')}),
        (_('URL patterns'), {
            'fields': ('allowed', 'disallowed'),
        }),
        (_('Advanced options'), {
            'classes': ('collapse',),
            'fields': ('crawl_delay',),
        }),
    )
    list_filter = ('sites',)
    list_display = ('robot', 'allowed_urls', 'disallowed_urls')
    search_fields = ('robot', 'allowed__pattern', 'disallowed__pattern')
    filter_horizontal = ('allowed', 'disallowed')

admin.site.register(Url)
admin.site.register(Rule, RuleAdmin)
