Exception Value: Generic detail view TransactionDetailView must be called with either an object pk or a slug












0















This error arises when I attempt to visit the Transaction Detail page from my Transaction List page. I am using a UUID (primary=true) as the PK for the Transaction Detail page.



memberships/models.py



class Transaction(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="user_transaction")
order_id = models.CharField(max_length=36, blank=True, unique=True, default=uuid.uuid4, primary_key=True, editable=False)
membership = models.ForeignKey(Membership, on_delete=models.SET_NULL, null=True, blank=True)
amount = models.DecimalField(max_digits=100, decimal_places=2)
success = models.BooleanField(default=True)
timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)


def __str__(self):
return self.order_id

class Meta:
ordering = ['-timestamp']


urls.py



...removed imports


urlpatterns = [

#Generic
url(r'^django-admin/', admin.site.urls),
url(r'^admin/', include(wagtailadmin_urls)),
url(r'^documents/', include(wagtaildocs_urls)),
url(r'^search/$', search_views.search, name='search'),

#Authentication
url(r'^accounts/', include('allauth.urls')),

#Product
url(r'^portal/', include(('portal.urls', 'portal'), namespace='portal')),

#Payment
url(r'^checkout/', include(('checkout.urls', 'checkout'), namespace='checkout')),

#Membership
url(r'^membership/', include(('memberships.urls', 'memberships'), namespace='memberships')),

#Rating
url(r'^ratings/', include('star_ratings.urls', namespace='ratings')),

#Users
url(r'^users/$', UserListView.as_view(), name='users_list'),
url(r'^profile/$', userPage, name='userPage'),
url(r'^users/~redirect/$', UserRedirectView.as_view(), name='redirect'),
url(r'^users/(?P<username>[w.@+-]+)/$', UserDetailView.as_view(), name='detail'),
url(r'^users/(?P<username>[w.@+-]+)/summary/$', SummaryDetailView.as_view(), name='summary'),
url(r'^users/~update/$', UserUpdateView.as_view(), name='update'),
url(r'^users/redirectprofile/$', RedirectProfileView.as_view(), name='redirectprofile'),
# For anything not caught by a more specific rule above, hand over to
# Wagtail's page serving mechanism. This should be the last pattern in
# the list:
url(r'', include(wagtail_urls)),

# Alternatively, if you want Wagtail pages to be served from a subpath
# of your site, rather than the site root:
# url(r'^pages/', include(wagtail_urls)),
]




if settings.DEBUG:
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

# Serve static and media files from development server
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


memberships/urls.py



from django.urls import path

from .views import (
MembershipSelectView,
PaymentView,
success,
updateTransactionRecords,
user_subscriptions_view,
cancelSubscription,
TransactionDetailView,
TransactionListView,
SubscriptionDetailView,
SubscriptionListView,
adminPanel,
permission_denied
)

app_name = 'memberships'

urlpatterns = [
path('', MembershipSelectView.as_view(), name='select'),
path('payment/', PaymentView, name='payment'),
path('success/', success, name='purchase_success'),
path('update-transactions/<subscription_id>/', updateTransactionRecords, name='update-transactions'),
path('subscription/', user_subscriptions_view, name='user_subscription'),
path('cancel/', cancelSubscription, name='cancel'),

#TODO MAKE SURE ONLY SUPERUSERS CAN VIEW THESE PAGES
path('transactions/', TransactionListView.as_view(), name='transaction_list'),
path('transaction/<uuid:order_id>/', TransactionDetailView.as_view(), name='transaction_detail'),
path('subscriptions/', SubscriptionListView.as_view(), name='subscription_list'),
path('subscription/<slug:id>/', SubscriptionDetailView.as_view(), name='subscription_detail'),
path('admin/', adminPanel, name='admin_panel'),
path('permission_denied/', permission_denied, name='permission_denied')
]


memberships/views.py



class TransactionDetailView(DetailView):
model = Transaction
slug_field = 'order_id'


memberships/transaction_list.html



      {% if object_list %}

{% for transaction in object_list %}
<tr class="text-left">
<td ><strong><a href="{% url 'memberships:transaction_detail' transaction.order_id %}" class="text-dark">{{ transaction.user }}</a></strong></td>
<td class="text-dark">{{ transaction.order_id }}</td>
<td class="text-dark ">{{ transaction.timestamp }}</td>
<td class="text-dark ">{{ transaction.success }}</td>
<td class="text-dark">$ {{ transaction.amount }}</td>
</tr>
{% endfor %}

{% else %}
<p>There were no transactions found.</p>
{% endif %}


EDIT: I added my main urls.py and the memberships/urls.py. The transaction page is under the memberships.urls.










share|improve this question





























    0















    This error arises when I attempt to visit the Transaction Detail page from my Transaction List page. I am using a UUID (primary=true) as the PK for the Transaction Detail page.



    memberships/models.py



    class Transaction(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="user_transaction")
    order_id = models.CharField(max_length=36, blank=True, unique=True, default=uuid.uuid4, primary_key=True, editable=False)
    membership = models.ForeignKey(Membership, on_delete=models.SET_NULL, null=True, blank=True)
    amount = models.DecimalField(max_digits=100, decimal_places=2)
    success = models.BooleanField(default=True)
    timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)


    def __str__(self):
    return self.order_id

    class Meta:
    ordering = ['-timestamp']


    urls.py



    ...removed imports


    urlpatterns = [

    #Generic
    url(r'^django-admin/', admin.site.urls),
    url(r'^admin/', include(wagtailadmin_urls)),
    url(r'^documents/', include(wagtaildocs_urls)),
    url(r'^search/$', search_views.search, name='search'),

    #Authentication
    url(r'^accounts/', include('allauth.urls')),

    #Product
    url(r'^portal/', include(('portal.urls', 'portal'), namespace='portal')),

    #Payment
    url(r'^checkout/', include(('checkout.urls', 'checkout'), namespace='checkout')),

    #Membership
    url(r'^membership/', include(('memberships.urls', 'memberships'), namespace='memberships')),

    #Rating
    url(r'^ratings/', include('star_ratings.urls', namespace='ratings')),

    #Users
    url(r'^users/$', UserListView.as_view(), name='users_list'),
    url(r'^profile/$', userPage, name='userPage'),
    url(r'^users/~redirect/$', UserRedirectView.as_view(), name='redirect'),
    url(r'^users/(?P<username>[w.@+-]+)/$', UserDetailView.as_view(), name='detail'),
    url(r'^users/(?P<username>[w.@+-]+)/summary/$', SummaryDetailView.as_view(), name='summary'),
    url(r'^users/~update/$', UserUpdateView.as_view(), name='update'),
    url(r'^users/redirectprofile/$', RedirectProfileView.as_view(), name='redirectprofile'),
    # For anything not caught by a more specific rule above, hand over to
    # Wagtail's page serving mechanism. This should be the last pattern in
    # the list:
    url(r'', include(wagtail_urls)),

    # Alternatively, if you want Wagtail pages to be served from a subpath
    # of your site, rather than the site root:
    # url(r'^pages/', include(wagtail_urls)),
    ]




    if settings.DEBUG:
    from django.conf.urls.static import static
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns

    # Serve static and media files from development server
    urlpatterns += staticfiles_urlpatterns()
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


    memberships/urls.py



    from django.urls import path

    from .views import (
    MembershipSelectView,
    PaymentView,
    success,
    updateTransactionRecords,
    user_subscriptions_view,
    cancelSubscription,
    TransactionDetailView,
    TransactionListView,
    SubscriptionDetailView,
    SubscriptionListView,
    adminPanel,
    permission_denied
    )

    app_name = 'memberships'

    urlpatterns = [
    path('', MembershipSelectView.as_view(), name='select'),
    path('payment/', PaymentView, name='payment'),
    path('success/', success, name='purchase_success'),
    path('update-transactions/<subscription_id>/', updateTransactionRecords, name='update-transactions'),
    path('subscription/', user_subscriptions_view, name='user_subscription'),
    path('cancel/', cancelSubscription, name='cancel'),

    #TODO MAKE SURE ONLY SUPERUSERS CAN VIEW THESE PAGES
    path('transactions/', TransactionListView.as_view(), name='transaction_list'),
    path('transaction/<uuid:order_id>/', TransactionDetailView.as_view(), name='transaction_detail'),
    path('subscriptions/', SubscriptionListView.as_view(), name='subscription_list'),
    path('subscription/<slug:id>/', SubscriptionDetailView.as_view(), name='subscription_detail'),
    path('admin/', adminPanel, name='admin_panel'),
    path('permission_denied/', permission_denied, name='permission_denied')
    ]


    memberships/views.py



    class TransactionDetailView(DetailView):
    model = Transaction
    slug_field = 'order_id'


    memberships/transaction_list.html



          {% if object_list %}

    {% for transaction in object_list %}
    <tr class="text-left">
    <td ><strong><a href="{% url 'memberships:transaction_detail' transaction.order_id %}" class="text-dark">{{ transaction.user }}</a></strong></td>
    <td class="text-dark">{{ transaction.order_id }}</td>
    <td class="text-dark ">{{ transaction.timestamp }}</td>
    <td class="text-dark ">{{ transaction.success }}</td>
    <td class="text-dark">$ {{ transaction.amount }}</td>
    </tr>
    {% endfor %}

    {% else %}
    <p>There were no transactions found.</p>
    {% endif %}


    EDIT: I added my main urls.py and the memberships/urls.py. The transaction page is under the memberships.urls.










    share|improve this question



























      0












      0








      0








      This error arises when I attempt to visit the Transaction Detail page from my Transaction List page. I am using a UUID (primary=true) as the PK for the Transaction Detail page.



      memberships/models.py



      class Transaction(models.Model):
      user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="user_transaction")
      order_id = models.CharField(max_length=36, blank=True, unique=True, default=uuid.uuid4, primary_key=True, editable=False)
      membership = models.ForeignKey(Membership, on_delete=models.SET_NULL, null=True, blank=True)
      amount = models.DecimalField(max_digits=100, decimal_places=2)
      success = models.BooleanField(default=True)
      timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)


      def __str__(self):
      return self.order_id

      class Meta:
      ordering = ['-timestamp']


      urls.py



      ...removed imports


      urlpatterns = [

      #Generic
      url(r'^django-admin/', admin.site.urls),
      url(r'^admin/', include(wagtailadmin_urls)),
      url(r'^documents/', include(wagtaildocs_urls)),
      url(r'^search/$', search_views.search, name='search'),

      #Authentication
      url(r'^accounts/', include('allauth.urls')),

      #Product
      url(r'^portal/', include(('portal.urls', 'portal'), namespace='portal')),

      #Payment
      url(r'^checkout/', include(('checkout.urls', 'checkout'), namespace='checkout')),

      #Membership
      url(r'^membership/', include(('memberships.urls', 'memberships'), namespace='memberships')),

      #Rating
      url(r'^ratings/', include('star_ratings.urls', namespace='ratings')),

      #Users
      url(r'^users/$', UserListView.as_view(), name='users_list'),
      url(r'^profile/$', userPage, name='userPage'),
      url(r'^users/~redirect/$', UserRedirectView.as_view(), name='redirect'),
      url(r'^users/(?P<username>[w.@+-]+)/$', UserDetailView.as_view(), name='detail'),
      url(r'^users/(?P<username>[w.@+-]+)/summary/$', SummaryDetailView.as_view(), name='summary'),
      url(r'^users/~update/$', UserUpdateView.as_view(), name='update'),
      url(r'^users/redirectprofile/$', RedirectProfileView.as_view(), name='redirectprofile'),
      # For anything not caught by a more specific rule above, hand over to
      # Wagtail's page serving mechanism. This should be the last pattern in
      # the list:
      url(r'', include(wagtail_urls)),

      # Alternatively, if you want Wagtail pages to be served from a subpath
      # of your site, rather than the site root:
      # url(r'^pages/', include(wagtail_urls)),
      ]




      if settings.DEBUG:
      from django.conf.urls.static import static
      from django.contrib.staticfiles.urls import staticfiles_urlpatterns

      # Serve static and media files from development server
      urlpatterns += staticfiles_urlpatterns()
      urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


      memberships/urls.py



      from django.urls import path

      from .views import (
      MembershipSelectView,
      PaymentView,
      success,
      updateTransactionRecords,
      user_subscriptions_view,
      cancelSubscription,
      TransactionDetailView,
      TransactionListView,
      SubscriptionDetailView,
      SubscriptionListView,
      adminPanel,
      permission_denied
      )

      app_name = 'memberships'

      urlpatterns = [
      path('', MembershipSelectView.as_view(), name='select'),
      path('payment/', PaymentView, name='payment'),
      path('success/', success, name='purchase_success'),
      path('update-transactions/<subscription_id>/', updateTransactionRecords, name='update-transactions'),
      path('subscription/', user_subscriptions_view, name='user_subscription'),
      path('cancel/', cancelSubscription, name='cancel'),

      #TODO MAKE SURE ONLY SUPERUSERS CAN VIEW THESE PAGES
      path('transactions/', TransactionListView.as_view(), name='transaction_list'),
      path('transaction/<uuid:order_id>/', TransactionDetailView.as_view(), name='transaction_detail'),
      path('subscriptions/', SubscriptionListView.as_view(), name='subscription_list'),
      path('subscription/<slug:id>/', SubscriptionDetailView.as_view(), name='subscription_detail'),
      path('admin/', adminPanel, name='admin_panel'),
      path('permission_denied/', permission_denied, name='permission_denied')
      ]


      memberships/views.py



      class TransactionDetailView(DetailView):
      model = Transaction
      slug_field = 'order_id'


      memberships/transaction_list.html



            {% if object_list %}

      {% for transaction in object_list %}
      <tr class="text-left">
      <td ><strong><a href="{% url 'memberships:transaction_detail' transaction.order_id %}" class="text-dark">{{ transaction.user }}</a></strong></td>
      <td class="text-dark">{{ transaction.order_id }}</td>
      <td class="text-dark ">{{ transaction.timestamp }}</td>
      <td class="text-dark ">{{ transaction.success }}</td>
      <td class="text-dark">$ {{ transaction.amount }}</td>
      </tr>
      {% endfor %}

      {% else %}
      <p>There were no transactions found.</p>
      {% endif %}


      EDIT: I added my main urls.py and the memberships/urls.py. The transaction page is under the memberships.urls.










      share|improve this question
















      This error arises when I attempt to visit the Transaction Detail page from my Transaction List page. I am using a UUID (primary=true) as the PK for the Transaction Detail page.



      memberships/models.py



      class Transaction(models.Model):
      user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="user_transaction")
      order_id = models.CharField(max_length=36, blank=True, unique=True, default=uuid.uuid4, primary_key=True, editable=False)
      membership = models.ForeignKey(Membership, on_delete=models.SET_NULL, null=True, blank=True)
      amount = models.DecimalField(max_digits=100, decimal_places=2)
      success = models.BooleanField(default=True)
      timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)


      def __str__(self):
      return self.order_id

      class Meta:
      ordering = ['-timestamp']


      urls.py



      ...removed imports


      urlpatterns = [

      #Generic
      url(r'^django-admin/', admin.site.urls),
      url(r'^admin/', include(wagtailadmin_urls)),
      url(r'^documents/', include(wagtaildocs_urls)),
      url(r'^search/$', search_views.search, name='search'),

      #Authentication
      url(r'^accounts/', include('allauth.urls')),

      #Product
      url(r'^portal/', include(('portal.urls', 'portal'), namespace='portal')),

      #Payment
      url(r'^checkout/', include(('checkout.urls', 'checkout'), namespace='checkout')),

      #Membership
      url(r'^membership/', include(('memberships.urls', 'memberships'), namespace='memberships')),

      #Rating
      url(r'^ratings/', include('star_ratings.urls', namespace='ratings')),

      #Users
      url(r'^users/$', UserListView.as_view(), name='users_list'),
      url(r'^profile/$', userPage, name='userPage'),
      url(r'^users/~redirect/$', UserRedirectView.as_view(), name='redirect'),
      url(r'^users/(?P<username>[w.@+-]+)/$', UserDetailView.as_view(), name='detail'),
      url(r'^users/(?P<username>[w.@+-]+)/summary/$', SummaryDetailView.as_view(), name='summary'),
      url(r'^users/~update/$', UserUpdateView.as_view(), name='update'),
      url(r'^users/redirectprofile/$', RedirectProfileView.as_view(), name='redirectprofile'),
      # For anything not caught by a more specific rule above, hand over to
      # Wagtail's page serving mechanism. This should be the last pattern in
      # the list:
      url(r'', include(wagtail_urls)),

      # Alternatively, if you want Wagtail pages to be served from a subpath
      # of your site, rather than the site root:
      # url(r'^pages/', include(wagtail_urls)),
      ]




      if settings.DEBUG:
      from django.conf.urls.static import static
      from django.contrib.staticfiles.urls import staticfiles_urlpatterns

      # Serve static and media files from development server
      urlpatterns += staticfiles_urlpatterns()
      urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


      memberships/urls.py



      from django.urls import path

      from .views import (
      MembershipSelectView,
      PaymentView,
      success,
      updateTransactionRecords,
      user_subscriptions_view,
      cancelSubscription,
      TransactionDetailView,
      TransactionListView,
      SubscriptionDetailView,
      SubscriptionListView,
      adminPanel,
      permission_denied
      )

      app_name = 'memberships'

      urlpatterns = [
      path('', MembershipSelectView.as_view(), name='select'),
      path('payment/', PaymentView, name='payment'),
      path('success/', success, name='purchase_success'),
      path('update-transactions/<subscription_id>/', updateTransactionRecords, name='update-transactions'),
      path('subscription/', user_subscriptions_view, name='user_subscription'),
      path('cancel/', cancelSubscription, name='cancel'),

      #TODO MAKE SURE ONLY SUPERUSERS CAN VIEW THESE PAGES
      path('transactions/', TransactionListView.as_view(), name='transaction_list'),
      path('transaction/<uuid:order_id>/', TransactionDetailView.as_view(), name='transaction_detail'),
      path('subscriptions/', SubscriptionListView.as_view(), name='subscription_list'),
      path('subscription/<slug:id>/', SubscriptionDetailView.as_view(), name='subscription_detail'),
      path('admin/', adminPanel, name='admin_panel'),
      path('permission_denied/', permission_denied, name='permission_denied')
      ]


      memberships/views.py



      class TransactionDetailView(DetailView):
      model = Transaction
      slug_field = 'order_id'


      memberships/transaction_list.html



            {% if object_list %}

      {% for transaction in object_list %}
      <tr class="text-left">
      <td ><strong><a href="{% url 'memberships:transaction_detail' transaction.order_id %}" class="text-dark">{{ transaction.user }}</a></strong></td>
      <td class="text-dark">{{ transaction.order_id }}</td>
      <td class="text-dark ">{{ transaction.timestamp }}</td>
      <td class="text-dark ">{{ transaction.success }}</td>
      <td class="text-dark">$ {{ transaction.amount }}</td>
      </tr>
      {% endfor %}

      {% else %}
      <p>There were no transactions found.</p>
      {% endif %}


      EDIT: I added my main urls.py and the memberships/urls.py. The transaction page is under the memberships.urls.







      django uuid






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 3:49







      Dominic M.

















      asked Nov 15 '18 at 18:45









      Dominic M.Dominic M.

      9319




      9319
























          2 Answers
          2






          active

          oldest

          votes


















          1














          You need to update the slug_url_kwarg in your view. For example:



          class TransactionDetailView(DetailView):
          model = Transaction
          slug_field = 'order_id'
          slug_url_kwarg = 'order_id'
          ...


          Because based on this code, slug value is taken from kwargs by attribute slug_url_kwarg of the View.



          Also please update the url path.



          Url:



          path('transaction/<uuid:order_id>/', TransactionDetailView.as_view(), name='transaction_detail'),





          share|improve this answer


























          • Now i'm getting this error, Exception Value: Reverse for 'transaction_detail' not found. 'transaction_detail' is not a valid view function or pattern name.

            – Dominic M.
            Nov 15 '18 at 21:30











          • @DominicM. Please see the url section of my answer.

            – ruddra
            Nov 16 '18 at 1:25











          • Still isn't working, same error

            – Dominic M.
            Nov 16 '18 at 2:19











          • Can you please share your main urls.py(which sits beside settings.py)?

            – ruddra
            Nov 16 '18 at 3:13






          • 1





            Lol I found it, not sure how I didn't see it. I had {{ url 'checkout:transaction_detail' transactions.order_id }}. The checkout needed to be changed to memberships. Thank you for all the help!

            – Dominic M.
            Nov 16 '18 at 13:25





















          1














          You've set the view's slug_field parameter to order_id, but you haven't told it where to get the value for that field; the view is still expecting the URL to give it either pk or slug, as the error says.



          In fact, your order_id is the primary key, not the slug, and Django already has an alias to whatever your primary key is: pk. So you should replace that attribute with pk_url_kwarg.



          class TransactionDetailView(DetailView):
          model = Transaction
          pk_url_kwarg = 'order_id'





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326047%2fexception-value-generic-detail-view-transactiondetailview-must-be-called-with-e%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You need to update the slug_url_kwarg in your view. For example:



            class TransactionDetailView(DetailView):
            model = Transaction
            slug_field = 'order_id'
            slug_url_kwarg = 'order_id'
            ...


            Because based on this code, slug value is taken from kwargs by attribute slug_url_kwarg of the View.



            Also please update the url path.



            Url:



            path('transaction/<uuid:order_id>/', TransactionDetailView.as_view(), name='transaction_detail'),





            share|improve this answer


























            • Now i'm getting this error, Exception Value: Reverse for 'transaction_detail' not found. 'transaction_detail' is not a valid view function or pattern name.

              – Dominic M.
              Nov 15 '18 at 21:30











            • @DominicM. Please see the url section of my answer.

              – ruddra
              Nov 16 '18 at 1:25











            • Still isn't working, same error

              – Dominic M.
              Nov 16 '18 at 2:19











            • Can you please share your main urls.py(which sits beside settings.py)?

              – ruddra
              Nov 16 '18 at 3:13






            • 1





              Lol I found it, not sure how I didn't see it. I had {{ url 'checkout:transaction_detail' transactions.order_id }}. The checkout needed to be changed to memberships. Thank you for all the help!

              – Dominic M.
              Nov 16 '18 at 13:25


















            1














            You need to update the slug_url_kwarg in your view. For example:



            class TransactionDetailView(DetailView):
            model = Transaction
            slug_field = 'order_id'
            slug_url_kwarg = 'order_id'
            ...


            Because based on this code, slug value is taken from kwargs by attribute slug_url_kwarg of the View.



            Also please update the url path.



            Url:



            path('transaction/<uuid:order_id>/', TransactionDetailView.as_view(), name='transaction_detail'),





            share|improve this answer


























            • Now i'm getting this error, Exception Value: Reverse for 'transaction_detail' not found. 'transaction_detail' is not a valid view function or pattern name.

              – Dominic M.
              Nov 15 '18 at 21:30











            • @DominicM. Please see the url section of my answer.

              – ruddra
              Nov 16 '18 at 1:25











            • Still isn't working, same error

              – Dominic M.
              Nov 16 '18 at 2:19











            • Can you please share your main urls.py(which sits beside settings.py)?

              – ruddra
              Nov 16 '18 at 3:13






            • 1





              Lol I found it, not sure how I didn't see it. I had {{ url 'checkout:transaction_detail' transactions.order_id }}. The checkout needed to be changed to memberships. Thank you for all the help!

              – Dominic M.
              Nov 16 '18 at 13:25
















            1












            1








            1







            You need to update the slug_url_kwarg in your view. For example:



            class TransactionDetailView(DetailView):
            model = Transaction
            slug_field = 'order_id'
            slug_url_kwarg = 'order_id'
            ...


            Because based on this code, slug value is taken from kwargs by attribute slug_url_kwarg of the View.



            Also please update the url path.



            Url:



            path('transaction/<uuid:order_id>/', TransactionDetailView.as_view(), name='transaction_detail'),





            share|improve this answer















            You need to update the slug_url_kwarg in your view. For example:



            class TransactionDetailView(DetailView):
            model = Transaction
            slug_field = 'order_id'
            slug_url_kwarg = 'order_id'
            ...


            Because based on this code, slug value is taken from kwargs by attribute slug_url_kwarg of the View.



            Also please update the url path.



            Url:



            path('transaction/<uuid:order_id>/', TransactionDetailView.as_view(), name='transaction_detail'),






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 16 '18 at 1:24

























            answered Nov 15 '18 at 19:50









            ruddraruddra

            15.7k32951




            15.7k32951













            • Now i'm getting this error, Exception Value: Reverse for 'transaction_detail' not found. 'transaction_detail' is not a valid view function or pattern name.

              – Dominic M.
              Nov 15 '18 at 21:30











            • @DominicM. Please see the url section of my answer.

              – ruddra
              Nov 16 '18 at 1:25











            • Still isn't working, same error

              – Dominic M.
              Nov 16 '18 at 2:19











            • Can you please share your main urls.py(which sits beside settings.py)?

              – ruddra
              Nov 16 '18 at 3:13






            • 1





              Lol I found it, not sure how I didn't see it. I had {{ url 'checkout:transaction_detail' transactions.order_id }}. The checkout needed to be changed to memberships. Thank you for all the help!

              – Dominic M.
              Nov 16 '18 at 13:25





















            • Now i'm getting this error, Exception Value: Reverse for 'transaction_detail' not found. 'transaction_detail' is not a valid view function or pattern name.

              – Dominic M.
              Nov 15 '18 at 21:30











            • @DominicM. Please see the url section of my answer.

              – ruddra
              Nov 16 '18 at 1:25











            • Still isn't working, same error

              – Dominic M.
              Nov 16 '18 at 2:19











            • Can you please share your main urls.py(which sits beside settings.py)?

              – ruddra
              Nov 16 '18 at 3:13






            • 1





              Lol I found it, not sure how I didn't see it. I had {{ url 'checkout:transaction_detail' transactions.order_id }}. The checkout needed to be changed to memberships. Thank you for all the help!

              – Dominic M.
              Nov 16 '18 at 13:25



















            Now i'm getting this error, Exception Value: Reverse for 'transaction_detail' not found. 'transaction_detail' is not a valid view function or pattern name.

            – Dominic M.
            Nov 15 '18 at 21:30





            Now i'm getting this error, Exception Value: Reverse for 'transaction_detail' not found. 'transaction_detail' is not a valid view function or pattern name.

            – Dominic M.
            Nov 15 '18 at 21:30













            @DominicM. Please see the url section of my answer.

            – ruddra
            Nov 16 '18 at 1:25





            @DominicM. Please see the url section of my answer.

            – ruddra
            Nov 16 '18 at 1:25













            Still isn't working, same error

            – Dominic M.
            Nov 16 '18 at 2:19





            Still isn't working, same error

            – Dominic M.
            Nov 16 '18 at 2:19













            Can you please share your main urls.py(which sits beside settings.py)?

            – ruddra
            Nov 16 '18 at 3:13





            Can you please share your main urls.py(which sits beside settings.py)?

            – ruddra
            Nov 16 '18 at 3:13




            1




            1





            Lol I found it, not sure how I didn't see it. I had {{ url 'checkout:transaction_detail' transactions.order_id }}. The checkout needed to be changed to memberships. Thank you for all the help!

            – Dominic M.
            Nov 16 '18 at 13:25







            Lol I found it, not sure how I didn't see it. I had {{ url 'checkout:transaction_detail' transactions.order_id }}. The checkout needed to be changed to memberships. Thank you for all the help!

            – Dominic M.
            Nov 16 '18 at 13:25















            1














            You've set the view's slug_field parameter to order_id, but you haven't told it where to get the value for that field; the view is still expecting the URL to give it either pk or slug, as the error says.



            In fact, your order_id is the primary key, not the slug, and Django already has an alias to whatever your primary key is: pk. So you should replace that attribute with pk_url_kwarg.



            class TransactionDetailView(DetailView):
            model = Transaction
            pk_url_kwarg = 'order_id'





            share|improve this answer




























              1














              You've set the view's slug_field parameter to order_id, but you haven't told it where to get the value for that field; the view is still expecting the URL to give it either pk or slug, as the error says.



              In fact, your order_id is the primary key, not the slug, and Django already has an alias to whatever your primary key is: pk. So you should replace that attribute with pk_url_kwarg.



              class TransactionDetailView(DetailView):
              model = Transaction
              pk_url_kwarg = 'order_id'





              share|improve this answer


























                1












                1








                1







                You've set the view's slug_field parameter to order_id, but you haven't told it where to get the value for that field; the view is still expecting the URL to give it either pk or slug, as the error says.



                In fact, your order_id is the primary key, not the slug, and Django already has an alias to whatever your primary key is: pk. So you should replace that attribute with pk_url_kwarg.



                class TransactionDetailView(DetailView):
                model = Transaction
                pk_url_kwarg = 'order_id'





                share|improve this answer













                You've set the view's slug_field parameter to order_id, but you haven't told it where to get the value for that field; the view is still expecting the URL to give it either pk or slug, as the error says.



                In fact, your order_id is the primary key, not the slug, and Django already has an alias to whatever your primary key is: pk. So you should replace that attribute with pk_url_kwarg.



                class TransactionDetailView(DetailView):
                model = Transaction
                pk_url_kwarg = 'order_id'






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 19:50









                Daniel RosemanDaniel Roseman

                456k41592649




                456k41592649






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326047%2fexception-value-generic-detail-view-transactiondetailview-must-be-called-with-e%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Florida Star v. B. J. F.

                    Danny Elfman

                    Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues