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 6065937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:26:50+00:00 2026-05-23T09:26:50+00:00

I have set up a pastebin app with Django but I would like to

  • 0

I have set up a pastebin app with Django but I would like to be able to create a list of links to each individual paste on my homepage’s template. I have been trying out a number of different things but am struggling to figure it out.

Here is what I have so far on the template, the app is named oxybeles:

<ul>
{% for ????? in ????? %}               
<a href="{% url oxybeles_detail item.uuid %}">A Link</a>
{% endfor %}
</ul>

And here is the relevant back-end code:

models.py

class PastedItem(models.Model):

    uuid = models.CharField(_('identifier'), max_length=36, unique=True)
    artist = models.CharField(_('artist'), max_length=50)
    album = models.CharField(_('album'), max_length=50)
    in_response_to = models.ForeignKey('self', related_name='responses',
        blank=True, null=True, verbose_name=_('in response to'))
    user = models.ForeignKey(User, related_name="pasted_items",
        verbose_name=_('user'))
    pasted_at = models.DateTimeField(_('pasted at'), auto_now_add=True)

    def __unicode__(self):
        return self.uuid

    def save(self):
        if not self.uuid:
            self.uuid = str(uuid4())  # random so it can't be easily guessed
        super(PastedItem, self).save()

    def get_absolute_url(self):
        return ('oxybeles_detail', (), { 'slug': self.uuid })
        get_absolute_url = models.permalink(get_absolute_url)

views.py

def new(request, form_class=PastedItemForm, template_name="oxybeles/new.html"):

    form = form_class()
    if request.method == 'POST':
        if request.POST["action"] == "paste":
            form = form_class(request.user, request.POST, request.FILES)
            if form.is_valid():
                item = form.save(commit=False)
                item.user = request.user
                item.save()
                request.user.message_set.create(
                    message=ugettext("Your album has been saved."))
                    # some problem with ugettext_lazy here
                return HttpResponseRedirect(reverse('oxybeles_detail',
                                            args=(item.uuid,)))
    return render_to_response(template_name,
                              {'form': form,},
                              context_instance=RequestContext(request))
new = login_required(new)
  • 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-05-23T09:26:50+00:00Added an answer on May 23, 2026 at 9:26 am
    for item in items
    

    where items is a queryset full of PastedItem’s:

    items = PastedItem.objects.all()
    

    and items is proffered to the template:

    {'form':form, 'items': items}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set the itemRollOver and itemRollOut event listeners on a List component, but
I have set a list of items in a combobox, but when I debug
I have set up a Django application that uses images. I think I have
I have set the FlushMode property on an NHibernate session to FlushMode.Never, but when
I have hard time with kohana sessions, i would like to store my sessions
Here you'll see I have two functions set up for fb_comment_count and my_post_gallery: Pastebin
I have this code http://pastebin.com/hCFk0FJg Server starts and listens normally, but then when I
We have set up a system where notifications get sent to a user with
I have set a canvas' background to an image of a company logo. I
I have set up transactional replication between two SQL Servers on different ends of

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.