Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

349
Views
How to save wallet address to user model in Django?

I have run into a bit of a hiccup here.

I have a script which gets the user's Metamask wallet address which works fine. The problem arises when I need to save that wallet address to the user model in this field:

ethereum_address = models.CharField(max_length=42, blank=True, null=True)

I have a Javascript that fetches the wallet when the Connect button is pressed:

function connect() {
        ethereum
            .request({ method: 'eth_requestAccounts' })
            .then((account)=> saveAccount(account))
            .catch((error) => {
            if (error.code === 4001) {
                // EIP-1193 userRejectedRequest error
                console.log('Please connect to MetaMask.');
            } else {
                console.error(error);
            }
            });
        }
        
        function saveAccount(account) {
            console.log(account);
            $.ajax({
                url: '/connect-metamask/',
                type: 'POST',
                data: {
                    'account': account,
                    'csrfmiddlewaretoken': '{{ csrf_token }}'
                },
            });
        }

In the views.py I have this when I have a POST request:

def connect_metamask(request):
user = request.user

if request.method == "POST":
    user.ethereum_address = request.POST.get("account")
    user.save()
.........

But when I look at the database the ethereum_address is Null .

How do I make this work?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!