Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm going to guess that what you actually want to do is simply get the relevant object in the <code>detail</code> view.</p> <p>But first, a word of warning: your URL is very strange and won't give you the result you expect. You have no division between the values of owner id, owner, and id, so the regex will <em>always</em> allocate all the characters up to the last two as owner id, and one each to owner and id. For example, if your URL was <code>products/category/type/1daniel34/</code>, instead of being parsed as <code>('1', 'daniel', '34')</code> this would always be parsed as <code>('1daniel', '3', '4')</code>. You should put a slash between each element to be captured, use <code>\d</code> instead of <code>\w</code> to match digits, and use named groups:</p> <pre><code>^products/category/type/(?P&lt;owner_id&gt;\d+)/(?P&lt;owner&gt;\w+)/(?P&lt;id&gt;\d+)/$ </code></pre> <p>(Also, you should consider using <a href="https://docs.djangoproject.com/en/1.4/ref/models/instances/#django.db.models.permalink" rel="nofollow">the <code>permalink</code> decorator</a> to produce your absolute URL, rather than reproducing the whole string from the urlconf.)</p> <p>Now, the point of a view is that it is passed the values captured from the URL conf. So your reference to the absolute URL is confusing: there's no reason to care about the value produced by get_absolute_url, you simply have to query the database using the values you are passed in the view. In this case, your view would look something like this:</p> <pre><code>def detail(owner_id, owner, id): product = Product.objects.get(id=id, owner_id=owner_id) ...etc... </code></pre> <p>Note that I've left out the reference to <code>owner</code>, as it seems likely that the owner ID is enough to identify the object. In fact, I would say that the id itself is enough, since it is unique, and you don't need the owner at all: but that's up to you to decide.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload