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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:26:37+00:00 2026-05-26T17:26:37+00:00

I’m currently working with django-nani to enable translated models on a project. Many of

  • 0

I’m currently working with django-nani to enable translated models on a project.

Many of these models require slugs for URL generation. My client is non-technical, and asking them to enter slugs would be unreasonable in terms of both expectations and support costs. Translation is a new requirement, so I am working to adjust old models for translation.

When saving a model, nani registers a post_save signal for the purpose of saving translations. This is fine, except that now if I attempt to register a post_save signal to use said translations to generate slugs, I’m out of luck; either my signal is running after or concurrently and no translation object exists.

The offending model code:

from django.db import models
from django.db.models import signals
from django.template.defaultfilters import slugify

from tinymce.models import HTMLField
from nani.models import TranslatableModel, TranslatedFields

class Product(TranslatableModel):
    translations = TranslatedFields(
        name = models.CharField(max_length=100),
        title = models.CharField(max_length=100),
        description = HTMLField(),
    )

    slug = models.SlugField(max_length=100, blank=True, null=True, editable=False),

    # Various unrelated fields...

    def __unicode__(self):
        return self.translations.get(language_code='en').name

def product_post_save(sender, instance, created, **kwargs):
    new_slug = slugify(instance.translations.get(language_code='en').name)

    if instance.slug != new_slug:
        instance.slug = new_slug
        instance.save()
signals.post_save.connect(product_post_save, Product)

This causes a ProductTranslation matching query does not exist DoesNotExist exception on the first line of product_post_save.

I’ve briefly tried refactoring nani to override the save method instead of using post_save, but that seems to be a nontrivial task (at least for someone who knows little about its internals, like me).

I’ve looked at some third-party autoslug fields, but I can’t imagine any would work with this particular situation and translation library.

My questions would be…

  • Is there a way to make sure one post_save is lined up after any
    others that are defined?
  • Barring that, can anyone else suggest a
    different/better solution to this issue?

Edit: Found out signal priority has been suggested and shot down by the Django core devs.

  • 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-26T17:26:37+00:00Added an answer on May 26, 2026 at 5:26 pm

    Since the Django team has elected not to support ordering for methods registered on hooks and nani implements translation save using them, I found no clear way to make sure my code ran after nani’s post_save methods.

    In the end I forked nani and added a custom signal that fires when its post_save finishes. It’s not ideal (in my opinion), but it works.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string

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.