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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:36:03+00:00 2026-05-17T19:36:03+00:00

I’m very new to Python and Django so maybe someone can point me in

  • 0

I’m very new to Python and Django so maybe someone can point me in the right direction.

I have the following url.py line

      url(r'^$', direct_to_template,
                  {'template':'index.html',
                  'extra_context':{'featured_actors': lambda: User.objects
                                    .annotate(avatars_nb=Count('avatar'))
                                    .filter(actor_profile__is_featured=True, avatars_nb__gt=0)
                                    .order_by('?')[:4]},
                 }, name='index'),

All this was working perfectly fine for a long time but for no reason that I can see all of a sudden I’m getting this template error.

 TemplateSyntaxError at /
 Caught an exception while rendering: (36, 'File name too long')

On line 70

 66   {% if featured_actors|length %}
 67       <div id="featured"> 
 68         <h2>Featured Actors: </h2>
 69         <ul>
 70             {% for actor in featured_actors %}
 71             <li> 
 72                 <a href="{% url public_profile actor.username %}">
 73                     <img src="{% avatar_itself_url actor.avatar_set.all.0 200 %}" alt="{{ actor.profile.firstname }} {{ actor.profile.lastname }}" style="max-width:140px" height="200"/> 
 74                 </a>
 75             </li>
 76             {% endfor %}

What is the best way to debug this?

UPDATE

 126     def avatar_url(self, size):
 127         return self.avatar.storage.url(self.avatar_name(size))

I think I found a bit of the problem, one of the user profiles is also giving the same error. So I think it must be a avatar/image path for him that is too long. I’m trying to narrow it down…

  • 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-17T19:36:04+00:00Added an answer on May 17, 2026 at 7:36 pm

    It’s possible that the image path {% avatar_itself_url actor.avatar_set.all.0 200 %} is too long. Can you delete the line with <img ... and see if the template renders?

    If the above renders, from the python manage.py shell, can you verify the length of your image path? Is the length greater than 255 chars?

    ANSWER TO COMMENT

    Your image path is too long, by that I mean:

    <img src="/this/is/a/very/long/path/which/exceeds/255/characters/something.png" />
    

    The above is not 255 chars long but you get the idea. The above src path might be very long. Try to find out what that path is and calculate its length. What does the implementation of avatar_itself_url look like? How about the unicode of Avatar? What does it return? Do you have an Avatar with a very long name?

    Replicating the error msg

    Here’s how you can replicate the error msg from python. Run the following in a python script:

    long_filename = 'a' * 256
    fp = open(long_filename, 'w')
    fp.close()
    

    The above should return the msg: IOError: [Errno 36] File name too long:.

    Displaying the image path

    Can you replace the img tag from the html by just its content: {% avatar_itself_url actor.avatar_set.all.0 200 %}? Instead of seeing the image, you should see the path of the image. Eyeballing the one longer than 256 chars shouldn’t be an issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I'm making a simple page using Google Maps API 3. My first. One marker

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.