GVKun编程网logo

刚启动时,在Django应用上获取“ str”没有属性“ _default_manager”(django启动时执行某个方法)

10

如果您想了解刚启动时,在Django应用上获取“str”没有属性“_default_manager”和django启动时执行某个方法的知识,那么本篇文章将是您的不二之选。我们将深入剖析刚启动时,在Dj

如果您想了解刚启动时,在Django应用上获取“ str”没有属性“ _default_manager”django启动时执行某个方法的知识,那么本篇文章将是您的不二之选。我们将深入剖析刚启动时,在Django应用上获取“ str”没有属性“ _default_manager”的各个方面,并为您解答django启动时执行某个方法的疑在这篇文章中,我们将为您介绍刚启动时,在Django应用上获取“ str”没有属性“ _default_manager”的相关知识,同时也会详细的解释django启动时执行某个方法的运用方法,并给出实际的案例分析,希望能帮助到您!

本文目录一览:

刚启动时,在Django应用上获取“ str”没有属性“ _default_manager”(django启动时执行某个方法)

刚启动时,在Django应用上获取“ str”没有属性“ _default_manager”(django启动时执行某个方法)

在重新启动Apache以获取新的Django更改之后,大约30秒到一分钟后,我收到以下错误:

ViewDoesNotExist: Tried home_page in module project.app.views. Error was:''str'' object has no attribute ''_default_manager''

错误会很快消失,但这很奇怪。任何想法如何调试此或可能是什么原因?

答案1

小编典典

我认为是这个错误:

http://code.djangoproject.com/ticket/10405#comment:11

考虑到Google搜索显示的其他内容似乎不太合适,而且一段时间后您的问题就消失了-根据这张票证,这是由于模型字符串的延迟加载所致。

该注释建议在管理员自动发现功能之​​前添加以下内容。

from django.db.models.loading import cache as model_cacheif not model_cache.loaded:    model_cache.get_models()

'django.db.models' 没有属性 'StdImageField'

'django.db.models' 没有属性 'StdImageField'

StdImageField 不是来自 django,而是来自第三方库,即 stdimage。而且,您已经像这样导入了它:

from stdimage.models import StdImageField

因此,只需删除模型

 class CustomUser(AbstractUser):
    picture = StdImageField(null=True,blank=True,upload_to="images",validators=[validate_file_size],size=(256,256))
,

StdImageField 属于 stdimage.models 模块,因此您将它与 picture = StdImageFIeld(…) 一起使用,而不是与 models. 前缀一起使用:

from stdimage.models import StdImageField

class CustomUser(AbstractUser):
    picture = StdImageField(
        null=True,upload_to=''images'',256)
    )
,

StdImageField 不是 Django 的 models API 的一部分,因此调用 picture = models.StdImageField 将不起作用。您已经导入了 StdImageField,因此只需将模型字段更改为

picture = StdImageField(null=True,256))

AttributeError: 模块“sklearn.cluster”没有属性“k_means_”

AttributeError: 模块“sklearn.cluster”没有属性“k_means_”

如何解决AttributeError: 模块“sklearn.cluster”没有属性“k_means_”?

我有一个奇怪的错误:

from sklearn.cluster import KMeans

from nose.tools import assert_equal,assert_is_instance,assert_true,assert_is_not
from numpy.testing import assert_array_equal,assert_array_almost_equal,assert_almost_equal

我的数据存储为这样的数组,只是更大:

array([[-2.65602062e+00,-1.38241098e+00,-6.04632297e-01,9.37261785e-01,-8.33086491e-01,-1.61945768e-01,1.54809554e-01,-2.62093027e-02,-2.78241107e-01,-2.42455888e-01]]

我定义了一个函数

def cluster(array,random_state,n_clusters=10):

    model = KMeans(n_clusters = n_clusters,init = ''k-means++'',random_state = 0).fit(array)
    clusters = model.fit_predict(array)

    return model,clusters

但是当我进行单元测试时,这给了我一个错误:

AttributeError                            Traceback (most recent call last)
<ipython-input-47-d502eebc4ee1> in <module>
  1 k_means_t,cluster_t = cluster(reduced,random_state=check_random_state(1),n_clusters=5)
  2 
----> 3 assert_is_instance(k_means_t,sklearn.cluster.k_means_.KMeans)
      4 assert_is_instance(cluster_t,np.ndarray)
      5 assert_equal(k_means_t.n_init,10)


AttributeError: module ''sklearn.cluster'' has no attribute ''k_means_''

我的代码以前工作过,不知道后来发生了什么。

我从 kmeans_ 中删除了 assert_is_instance(k_means_t,sklearn.cluster.k_means_.KMeans),错误消失了,但我认为这不是正确的解决方案。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

AttributeError:模块“ attr”没有属性“ s”

AttributeError:模块“ attr”没有属性“ s”

import attr
>>> @attr.s
… class SmartClass(object):
… a=attr.ib()
… b=attr.ib()

Traceback (most recent call last):
File ““,line 1,in
AttributeError: module ‘attr’ has no attribute ‘s’
>>>

我不明白为什么它不起作用。我已经使用pip安装了此模块,并且安装正确,但是在实现部分仍然显示错误。

AttributeError:模块“ tensorflow”没有属性“ get_default_graph”

AttributeError:模块“ tensorflow”没有属性“ get_default_graph”

我正在执行一些与图像字幕相关的任务,并且已经像这样加载了初始模型的权重

model = InceptionV3(weights=''imagenet'')

但是我得到这样的错误:

AttributeError: module ''tensorflow'' has no attribute ''get_default_graph''

我该怎么办?请帮忙。这是上面代码的完整输出。

1。--------------------------------------------------
-------------------------()中的AttributeError
Traceback(最近一次调用为最新)1#加载初始v3模型----> 2模型= InceptionV3(include_top =
True,weights =’imagenet’)3#InceptionV3(weights =’imagenet’)

~/anaconda3/lib/python3.6/site-packages/keras/applications/__init__.pyin wrapper(*args, **kwargs)     26             kwargs[''models''] = models     27             kwargs[''utils''] = utils---> 28         return base_fun(*args, **kwargs)     29      30     return wrapper~/anaconda3/lib/python3.6/site-packages/keras/applications/inception_v3.pyin InceptionV3(*args, **kwargs)      9 @keras_modules_injection     10 def InceptionV3(*args, **kwargs):---> 11     return inception_v3.InceptionV3(*args, **kwargs)     12      13~/anaconda3/lib/python3.6/site-packages/keras_applications/inception_v3.pyin InceptionV3(include_top, weights, input_tensor, input_shape,pooling, classes, **kwargs)    155     156     if input_tensor is None:--> 157         img_input = layers.Input(shape=input_shape)    158     else:    159         if not backend.is_keras_tensor(input_tensor):~/anaconda3/lib/python3.6/site-packages/keras/engine/input_layer.pyin Input(shape, batch_shape, name, dtype, sparse, tensor)    176                              name=name, dtype=dtype,    177                              sparse=sparse,--> 178                              input_tensor=tensor)    179     # Return tensor including _keras_shape and _keras_history.    180     # Note that in this case train_output and test_output are the same pointer.~/anaconda3/lib/python3.6/site-packages/keras/legacy/interfaces.pyin wrapper(*args, **kwargs)     89                 warnings.warn(''Update your `'' + object_name + ''` call to the '' +     90                               ''Keras 2 API: '' + signature, stacklevel=2)---> 91             return func(*args, **kwargs)     92         wrapper._original_function = func     93         return wrapper~/anaconda3/lib/python3.6/site-packages/keras/engine/input_layer.pyin __init__(self, input_shape, batch_size, batch_input_shape, dtype,input_tensor, sparse, name)     37         if not name:     38             prefix = ''input''---> 39             name = prefix + ''_'' + str(K.get_uid(prefix))     40         super(InputLayer, self).__init__(dtype=dtype, name=name)     41~/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.pyin get_uid(prefix)     72     """     73     global _GRAPH_UID_DICTS---> 74     graph = tf.get_default_graph()     75     if graph not in _GRAPH_UID_DICTS:     76         _GRAPH_UID_DICTS[graph] = defaultdict(int)AttributeError: module ''tensorflow'' has no attribute''get_default_graph''

答案1

小编典典

更改

Import keras.<something>.<something>

Import tensorflow.keras.<something>.<something>

其中“某物”是指您要导入的模块。它为我工作。

今天关于刚启动时,在Django应用上获取“ str”没有属性“ _default_manager”django启动时执行某个方法的分享就到这里,希望大家有所收获,若想了解更多关于'django.db.models' 没有属性 'StdImageField'、AttributeError: 模块“sklearn.cluster”没有属性“k_means_”、AttributeError:模块“ attr”没有属性“ s”、AttributeError:模块“ tensorflow”没有属性“ get_default_graph”等相关知识,可以在本站进行查询。

本文标签: