[英]Django-Admin Panel Wont Show Records that are inserted throw phpmyadmin?
I have a django admin panel , and this django admin panel is connected to mysql and wamp . 我有一个django管理面板,这个django管理面板连接到mysql和wamp。
My problem is when i insert some records in database using phpmyadmin , django-admin panel wont show records , and just show numbers of them . 我的问题是,当我使用phpmyadmin在数据库中插入一些记录时,django-admin面板将不会显示记录,而只会显示它们的编号。
What this problem is for ? 这个问题是为了什么?
Here is My Model in Django : 这是Django中的My Model:
class Orders(models.Model):
objects = jmodels.jManager()
product = models.ForeignKey('PartoProducts', models.DO_NOTHING)
user_phone = models.ForeignKey('PartoUsers', models.DO_NOTHING, db_column='user_phone')
order_date = jmodels.jDateField()
status = models.CharField(max_length=11)
price = models.CharField(max_length=11)
count = models.IntegerField()
def __unicode__(self):
return self.product.title
class Meta:
managed = False
db_table = 'orders'
verbose_name_plural = "Orders"
def __str__(self):
return '%s------- (%s)' % (self.user_phone,self.status)
and This is My Admin.py for this model : 这是此模型的My Admin.py:
class OrdersResource(resources.ModelResource):
class Meta :
model = Orders
fields = ('product__title','product__realprice','user_phone__name','user_phone__family','user_phone__city','user_phone__address','user_phone__nationalcode')
@admin.register(Orders)
class OrdersAdmin(ImportExportModelAdmin):
list_display = ('product','user_phone','price')
list_filter = ('product','user_phone','price')
search_fields = ('product','user_phone','price')
resource_class = OrdersResource
Why django wont show any records that are inserted throw phpmyadmin ? 为什么django不会显示插入的任何记录引发phpmyadmin?
I searched alot but not found anything . 我搜寻了很多,但没有找到任何东西。
Any Suggestion will be helpfull . 任何建议都会有所帮助。
Thanks to this great community . 感谢这个伟大的社区。
Found Solution !!! 找到解决方案!
I Just need to change my model field : 我只需要更改我的模型字段:
From This : 由此 :
user_phone = models.ForeignKey('PartoUsers', models.DO_NOTHING, db_column='user_phone')
To This : 为此:
user_phone = models.ForeignKey('PartoUsers',models.DO_NOTHING,db_column='user_phone',to_field='phone')
And Yes , This is solved my problem . 是的,这解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.