Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

822
Visualizações
What became available_attrs on Django 3?

First of all, I'm new to Django, so please be nice with me :D

I'm currently adapting .py files for Django 3 because the files I have are compatible for Django 2. So, some changes have been made for the new version and in a file, it's written :

@wraps(view_func, assigned=available_attrs(view_func))

With the import :

from django.utils.decorators import available_attrs

I searched for an adaptation of available_attrs, and I quickly found that it has been removed for the new version.

And when I launch the code, I have this :

ImportError : cannot import name 'available_attrs' from 'django.utils.decorators'

So I was wondering what should I write instead of available_attrs to make it work ?

PS : Sorry for my bad english

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

available_attrs() only ever existed to help bridge between Python 2 and Python 3. This is documented in the Django 3.0 release notes:

Removed private Python 2 compatibility APIs

While Python 2 support was removed in Django 2.0, some private APIs weren’t removed from Django so that third party apps could continue using them until the Python 2 end-of-life.

Since we expect apps to drop Python 2 compatibility when adding support for Django 3.0, we’re removing these APIs at this time.

  • [...]
  • django.utils.decorators.available_attrs() - This function returns functools.WRAPPER_ASSIGNMENTS

If the @wraps() in your sample line is the standard functools.wraps() decorator, then you can just entirely remove assigned=available_attrs(...), because functools.WRAPPER_ASSIGNMENTS is the default value for assigned:

@wraps(view_func)

otherwise, just use functools.WRAPPER_ASSIGNMENTS directly.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda