title: Django Sitemap and Absolute URL
body: <p>I have an issue setting up a sitemap with my models. I am getting the following error. Reverse for '5555155555' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []. I think I have to pass a slug to the location but not 100% sure how I would accomplish this task. </p>
  
  <pre><code>#sitemap.py
  from django.contrib.sitemaps import Sitemap
  from django.contrib.flatpages.models import FlatPage
  from django.urls import reverse
  from phonenumbers.models import Phone
  
  
  class PhoneSitemap(Sitemap):
      changefreq = "always"
      priority = 0.5
  
      def items(self):
          return Phone.objects.all()
  
      def location(self, obj):
          return reverse(obj)
  
      def lastmode(self, obj):
          return obj.created
  
  
  class FlatpageSitemap(Sitemap):
      changefreq = "always"
      priority = 0.5
  
      def items(self):
          return FlatPage.objects.all()
  
  #models.py
  class Phone(models.Model):
      phone_number = models.CharField(blank=False, max_length=15) # validators should be a list
      name = models.CharField(max_length=50)
      message = models.TextField()
      caller = models.CharField(max_length=100, choices=CALLER_CHOICES, default="Unknown")
      created = models.DateTimeField(auto_now_add=True)
      slug = models.SlugField(max_length=250, unique=True)
  
      def save(self, *args, **kwargs):
          self.slug = slugify(self.phone_number)
          super(Phone, self).save(*args, **kwargs)
  
      def get_absolute_url(self):
          return reverse('phonenumbers:phone_details', args=[self.slug])
  
      def __str__(self):
          return self.phone_number
  
  #urls.py
  from django.conf.urls import url, include
  from django.contrib import admin
  from django.contrib.flatpages import views
  from django.contrib.sitemaps.views import sitemap
  from .sitemap import PhoneSitemap, FlatpageSitemap
  
  
  from info.views import home
  
  sitemaps = {
      'posts': PhoneSitemap,
      'pages': FlatpageSitemap,
  }
  
  urlpatterns = [
      url(r'^admin/', admin.site.urls),
      url(r'^$', home, name="home"),
      url(r'^privacy-policy/$', views.flatpage, {'url': '/privacy-policy/'}, name='privacy-policy'),
      url(r'^terms-and-conditions/$', views.flatpage, {'url': '/terms-and-conditions/'}, name='terms-and-conditions'),
      url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'),
      url(r'^whocalledme/', include('phonenumbers.urls', app_name="phonenumbers", namespace="phonenumbers")),
  ]
  phonenumbers.urls
  from django.conf.urls import url
  from . import views
  
  urlpatterns = [
      url(r'^search/$', views.search_numbers, name="search_numbers"),
      url(r'^number/(?P&lt;slug&gt;[-\w]+)/$', views.phone_detail, name="phone_detail"),
      url(r'^add_number/$', views.add_number, name='add_number'),
  Environment:
  
  
  Request Method: GET
  Request URL: http://127.0.0.1:8000/sitemap.xml
  
  Django Version: 1.10.4
  Python Version: 3.5.2
  Installed Applications:
  ['django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'django.contrib.sites',
   'django.contrib.flatpages',
   'whitenoise.runserver_nostatic',
   'crispy_forms',
   'django.contrib.sitemaps',
   'phonenumbers']
  Installed Middleware:
  ['django.middleware.security.SecurityMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.middleware.clickjacking.XFrameOptionsMiddleware']
  
  
  
      Traceback:
  
      File "/Users/Tommy/Desktop/django/info/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
        39.             response = get_response(request)
  
      File "/Users/Tommy/Desktop/django/info/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
        187.                 response = self.process_exception_by_middleware(e, request)
  
      File "/Users/Tommy/Desktop/django/info/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
        185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)
  
      File "/Users/Tommy/Desktop/django/info/lib/python3.5/site-packages/django/contrib/sitemaps/views.py" in inner
        16.         response = func(request, *args, **kwargs)
  
      File "/Users/Tommy/Desktop/django/info/lib/python3.5/site-packages/django/contrib/sitemaps/views.py" in sitemap
        68.                                       protocol=req_protocol))
  
      File "/Users/Tommy/Desktop/django/info/lib/python3.5/site-packages/django/contrib/sitemaps/__init__.py" in get_urls
        105.             urls = self._urls(page, protocol, domain)
  
      File "/Users/Tommy/Desktop/django/info/lib/python3.5/site-packages/django/contrib/sitemaps/__init__.py" in _urls
        114.             loc = "%s://%s%s" % (protocol, domain, self.__get('location', item))
  
      File "/Users/Tommy/Desktop/django/info/lib/python3.5/site-packages/django/contrib/sitemaps/__init__.py" in __get
        62.             return attr(obj)
  
      File "/Users/Tommy/Desktop/django/info/info/info/sitemap.py" in location
        15.         return obj.get_absolute_url()
  
      File "/Users/Tommy/Desktop/django/info/info/phonenumbers/models.py" in get_absolute_url
        25.         return reverse('phonenumbers:phone_details', kwargs={'slug': self.slug})
  
      File "/Users/Tommy/Desktop/django/info/lib/python3.5/site-packages/django/urls/base.py" in reverse
        91.     return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
  
      File "/Users/Tommy/Desktop/django/info/lib/python3.5/site-packages/django/urls/resolvers.py" in _reverse_with_prefix
        392.             (lookup_view_s, args, kwargs, len(patterns), patterns)
  
      Exception Type: NoReverseMatch at /sitemap.xml
      Exception Value: Reverse for 'phone_details' with arguments '()' and keyword arguments '{'slug': '2159642387'}' not found. 0 pattern(s) tried: []
  </code></pre>