<commit_before>from django.db import router
from django.core.urlresolvers import NoReverseMatch, reverse
from django.db.models.deletion import Collector


def get_deleted_objects(root):
    """Collect linked objects required to be deleted.

    And maps each one to the `detail` page link.
    """
    using = router.db_for_write(root)
    collector = Collector(using=using)
    collector.collect([root])

    def format_callback(obj):
        opts = obj._meta

        try:
            return reverse(
                '{}:{}_{}_details'.format(opts.app_label, opts.app_label, opts.model_name),
                args=[obj._get_pk_val()])
        except NoReverseMatch:
            return None

    to_delete = collector.nested(format_callback)
    return to_delete
<commit_msg>Fix django 2.0 compatibility, close #370<commit_after>from django.db import router
from django.db.models.deletion import Collector
from django.urls import NoReverseMatch, reverse


def get_deleted_objects(root):
    """Collect linked objects required to be deleted.

    And maps each one to the `detail` page link.
    """
    using = router.db_for_write(root)
    collector = Collector(using=using)
    collector.collect([root])

    def format_callback(obj):
        opts = obj._meta

        try:
            return reverse(
                '{}:{}_{}_details'.format(opts.app_label, opts.app_label, opts.model_name),
                args=[obj._get_pk_val()])
        except NoReverseMatch:
            return None

    to_delete = collector.nested(format_callback)
    return to_delete

{'fraction_non_alphanumeric': 0.09450830140485313, 'fraction_numerical': 0.0031928480204342275, 'mean_word_length': 2.878712871287129, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2330048', 'n_tokens_mistral': 466, 'n_tokens_neox': 443, 'n_words': 115}