Karthika_g 0 Newbie Poster


Please let me know how should we get the id of an entity and put it in the another entity. I have two entity User and Track.

I tried the below code I couldn't make.
Please help!

class Review(webapp2.RequestHandler):

        template = JE.get_template('templates/Review.html')

    def post(self):
        n = self.request.get('user_name')
        t = self.request.get('track_name')
        a = self.request.get('artist_name')
        c = self.request.get('comment')
        r = int(self.request.get('rating'))
        q = db.Gqlquery("SELECT track_name from Track")
        for msg in q:
            if t!=msg:
                trk = models.Track(track_name = t, artist_name = a)
                self.response.out.write("<h3>Already track exists</h3>")

        #query = db.GqlQuery("SELECT __key__ FROM Track WHERE track_name = :1, t)
        #for m in query:
            #self.response.write('%s' %m)
        usr =  models.User(user_name = n, content = c, rating = r)

        self.response.out.write("<h3>Thank you for posting</h3>")

My model classes are:

class User(db.Model):
    user_name = db.StringProperty(multiline=True)
    track_id = db.StringProperty(multiline=True)
    content = db.StringProperty(multiline=True)
    rating = db.IntegerProperty()
    time = db.DateTimeProperty(auto_now_add=True)

class Track(db.Model):
    track_name = db.StringProperty(multiline=True)
    artist_name = db.StringProperty(multiline=True)