Beacon_info應用程式模式 如下所示的代碼是一個havinng領域我想要在另一個應用中作爲外鍵使用,如下所示。在我的項目,我有兩個應用程序,beacon_info和報價,我需要使用存儲爲外鍵從我beacon_info應用提供
from django.db import models
from django.utils.encoding import smart_unicode
from django.utils import timezone
from datetime import datetime
class store(models.Model):
store_name = models.CharField('Store Name',max_length=100)
store_id = models.CharField('Store_ID', max_length=20, unique=True)
store_email = models.EmailField('Email_ID', max_length=254)
address = models.CharField('Address', max_length=250)
country = models.CharField('Country', max_length=50)
state = models.CharField('State', max_length=50)
city = models.CharField('City',max_length=50)
pincode = models.CharField('Pincode', max_length=15)
contact_no = models.CharField('Contact', max_length=15)
createdat = models.DateTimeField(auto_now=True)
def __unicode__(self):
return smart_unicode(self.id)
信息的應用程序的模型
from django.db import models
from django.utils.encoding import smart_unicode
from beacon_info.models import *
from django.utils import timezone
from datetime import datetime
class offer(models.Model):
offer_code = models.CharField(max_length=50)
store_code = models.ForeignKey('beacon_info.models.store')
entry_exit_type = models.CharField(max_length=50, null=True)
offername = models.CharField(max_length=100, null=True)
description = models.TextField()
membership = models.CharField(max_length=5, default=1)
start_time = models.DateTimeField()
end_time = models.DateTimeField()
createdat =models.DateTimeField(auto_now_add=True)
def __unicode__(self):
return smart_unicode(self.offername)
你真的不問問題 – Ngenator