Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8814277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:04:37+00:00 2026-06-14T04:04:37+00:00

I have an application with entries and containers. There is a ManyToMany relationship between

  • 0

I have an application with entries and containers. There is a ManyToMany relationship between them:

  • A container contains 0 or more entries
  • An entry is in 0 or more containers

I use the following schema for URIs:

  • prefix/container
  • prefix/container/entry

This means that several URLs can lead to the same entry. Each URL defines a different context.

I’m trying to create a RSS/Atom Feed for each container. My issue is how to implement the Feed.item_link method to returns
the right URL. I need to invoke urlresolvers.reverse with two arguments: the container identifier and the entry identifier.
Unfortunately item_link receives only the entry as parameter. Only Feed.get_object method knows about the container. What is the cleanest solution to solve this issue ?

Sample code follows:

Models

    class Entry(models.Model):
        pass

    class Container(models.Model):
        entries = models.ManyToManyField("Entries",
                related_name='containers',
                null=True,
                blank=True
        )

URLs

    url(r'^prefix/(?P<container_slug>[-\w]+)/rss$', feeds.LatestEntries()),

Feed

    class LatestEntries(Feed):
        title = "foo"
        description = "bar"

        def get_object(self, request, container_slug):
            return get_object_or_404(models.Container, slug=container_slug)

        def item_link(self, entry):
            # TODO: How to pass container_slug to reverse() ?
            return urlresolvers.reverse('up.views.portfolio_image', kwargs={
                    'container_slug': 'FIXME',
                    'entry_slug': entry.slug,
                })
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:04:39+00:00Added an answer on June 14, 2026 at 4:04 am

    With syndication the situation is complicated by the fact that a single instance of Feed is used to handle all requests, therefore you can’t reliably store the value as an attribute of the Feed instance, instead, you have to somehow use the objects you create to pass the value forward. I can only think of one way forward in this case, short of reimplementing the whole Feed class yourself.

    You’ll need to attach the argument to the object returned by get_object, for example like this (although this step seems redundant in this case as your Container instances will contain this as a regular model field already):

    def get_object(self, request, container_slug):
        object = get_object_or_404(models.Container, slug=container_slug)
        object.container_slug = container_slug
        return object
    

    Then, in items, you’ll have to take this value from the container instance and attach it to each item returned, for example:

    def items(self, container):
        result = list(Entry.objects.filter(field__exact=container.something)[:10])
        for entry in result:
            entry.container_slug = container.container_slug
        return result
    

    You can avoid enumerating the queryset in this step by using a closure and a generator for the list of entries if you feel like it, although it shouldn’t matter in this case if you’re only returning a handful of entries.

    Then, finally, you can implement item_link like this:

    def item_link(self, entry):
        return urlresolvers.reverse('up.views.portfolio_image', kwargs={
                'container_slug': entry.container_slug,
                'entry_slug': entry.slug,
            })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a csv file that contains XML entries. Imagine that each XML entry
In my application I have a UILabel that holds an expanding number of entries
I have a web application that dynamically loads assemblies based on database configuration entries
I have a ASP.NET MVC application and I have a few entries on the
I have application which needs to use a dll (also written by me) which
I have a pretty complex chat application going on, and there are multiple chat
I have an application that contains two Activities with <intent-filter> <action android:name=android.intent.action.MAIN/> <category android:name=android.intent.category.LAUNCHER/>
I have a web application which basically process entries of the user when the
Background: I have created an application that allows users to submit an entry to
I have a simple blog application written in Python, using Django. I use Git

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.