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