mirror of
https://github.com/jazzband/django-categories.git
synced 2026-03-16 22:30:24 +00:00
[-] Get management commands compatible with Django 1.10+
This commit is contained in:
parent
408e69d010
commit
9c5ccb8c54
2 changed files with 16 additions and 8 deletions
|
|
@ -8,7 +8,10 @@ class Command(BaseCommand):
|
|||
help = "Alter the tables for all registered models, or just specified models"
|
||||
args = "[appname ...]"
|
||||
can_import_settings = True
|
||||
requires_model_validation = False
|
||||
requires_system_checks = False
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('app_names', nargs='*')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
"""
|
||||
|
|
@ -17,8 +20,8 @@ class Command(BaseCommand):
|
|||
|
||||
from categories.migration import migrate_app
|
||||
from categories.settings import MODEL_REGISTRY
|
||||
if args:
|
||||
for app in args:
|
||||
if options['app_names']:
|
||||
for app in options['app_names']:
|
||||
migrate_app(None, app)
|
||||
else:
|
||||
for app in MODEL_REGISTRY:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import CommandError
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
|
@ -8,15 +9,19 @@ class Command(BaseCommand):
|
|||
help = "Drop the given field from the given model's table"
|
||||
args = "appname modelname fieldname"
|
||||
can_import_settings = True
|
||||
requires_model_validation = False
|
||||
requires_system_checks = False
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('app_name')
|
||||
parser.add_argument('model_name')
|
||||
parser.add_argument('field_name')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
"""
|
||||
Alter the tables
|
||||
"""
|
||||
|
||||
from categories.migration import drop_field
|
||||
if len(args) != 3:
|
||||
print("You must specify an Application name, a Model name and a Field name")
|
||||
if 'app_name' not in options or 'model_name' not in options or 'field_name' not in options:
|
||||
raise CommandError("You must specify an Application name, a Model name and a Field name")
|
||||
|
||||
drop_field(*args)
|
||||
drop_field(options['app_name'], options['model_name'], options['field_name'])
|
||||
|
|
|
|||
Loading…
Reference in a new issue