我刚刚更新到Django v1.8,并在更新项目之前测试了本地设置,并且发出了弃用警告,这是我从未见过的,对我也没有任何意义。我可能只是忽略了某些内容或误解了文档。
/Users/neilhickman/Sites/guild/ankylosguild/apps/raiding/models.py:6: RemovedInDjango19Warning: Model class ankylosguild.apps.raiding.models.Difficulty doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class Difficulty(models.Model):
/Users/neilhickman/Sites/guild/ankylosguild/apps/raiding/models.py:21: RemovedInDjango19Warning: Model class ankylosguild.apps.raiding.models.Zone doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class Zone(models.Model):
/Users/neilhickman/Sites/guild/ankylosguild/apps/raiding/models.py:49: RemovedInDjango19Warning: Model class ankylosguild.apps.raiding.models.Boss doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class Boss(models.Model):
/Users/neilhickman/Sites/guild/ankylosguild/apps/raiding/models.py:79: RemovedInDjango19Warning: Model class ankylosguild.apps.raiding.models.Item doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class Item(models.Model):
/Users/neilhickman/Sites/guild/ankylosguild/apps/forum/models.py:14: RemovedInDjango19Warning: Model class ankylosguild.apps.forum.models.Category doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class Category(models.Model):
/Users/neilhickman/Sites/guild/ankylosguild/apps/forum/models.py:36: RemovedInDjango19Warning: Model class ankylosguild.apps.forum.models.Comment doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class Comment(ScoreMixin, ProfileMixin, models.Model):
/Users/neilhickman/Sites/guild/ankylosguild/apps/forum/models.py:64: RemovedInDjango19Warning: Model class ankylosguild.apps.forum.models.Forum doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class Forum(models.Model):
/Users/neilhickman/Sites/guild/ankylosguild/apps/forum/models.py:88: RemovedInDjango19Warning: Model class ankylosguild.apps.forum.models.Post doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class Post(ScoreMixin, ProfileMixin, models.Model):
/Users/neilhickman/Sites/guild/ankylosguild/apps/forum/models.py:119: RemovedInDjango19Warning: Model class ankylosguild.apps.forum.models.CommentPoint doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class CommentPoint(models.Model):
/Users/neilhickman/Sites/guild/ankylosguild/apps/forum/models.py:127: RemovedInDjango19Warning: Model class ankylosguild.apps.forum.models.TopicPoint doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class TopicPoint(models.Model):
/Users/neilhickman/Sites/guild/ankylosguild/apps/auctionhouse/models.py:10: RemovedInDjango19Warning: Model class ankylosguild.apps.auctionhouse.models.Auction doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class Auction(models.Model):
/Users/neilhickman/Sites/guild/ankylosguild/apps/auctionhouse/models.py:83: RemovedInDjango19Warning: Model class ankylosguild.apps.auctionhouse.models.Bid doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class Bid(models.Model):
现在,这对我提出了3个问题。
如警告中所述,将发生以下两种情况:
INSTALLED_APPS
设置中引用了应用程序,因此很可能在应用程序初始化之前就使用了模型。通常,当你有from .models import SomeModels
一个apps.py早期信号时(例如post_migrate
),就会发生这种情况。建议不要使用AppConfig.get_model()代替这里的经典方法。检查你的apps.py文件是否有任何模型导入,并使用此api替换它们。
例如代替:
# apps.py
from django.apps import AppConfig
from .models import MyModel
def do_stuff(sender, **kwargs):
MyModel.objects.get() # etc...
class MyAppConfig(AppConfig):
name = 'src.my_app_label'
def ready(self):
post_migrate.connect(do_stuff, sender=self)
做这个 :
# apps.py
from django.apps import AppConfig
def do_stuff(sender, **kwargs):
mymodel = sender.get_model('MyModel')
mymodel.objects.get() # etc...
class MyAppConfig(AppConfig):
name = 'src.my_app_label'
def ready(self):
post_migrate.connect(do_stuff, sender=self)
请注意,此强制性是在Bug #21719中引入的。
问题内容: 我有一个React组件,我想在单击时切换一个CSS类。 所以我有这个: 这个问题是ESLint不断告诉我“ this.refs”已贬值。 我该怎么办?我如何解决它而不使用折旧的代码? 问题答案: 您要引用的Lint规则称为 no-string-refs, 并通过以下方式警告您: 之所以收到此警告,是因为已实现了不赞成使用的使用方式(通过使用字符串)。根据您的React版本,您可以执行以
我刚刚更新到rails 4.0.2,我收到了这个警告: [已弃用]我18n.enforce_available_locales将来会默认为true。如果您真的想跳过区域设置的验证,您可以设置I18n.enforce_available_locales=false以避免此消息。 将其设置为false是否存在任何安全问题?
我正在使用scikit-learn 0.14的GridSearchCV,但总是得到以下警告: /Library/Frameworks/epd 64 . framework/Versions/7.2/lib/python 2.7/site-packages/sk learn/grid _ search . py:706:deprecation warning:忽略GridSearchCV的附加参数!
我的项目正在迁移到视图绑定,但与此同时,在查看构建日志时,此警告会分散注意力 警告:“kotlin android extensions”Gradle插件已弃用。请使用本迁移指南(https://goo.gle/kotlin-android-extensions-deprecation)开始使用视图绑定的步骤(https://developer.android.com/topic/librarie
问题内容: 我正在尝试使用自定义方法在猫鼬的顶部开发一个类,因此我用自己的类扩展了猫鼬,但是当我调用创建一个新的car方法时,它可以工作,但是它的剥离和错误,在这里让你看看我要做什么。 我收到此警告 我做完之后 driver是Driver类的实例 关于我在做什么错的任何想法? 问题答案: 阅读文档后,这对我来说是解决问题的方法:http : //mongoosejs.com/docs/promis
问题内容: 通过使用我查询文档时,我开始在控制台中收到以下警告 DeprecationWarning:不建议使用collection.find选项[fields],在更高版本中将其删除 为什么会看到此错误以及如何解决?(可能的替代方法) 编辑:添加查询 猫鼬版本5.2.9 问题答案: 更新: 5.2.10已发布,可在此处下载。 使用有mongooose调用上MongoDB的本地驱动程序的方法。 有