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

  • Home
  • SEARCH
  • 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 5929969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:29:38+00:00 2026-05-22T14:29:38+00:00

I have a post(self) and I want to add some logic here to add

  • 0

I have a post(self) and I want to add some logic here to add lat and lng (these are computed from google maps) to the data store as defined in my db model. Should I add to data, or should I do it some other way such as with the original class. What is the best way to do this?

so…

class Company(db.Model):
  company_type = db.StringProperty(required=True, choices=["PLC", "LTD", "LLC", "Sole Trader", "Other"])
  company_lat = db.StringProperty(required=True)
  company_lng = db.StringProperty(required=True)

class CompanyForm(djangoforms.ModelForm):
  company_description = forms.CharField(widget=forms.Textarea(attrs={'rows':'2', 'cols':'20'}))
  company_address = forms.CharField(widget=forms.Textarea(attrs={'rows':'2', 'cols':'20'}))

  class Meta:
    model = Company
    exclude = ['company_lat,company_lng']


def post(self):
  data = CompanyForm(data=self.request.POST)
  map_url = ''  
  address = self.request.get("company_postcode")
  ...
  lat = response['results'][0]['geometry']['location']['lat']
  lng = response['results'][0]['geometry']['location']['lng']
  ...
  # How do I add these fields lat and lng to my data store?
  # Should I add them to data? if this is possible?
  # Or shall I do it some other way?

Thanks

  • 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-22T14:29:38+00:00Added an answer on May 22, 2026 at 2:29 pm

    The djangoforms help page explains how to add data to your datastore entity. Call save method with commit=False. It returns datastore entity and then you can add fields before saving it with put()

    def post(self):
      ...
      # This code is after the code above
      if data.is_valid():
        entity=data.save(commit=False)
        entity.company_lat=lat
        entity.company_lng=lng
        entity.put()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a self-joining model defined. Basically a post on a forum, and
I have a post-build event that runs some commands for a c# project. The
I have a POST request coming to one of my pages, here is a
I have a post-commit hook in svn that runs fine from the command line
I have a function that looks like this: def post_count(self): return self.thread_set.aggregate(num_posts=Count('post'))['num_posts'] I only
I want to make a POST to a PHP site from a C# WinForm
I already have a custom UIAlertView and in which i want to add UIImageView
I want to add thread and show the message in phpBB. Here is my
I have a self-hosted WordPress blog post that got popular and has over 100
i have this problem to find a particular xml node l have post this

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.