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

  • Home
  • SEARCH
  • 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 8579513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:37:21+00:00 2026-06-11T20:37:21+00:00

I have 2 tables one with a ForeignKey the current site has a slug

  • 0

I have 2 tables one with a ForeignKey the current site has a slug i want to lookup a set of objects that have a reference that is the slug

Every Non Profit gets donations, help me show the donations given to one non-profit by the label on the present

Here is my views.py

def nonProfit(request,slug):
    """ we need a page to serve info about non profit pages"""
    np = get_object_or_404(NonProfit,slug=slug)
    try:
        nonProfit_slug = NonProfit.objects.filter(name=slug)
        donation_list = Donation.objects.filter(towards=nonProfit_slug)

        paginator = Paginator(donation_list, 4) # Show 4 contacts per page

        page = request.GET.get('page')
        try:
            donations = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            donations = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            donations = paginator.page(paginator.num_pages)
        return render_to_response('nonProfit.html',
    {"donations":donations,
    "site":settings.SITE_DOMAIN,
    "nonProfit":np},
    context_instance=RequestContext(request))

    except: # no donations
        return render_to_response('nonProfit.html',{'nonProfit':np},context_instance=RequestContext(request))

My models.py

class Donation (models.Model):
    user = models.ForeignKey(User)
    name = models.CharField(max_length=50)
    description = models.CharField(max_length=3000)
    towards = models.ForeignKey(NonProfit)
    image = models.ImageField(upload_to='photos/%Y/%m/%d')
    slug = models.SlugField(max_length=128)
    slug = AutoSlugField(('slug'), max_length=128, unique=True, populate_from=('name',))
    ticketPrice = models.IntegerField()

    enable_comments = models.BooleanField()
class NonProfit (models.Model):
    user = models.ForeignKey(User)
    name = models.CharField(max_length=50)
    address = models.CharField(max_length=50)
    city = models.CharField(max_length=60)
    state_province = models.CharField(max_length=30)
    country = models.CharField(max_length=50)
    website = models.URLField()
    email = models.EmailField()
    money_gained = models.IntegerField()
    money_gained.null = True
    slug = models.SlugField(max_length=128)
    slug = AutoSlugField(('slug'), max_length=128, unique=True, populate_from=('name',))


    description = models.CharField(max_length=3000)

    def __unicode__(self):
        return self.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-11T20:37:22+00:00Added an answer on June 11, 2026 at 8:37 pm

    This is what you’re after I think.

    Example:

    np = get_object_or_404(NonProfit,slug=slug)
    related_donations = np.donation_set.all() 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have two tables that are linked (one has a foreign key to
I have two tables, one that has a foreign key from the other. I
I was making one table that have two foreign key to another tables. But
I have two tables, one with products and a foreign key for the customer.
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables one called fs_note the other called dumy_fs_note I created after
i have two tables one is called addons and holds information about different addons,
I have 2 tables - one storing user information (id, username, password) and the
I have two tables : one table it matchs and the other is teams.
I have four tables. Three of them are tables with one key and they

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.