Skip to content

Commit

Permalink
Add Django 1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry committed Aug 30, 2022
1 parent 07632b2 commit b42e5dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,17 @@ ADMIN_TWO_FACTOR_NAME = 'PROJECT_NAME'
* Include the **Admin Two Factor** URL config in `PROJECT_CORE/urls.py`:

```python
# Django version >= 2
urlpatterns = [
path('admin/', admin.site.urls),
path('two_factor/', include(('admin_two_factor.urls', 'admin_two_factor'), namespace='two_factor')),
# ...
]

# Django version = 1
# urlpatterns = [
# url(r'^admin/', include(admin.site.urls)),
# url(r'^two_factor/', include(('admin_two_factor.urls', 'admin_two_factor'), namespace='two_factor')),
```

* Collect static if you are in production environment:
Expand Down
18 changes: 13 additions & 5 deletions admin_two_factor/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from django.urls import path

import django
from admin_two_factor.views import TwoStepVerification

urlpatterns = [
path('verification/', TwoStepVerification.as_view(), name='verification'),
]
if django.VERSION[0] >= 2:
from django.urls import path

urlpatterns = [
path('verification/', TwoStepVerification.as_view(), name='verification'),
]
else:
from django.conf.urls import url

urlpatterns = [
url(r'^verification/', TwoStepVerification.as_view(), name='verification'),
]

0 comments on commit b42e5dd

Please sign in to comment.