title: ValueError: Don't mix *args and **kwargs in call to reverse()!
body: <p>I am trying to render_to_response to return a rendered response of my view to an ajax call, but I am getting the following error that I don't really understand...</p>
  
  <pre><code>Internal Server Error: /schedules/calendar/2014/10/1/
  Traceback (most recent call last):
    File "/blahblahblah/django/core/handlers/base.py", line 111, in get_response
      response = wrapped_callback(request, *callback_args, **callback_kwargs)
    File "/blahblahblah/schedules/views.py", line 229, in month_view
      return render_to_string(template, data)
    File "/blahblahblah/django/template/loader.py", line 172, in render_to_string
      return t.render(Context(dictionary))
    File "/blahblahblah/django/template/base.py", line 148, in render
      return self._render(context)
    File "/blahblahblah/django/template/base.py", line 142, in _render
      return self.nodelist.render(context)
    File "/blahblahblah/django/template/base.py", line 844, in render
      bit = self.render_node(node, context)
    File "/blahblahblah/django/template/debug.py", line 80, in render_node
      return node.render(context)
    File "/blahblahblah/django/template/defaulttags.py", line 444, in render
      url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app)
    File "/blahblahblah/django/core/urlresolvers.py", line 546, in reverse
      return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
    File "/blahblahblah/django/core/urlresolvers.py", line 405, in _reverse_with_prefix
      raise ValueError("Don't mix *args and **kwargs in call to reverse()!")
  
  ValueError: Don't mix *args and **kwargs in call to reverse()!
  </code></pre>
  
  <p>I don't understand where this error is coming from. I am calling request_to_response as per instructed in the django documentation. Here is my view:</p>
  
  <pre><code>def month_view(
      request, 
      year, 
      month, 
      template='monthly_view.html',
      user_id=None,
      queryset=None
  ):
      year, month = int(year), int(month)
      cal         = calendar.monthcalendar(year, month)
      dtstart     = datetime(year, month, 1)
      last_day    = max(cal[-1])
      dtend       = datetime(year, month, last_day)
  
      if user_id:
          profile = get_object_or_404(UserProfile, pk=user_id)
          queryset = profile.occurrence_set
      queryset = queryset._clone() if queryset else Occurrence.objects.select_related()
      occurrences = queryset.filter(start_time__year=year, start_time__month=month)
  
      def start_day(o):
          return o.start_time.day
  
      by_day = dict([(dt, list(o)) for dt,o in itertools.groupby(occurrences, start_day)])
      data = {
          'today':      datetime.now(),
          'calendar':   [[(d, by_day.get(d, [])) for d in row] for row in cal], 
          'this_month': dtstart,
          'next_month': dtstart + timedelta(days=+last_day),
          'last_month': dtstart + timedelta(days=-1),
      }
  
      if request.is_ajax():
          my_html = render_to_string('monthly_view.html', data)
          return HttpResponse(json.dumps(my_html), content_type="application/json")
      else:
          raise Http404
  </code></pre>
  
  <p>Has anyone encountered an error like this before, or have any idea where it is coming from?
  On the line right before the call to reverse the parameters for reverse are </p>
  
  <blockquote>
    <p>View_name: schedules:monthly-view  Args: [2014, 9]  kwargs:
    {'user_pk':
    ''}</p>
  </blockquote>
  
  <p>Template I am trying to render is:</p>
  
  <pre><code>&lt;h4&gt;
      &lt;a href="{% url 'schedules:monthly-view' last_month.year last_month.month user_pk=object.profile.pk %}" 
          title="Last Month"&gt;&amp;larr;&lt;/a&gt;
      {{ this_month|date:"F" }}
      &lt;a title="View {{ this_month.year}}" href='#'&gt;
          {{ this_month|date:"Y" }}&lt;/a&gt;
      &lt;a href="{% url 'schedules:monthly-view' next_month.year next_month.month user_pk=object.profile.pk %}" 
         title="Next Month"&gt;&amp;rarr;&lt;/a&gt;
  &lt;/h4&gt;
  &lt;table class="month-view"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Sun&lt;/th&gt;&lt;th&gt;Mon&lt;/th&gt;&lt;th&gt;Tue&lt;/th&gt;&lt;th&gt;Wed&lt;/th&gt;&lt;th&gt;Thu&lt;/th&gt;&lt;th&gt;Fri&lt;/th&gt;&lt;th&gt;Sat&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          {% for row in calendar %}
          &lt;tr&gt;
              {% for day,items in row  %}
              &lt;td{% ifequal day today.day  %} class="today"{% endifequal %}&gt;
              {% if day %}
                  &lt;div class="day-ordinal"&gt;
                      &lt;a href="{% url 'schedules:daily-view' this_month.year this_month.month day user_pk=object.profile.pk %}"&gt;{{ day }}&lt;/a&gt;
                  &lt;/div&gt;
                  {% if items %}
                  &lt;ul&gt;
                      {% for item in items %}
                      &lt;li&gt;
                          &lt;a href="{{ item.get_absolute_url }}"&gt;
                              &lt;span class="event-times"&gt;{{ item.start_time|time }}&lt;/span&gt;
                              {{ item.title }}&lt;/a&gt;
                      &lt;/li&gt;
                      {% endfor %}
                  &lt;/ul&gt;
                  {% endif %}
              {% endif %}
              &lt;/td&gt;
              {% endfor %}
          &lt;/tr&gt;
          {% endfor %}
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>and urls.py is </p>
  
  <pre><code>from django.conf.urls import patterns, url
  
  from .views import (
      CreateSessionView, CreateListingsView, SessionsListView,
      month_view, day_view, today_view
  
  )
  
  urlpatterns = patterns('',
      url(
          r'^(?:calendar/)?$', 
          today_view, 
          name='today'
      ),
      url(
          r'^calendar/(?P&lt;year&gt;\d{4})/(?P&lt;month&gt;0?[1-9]|1[012])/(?P&lt;user_pk&gt;\d+)/$', 
          month_view, 
          name='monthly-view'
      ),
  
      url(
          r'^calendar/(?P&lt;year&gt;\d{4})/(?P&lt;month&gt;0?[1-9]|1[012])/(?P&lt;day&gt;[0-3]?\d)/(?P&lt;user_pk&gt;\d+)/$', 
          day_view, 
          name='daily-view'
      ),
  </code></pre>
  
  <p>Additionally, here is the ajax request:</p>
  
  <pre><code>&lt;script&gt;
  
      function update_calendar(url) {
          console.log("Calling url " + url)
          $.ajax({
              type: 'GET',
              dataType: 'json',
              url: url,
              success: function(data, status, xhr) {
                  console.log('success')
                  console.log(data);
                  $('#schedule').html(data)
              },
              error: function() {
                  console.log('Something went wrong');
              }
          });
      }
  
      $(document).ready(function() {
  
          // Initially set up calendar for current month
          var today = new Date();
          var year = today.getFullYear();
          var month = today.getMonth()+1;
          var user_pk = {{ object.profile.pk }};
          var url = '../schedules/calendar/'+year+'/'+month+'/'+user_id+'/';
  
          // EDIT JUST ADDED THIS LINE HERE AND AM GETTING THE ERROR HERE NOW
          url = "{% url 'schedules:monthly-view' year month user_pk=user_pk %}"
  
          update_calendar(url);
  
          $('#schedule &gt; a').click(function(event) {
              var url = $(this).attr('href');
              update_calendar(url);
          });
      });
  &lt;/script&gt;
  </code></pre>