English 中文(简体)
django使用过滤器时的例外情况(ImportError:无标号......)
原标题:django exception while using Filter (ImportError: No Module named ..)

When I try using in Django the "filter" Method:

dumpData.objects.filter(bid = True)

我有以下例外:

进口错误: 没有名为“贸易”的模块

 File "XXXCacheUtil.py", line 141, in loadItems print DumpData.objects.filter(bid = True)
  File "XXXsite-packagesdjangodbmodelsmanager.py", line 141, in filter
    return self.get_query_set().filter(*args, **kwargs)
  File "X:Python27libsite-packagesdjangodbmodelsquery.py", line 550, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File "X:Python27libsite-packagesdjangodbmodelsquery.py", line 568, in _filter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))
  File "X:Python27libsite-packagesdjangodbmodelssqlquery.py", line 1194, in add_q
    can_reuse=used_aliases, force_having=force_having)
  File "X:Python27libsite-packagesdjangodbmodelssqlquery.py", line 1069, in add_filter
    negate=negate, process_extras=process_extras)
  File "X:Python27libsite-packagesdjangodbmodelssqlquery.py", line 1248, in setup_joins
    field, model, direct, m2m = opts.get_field_by_name(name)
  File "X:Python27libsite-packagesdjangodbmodelsoptions.py", line 307, in get_field_by_name
    cache = self.init_name_map()
  File "X:Python27libsite-packagesdjangodbmodelsoptions.py", line 337, in init_name_map
    for f, model in self.get_all_related_m2m_objects_with_model():
  File "X:Python27libsite-packagesdjangodbmodelsoptions.py", line 414, in get_all_related_m2m_objects_with_model
    cache = self._fill_related_many_to_many_cache()
  File "X:Python27libsite-packagesdjangodbmodelsoptions.py", line 428, in _fill_related_many_to_many_cache
    for klass in get_models():
  File "X:Python27libsite-packagesdjangodbmodelsloading.py", line 167, in get_models
    self._populate()
  File "X:Python27libsite-packagesdjangodbmodelsloading.py", line 61, in _populate
    self.load_app(app_name, True)
  File "X:Python27libsite-packagesdjangodbmodelsloading.py", line 76, in load_app
    app_module = import_module(app_name)
  File "X:Python27libsite-packagesdjangoutilsimportlib.py", line 35, in import_module
    __import__(name)
进口错误: 没有名为“贸易”的模块

贸易是我的达詹戈应用治理环境。 under

INSTALLED_APPS = (    
(...),
 Trades )

DumpData的定义是:

class DumpData(models.Model):
    orderId = models.BigIntegerField()
    typeId = models.BigIntegerField()
    price = models.DecimalField(decimal_places=2,max_digits=20)
    bid = models.BooleanField()
    issued = models.DateField()
    dateDumped = models.DateTimeField()

我只想

dumbData.objects.all()

所有这些工作都很重,因此可能不是一个服务器/银问题。 (因此我可以无一例外地拯救日期)。

最佳回答

Ok i solved my Problem. The reason because it didnt worked was in the Project Strukture, i had:

src
    PackageNr1
       Main.py  <-- File where Django was called.
    PackageNr2  <-- Package for the Django Files
       	rades   <-- Django App
          models.py , 
          views ...usw 
       settings.py  <-- Django Settings File
       manage.py 

itch这种 Str子可以称作“ave”或“bject(bject)”等物品,并做罚款。 但是,用多数称呼的是它所干的。 因此,我把我的Django一揽子计划移入了主波克奇,现在正在运行。 新的“强硬”就是这样:

 src
    PackageNr1
        	rades    <-- The django app
            models.py
            views ....
        Main.py
        settings.py <--Django Files
        manage.py

这对我来说是一件事。

问题回答

I didn t found any documentation about it, but I would suggest to use lowercase names for apps. Also, try :

dumpData.objects.filter(bid = True).all()




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签