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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:05:48+00:00 2026-05-13T12:05:48+00:00

Inside a django template I’m trying to call the split function on one of

  • 0

Inside a django template I’m trying to call the split function on one of the template variables and then get the last element, so I did something like this:

{{ newsletter.NewsletterPath.split('/').-1 }}

Unfortunately, it doesn’t like the split. Some might suggest that I do the split in the view, but I’m not sure how to do that because I need to do it for all of the records. It would be much easier if I could do it in the template. Is there a way to do this?

  • 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-13T12:05:48+00:00Added an answer on May 13, 2026 at 12:05 pm

    What do you mean by “it doesn’t like the split”? How does it manifest its dislike?

    If I remember correctly, you can not pass any arbitrary arguments to methods, that are called from the django template and the identifiers, that can be used in the templates can only consist of a-z, A-Z, 0-9, underscores and dots (where dots signify lookup: dictionary->attribute->method->list-index).

    There are at least four ways to achieve what you want:

    • make the appropriately prepared data available as an attribute of your model (or whatever that is), by pre-processing it
    • make the data available as a method of your model and make sure, that the method takes no required arguments, besides self
    • populate the model instances in the view

       for newsletter in newsletters:
            setattr(newsletter, 'basepath',
                    newsletter.NewsletterPath.split('/')[-1])
      

      (or something along these lines)

    • implement a custom filter tag, that will handle the split (easier, than you might think)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 511k
  • Answers 511k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Search for "track_errors PHP". https://www.php.net/manual/en/errorfunc.configuration.php#ini.track-errors If enabled, the last error… May 16, 2026 at 5:26 pm
  • Editorial Team
    Editorial Team added an answer As seen in this article Doctrine 2 supports the identity… May 16, 2026 at 5:26 pm
  • Editorial Team
    Editorial Team added an answer Visual Studio (starting with Visual Studio .NET 2002) does not… May 16, 2026 at 5:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am trying to compare the length of a dictionary inside a django template
I am trying to use the include Django template tag, and inside it I
I know there is a post here: django template system, calling a function inside
The Django documentation states the following clearly: Not every template in contrib\admin\templates\admin may be
I have a Django template that I want to extend in multiple places. In
Using Google App Engine and Django. Whenever I have a db.ReferenceProperty() inside a model
I'm building a small web project using Django that has one model ( Image
I'm very new to django, about a week into it. I'm making a site
I'm developing a Django-based site for fun, and wondered if anyone knows how to
tl:dr How would a hosted django app correctly transform resource paths to match any

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.