If you need to write code which is Python2 and Python3 compatible you can use the following import
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
More Related Contents:
- Django: add image in an ImageField from image url
- Does the django-rest-framework provide an admin site to manage models?
- Django dynamic model fields
- How to convert JSON data into a Python object?
- Django filter queryset __in for *every* item in list
- How to execute a Python script from the Django shell?
- Django, creating a custom 500/404 error page
- Django: Redirect to previous page after login
- How do I force Django to ignore any caches and reload data?
- Django: Adding “NULLS LAST” to query
- Serving dynamically generated ZIP archives in Django
- Django Rest Framework writable nested serializers
- How can I save my secret keys and password securely in my version control system?
- get request data in Django form
- How do I use Django templates without the rest of Django?
- many-to-many in list display django
- Calling a REST API from django view
- Django – makemigrations – No changes detected
- Class has no objects member
- Python – make a POST request using Python 3 urllib
- Django 1.11 TypeError context must be a dict rather than Context
- How do I filter values in a Django form using ModelForm?
- Django cannot import login from django.contrib.auth.views
- Django ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
- Running a specific test case in Django when your app has a tests directory
- Change a Django form field to a hidden field
- Making django server accessible in LAN
- Django Admin: Using a custom widget for only one model field
- django excel xlwt
- Deploying Django to Heroku (Psycopg2 Error)