# Buggy code
def upload(self, request, project, language, fileobj, method):
    """
    Handles dictionary upload.
    """
    from weblate.trans.models.changes import Change

    store = AutoFormat.parse(fileobj)

    ret = 0

    # process all units
    for dummy, unit in store.iterate_merge(False):
        source = unit.get_source()
        target = unit.get_target()

        # Ignore too long words
        if len(source) > 200 or len(target) > 200:
            continue

        # Get object
        word, created = self.get_or_create(
            project=project,
            language=language,
            source=source,
            defaults={
                "target": target,
            },
        )

        # Already existing entry found
        if not created:
            # Same as current -> ignore
            if target == word.target:
                continue
            if method == "add":
                # Add word
                word = self.create(
                    request,
                    action=Change.ACTION_DICTIONARY_UPLOAD,
                    project=project,
                    language=language,
                    source=source,
                    target=target,
                )
            elif method == "overwrite":
                # Update word
                word.target = target
                word.save()

        ret += 1

    return ret


# Traceback (django.db.utils.OperationalError)
Operations to perform:
Synchronize unmigrated apps: staticfiles, admindocs, messages, sitemaps, compressor, weblate, crispy_forms
Apply all migrations: lang, sessions, admin, sites, auth, default, contenttypes, accounts, trans
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying lang.0001_initial... OK
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying trans.0001_initial...Traceback (most recent call last):
File "./manage.py", line 31, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
(...)
File "/usr/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.OperationalError: (1709, 'Index column size too large. The maximum column size is 767 bytes.')

# Fixed code
def upload(self, request, project, language, fileobj, method):
    """
    Handles dictionary upload.
    """
    from weblate.trans.models.changes import Change

    store = AutoFormat.parse(fileobj)

    ret = 0

    # process all units
    for dummy, unit in store.iterate_merge(False):
        source = unit.get_source()
        target = unit.get_target()

        # Ignore too long words
        if len(source) > 190 or len(target) > 190:
            continue

        # Get object
        word, created = self.get_or_create(
            project=project,
            language=language,
            source=source,
            defaults={
                "target": target,
            },
        )

        # Already existing entry found
        if not created:
            # Same as current -> ignore
            if target == word.target:
                continue
            if method == "add":
                # Add word
                word = self.create(
                    request,
                    action=Change.ACTION_DICTIONARY_UPLOAD,
                    project=project,
                    language=language,
                    source=source,
                    target=target,
                )
            elif method == "overwrite":
                # Update word
                word.target = target
                word.save()

        ret += 1

    return ret