Skip to content

Commit

Permalink
Fixed #387 -- Importing from django.core.urlresolvers is deprecated i…
Browse files Browse the repository at this point in the history
…n favor of django.urls
  • Loading branch information
felixxm committed Nov 1, 2016
1 parent 2bf8fd3 commit 11c0eaa
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
20 changes: 12 additions & 8 deletions django_tables2/columns/linkcolumn.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# coding: utf-8
from __future__ import absolute_import, unicode_literals

from django.core.urlresolvers import reverse
from django.utils.html import format_html

try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse

from django_tables2.utils import Accessor, AttributeDict

from .base import Column, library
Expand Down Expand Up @@ -63,19 +67,19 @@ class LinkColumn(BaseLinkColumn):
dedicated to that record.
The first arguments are identical to that of
`~django.core.urlresolvers.reverse` and allows an internal URL to be
`~django.urls.reverse` and allows an internal URL to be
described. If this argument is `None`, then `get_absolute_url`.
(see Django references) will be used.
The last argument *attrs* allows custom HTML attributes to be added to the
rendered ``<a href="...">`` tag.
Arguments:
viewname (str): See `~django.core.urlresolvers.reverse`, or use `None`
viewname (str): See `~django.urls.reverse`, or use `None`
to use the model's `get_absolute_url`
urlconf (str): See `~django.core.urlresolvers.reverse`.
args (list): See `~django.core.urlresolvers.reverse`. [2]_
kwargs (dict): See `~django.core.urlresolvers.reverse`. [2]_
current_app (str): See `~django.core.urlresolvers.reverse`.
urlconf (str): See `~django.urls.reverse`.
args (list): See `~django.urls.reverse`. [2]_
kwargs (dict): See `~django.urls.reverse`. [2]_
current_app (str): See `~django.urls.reverse`.
attrs (dict): HTML attributes that are added to the rendered
``<a ...>...</a>`` tag.
text (str or callable): Either static text, or a callable. If set, this
Expand All @@ -85,7 +89,7 @@ class LinkColumn(BaseLinkColumn):
.. [2] In order to create a link to a URL that relies on information in the
current row, `.Accessor` objects can be used in the *args* or *kwargs*
arguments. The accessor will be resolved using the row's record before
`~django.core.urlresolvers.reverse` is called.
`~django.urls.reverse` is called.
Example:
Expand Down
6 changes: 5 additions & 1 deletion example/app/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# coding: utf-8
from random import choice

from django.core.urlresolvers import reverse
from django.shortcuts import render
from django.utils.lorem_ipsum import words
from django.views.generic.base import TemplateView

try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse

from django_tables2 import MultiTableMixin, RequestConfig, SingleTableView

from .models import Country, Person
Expand Down
6 changes: 5 additions & 1 deletion tests/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@

from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse
from django.db import models
from django.utils import six
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext, ugettext_lazy

try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse


@six.python_2_unicode_compatible
class Person(models.Model):
Expand Down
6 changes: 5 additions & 1 deletion tests/columns/test_linkcolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
from __future__ import unicode_literals

import pytest
from django.core.urlresolvers import reverse
from django.template import Context, Template
from django.utils.html import mark_safe

try:
from django.urls import reverse
except ImportError:
from django.core.urlresolvers import reverse

import django_tables2 as tables
from django_tables2 import A

Expand Down

0 comments on commit 11c0eaa

Please sign in to comment.