from flask import current_app
from .. import db, login_manager

class Bookmarks(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    listing_id = db.Column(db.Integer, unique=True)
    merchant_id = db.Column(db.Integer, db.ForeignKey('user.id')) #also needs to be added to Hunter's Vendors model

    def __init__(self, listing_id, merchant_id):
        self.listing_id = listing_id
        self.merchant_id = merchant_id

    def __repr__(self):
        return "<User: {} Bookmarked Listing: {}".format(self.merchant_id, self.listing_id)

from flask import current_app
from .. import db, login_manager

class Bookmarks(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    listing_id = db.Column(db.Integer, unique=True)
    merchant_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    merchant = db.relationship('User', backref=db.backref('bookmarks', lazy='dynamic'))

    def __init__(self, listing_id, merchant):
        self.listing_id = listing_id
        self.merchant = merchant

    def __repr__(self):
        return "<User: {} Bookmarked Listing: {}".format(self.merchant_id, self.listing_id)

Set up the relationship between bookmark and merchant
Set up the relationship between bookmark and merchant

  from flask import current_app
  from .. import db, login_manager
  
  class Bookmarks(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      listing_id = db.Column(db.Integer, unique=True)
-     merchant_id = db.Column(db.Integer, db.ForeignKey('user.id')) #also needs to be added to Hunter's Vendors model
+     merchant_id = db.Column(db.Integer, db.ForeignKey('user.id'))
+     merchant = db.relationship('User', backref=db.backref('bookmarks', lazy='dynamic'))
  
-     def __init__(self, listing_id, merchant_id):
+     def __init__(self, listing_id, merchant):
          self.listing_id = listing_id
-         self.merchant_id = merchant_id
+         self.merchant = merchant
  
      def __repr__(self):
          return "<User: {} Bookmarked Listing: {}".format(self.merchant_id, self.listing_id)
  
Set up the relationship between bookmark and merchant
## Code Before:
from flask import current_app
from .. import db, login_manager

class Bookmarks(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    listing_id = db.Column(db.Integer, unique=True)
    merchant_id = db.Column(db.Integer, db.ForeignKey('user.id')) #also needs to be added to Hunter's Vendors model

    def __init__(self, listing_id, merchant_id):
        self.listing_id = listing_id
        self.merchant_id = merchant_id

    def __repr__(self):
        return "<User: {} Bookmarked Listing: {}".format(self.merchant_id, self.listing_id)

## Instruction:
Set up the relationship between bookmark and merchant
## Code After:
from flask import current_app
from .. import db, login_manager

class Bookmarks(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    listing_id = db.Column(db.Integer, unique=True)
    merchant_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    merchant = db.relationship('User', backref=db.backref('bookmarks', lazy='dynamic'))

    def __init__(self, listing_id, merchant):
        self.listing_id = listing_id
        self.merchant = merchant

    def __repr__(self):
        return "<User: {} Bookmarked Listing: {}".format(self.merchant_id, self.listing_id)
