Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #387 -- Importing from django.core.urlresolvers is deprecated in favor of django.urls #388

Merged
merged 1 commit into from
Nov 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions django_tables2/columns/linkcolumn.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# 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:
# to keep backward (Django <= 1.9) compatibility
from django.core.urlresolvers import reverse

from django_tables2.utils import Accessor, AttributeDict

from .base import Column, library
Expand Down Expand Up @@ -63,19 +68,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 +90,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
7 changes: 6 additions & 1 deletion example/app/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# 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:
# to keep backward (Django <= 1.9) compatibility
from django.core.urlresolvers import reverse

from django_tables2 import MultiTableMixin, RequestConfig, SingleTableView

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

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:
# to keep backward (Django <= 1.9) compatibility
from django.core.urlresolvers import reverse


@six.python_2_unicode_compatible
class Person(models.Model):
Expand Down
7 changes: 6 additions & 1 deletion tests/columns/test_linkcolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
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:
# to keep backward (Django <= 1.9) compatibility
from django.core.urlresolvers import reverse

import django_tables2 as tables
from django_tables2 import A

Expand Down