question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Use more than one alias

See original GitHub issue

Question

For bugs/questions:

  • OS: MAC
  • Python version 3.6
  • Pydantic version 0.14

Is it possible to use more than 1 alias? I have data that can sometime have an attribute like_this and sometimes likeThis and I want to reuse the model

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

19reactions
samuelcolvincommented, Jul 12, 2022

https://pydantic-docs.helpmanual.io/blog/pydantic-v2/#more-powerful-aliases

It will be possible in V2. It’s already implemented in pydantic-core.

9reactions
dlopuchcommented, Jun 8, 2022

Ran across this for use-case of renaming an API field – had to support both old field name and new field name going to same place in order to maintain API stability.

For the web archives, a slight twist on @jmkd3v’s solution for when you have many fields on your model and don’t want to type everything out:

class PartialUser(BaseUser):
    def __init__(self, **data):
        super().__init__(
            id=data.pop("old_id", None) or data.pop("id", None),
            **data,
        )

    id: int
    name: str
    display_name: str
Read more comments on GitHub >

github_iconTop Results From Across the Web

Question: Use more than one alias · Issue #324 · pydantic ...
OS: MAC; Python version 3.6; Pydantic version 0.14. Is it possible to use more than 1 alias? I have data that can sometime...
Read more >
Using multiple alias in a single command - Unix Stack Exchange
I'm facing problem in using multiple alias in a single line on Mac bash Terminal . I have setup below alias in my...
Read more >
how can add more than one alias for every mailbox
You can have only one alias ( mailNickname) per mailbox. You can have multple proxy SMTP addresses ( the EmailAddresses switch in set-mailbox) ......
Read more >
Can we add multiple aliases on one column? - Stack Overflow
No, you cannot add multiple aliases to a single column in your query. Query syntax of SQL allows for zero or one alias;...
Read more >
Use Question Aliases - Alchemer Help
Question Aliases, available on the Logic tab of each of your questions, allow you create a shortname for questions in your survey.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found