小编Ily*_*bik的帖子

bootstrap.min.js:6 Uncaught Error:Bootstrap下拉列表需要Popper.js

突然,当我尝试打开下拉菜单时,我开始出错:

 bootstrap.min.js:6 Uncaught Error: Bootstrap dropdown require Popper.js (https://popper.js.org)
        at bootstrap.min.js:6
        at bootstrap.min.js:6
        at bootstrap.min.js:6
Run Code Online (Sandbox Code Playgroud)

我正在使用标准的bootstrap文件

<script src="https://getbootstrap.com/dist/js/bootstrap.min.js">

引导程序有什么变化我必须要小心吗?

订单我正在加载文件如下

<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script src="{{ STATIC_URL }}/static/jquery/jquery-1.9.1.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="{{ STATIC_URL }}/static/jquery/jquery-ui.js"></script>




<script src="https://getbootstrap.com/dist/js/bootstrap.min.js"></script>
<!-- Just to make our placeholder images work. Don't actually copy the next line! -->
<script src="https://getbootstrap.com/assets/js/vendor/holder.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="https://getbootstrap.com/assets/js/ie10-viewport-bug-workaround.js"></script>
Run Code Online (Sandbox Code Playgroud)

javascript twitter-bootstrap

37
推荐指数
7
解决办法
8万
查看次数

未捕获的TypeError:$(...).datepicker不是函数(匿名函数)

我发现堆栈溢出的答案很少,但仍然无法解决我的问题.我在Django上运行,但我不认为它与此错误有关.

我尝试使我的日期选择器java脚本工作,但我收到错误

1:27 Uncaught TypeError:$(...).datepicker不是函数(匿名函数)@ 1:27fire @jquery-1.9.1.js:1037self.fireWith @jquery-1.9.1.js:1148jQuery.extend .ready @jquery-1.9.1.js:433completed @jquery-1.9.1.js:103 jquery-2.1.0.min.js:4 XHR完成加载:POST" https:// localhost:26143/skypectoc/v1/pnr/parse ".l.cors.a.crossDomain.send @jquery-2.1.0.min.js:4o.extend.ajax @jquery-2.1.0.min.js:4PNR.findNumbers @ pnr.js: 43parseContent @ contentscript.js:385processMutatedElements @ contentscript.js:322

这是我的所有脚本:

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />


<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>

<script type="text/javascript">
$(document).ready(function() {
    $('.dateinput').datepicker({ format: "yyyy/mm/dd" });
}); 
</script>

      <!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="http://getbootstrap.com/dist/js/bootstrap.min.js"></script>
<!-- Just to make our placeholder …
Run Code Online (Sandbox Code Playgroud)

javascript django jquery datepicker

18
推荐指数
1
解决办法
12万
查看次数

Meta.fields包含一个未在此FilterSet上定义的字段:****

我正在使用Django Filters包.

我在视图中以下列方式定义了我的过滤器

class UnitFilter(django_filters.FilterSet):
    class Meta:
        model = Unit
        fields = [
            'floor', 'number', 'building','lease','leaseterm', 
            'lease__is_active','lease__is_terminated','lease__is_renewed',]
Run Code Online (Sandbox Code Playgroud)

我过滤的我的单位模型如下

class Unit(CommonInfo):
    version = IntegerVersionField( )
    number = models.CharField(max_length=30,null=True, blank=True)
    max_occupants = models.PositiveSmallIntegerField()
    floor = models.PositiveSmallIntegerField()
    rooms = models.PositiveSmallIntegerField()
    is_disabled_access = models.BooleanField(default=False)
    balcony_quantity = models.PositiveSmallIntegerField()
    building = models.ForeignKey(Building)
    recomended_price = models.DecimalField(max_digits=7, decimal_places=2)
    _lease = None
    _leaseterm = None
    #check = models.ManyToManyField(UnitCheck, through='UnitChecklist')

    def _get_total(self):

        from conditions.models import LeaseTerm
        from lease.models import Lease

        lease_dict = Lease.objects.filter(unit_id=self.id, is_active = True , is_terminated = False).aggregate(Max('id')) …
Run Code Online (Sandbox Code Playgroud)

django django-models django-filter

7
推荐指数
1
解决办法
5803
查看次数

django-autocomplete-light在表单中显示空下拉列表

我正在尝试使用django-autocomplete-light从本教程开始 https://github.com/yourlabs/django-autocomplete-light/blob/master/docs/tutorial.rst

我用pip安装了它并将其添加到我的设置文件中

INSTALLED_APPS = (
    'dal',
    'dal_select2',
Run Code Online (Sandbox Code Playgroud)

为了我的房客价值

我的租户模型是

class Tenant(CommonInfo):
    version = IntegerVersionField( )

    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=40)
    def __unicode__(self):
        return u'%s %s %s ' % ("#", self.id,"first_name", self.first_name, "last_name")
Run Code Online (Sandbox Code Playgroud)

在我的自动填充视图中:

from django.shortcuts import render
from dal import autocomplete
from client.models import Tenant


    class TenantAutocomplete(autocomplete.Select2QuerySetView):
        def get_queryset(self):
            # Don't forget to filter out results depending on the visitor !
            if not self.request.user.is_authenticated():
                return Tenant.objects.none()

            qs = Tenant.objects.all()

            if self.q:
                qs = qs.filter(last_name__istartswith=self.q)

            return qs
Run Code Online (Sandbox Code Playgroud)

在自动完成网址中

from …
Run Code Online (Sandbox Code Playgroud)

django jquery django-autocomplete-light

4
推荐指数
1
解决办法
1676
查看次数

如果一个值大于另一个值,则过滤查询集

我试图基于两个字段之间的关系来筛选我的查询集。

但是总是会得到我的字段未定义的错误。

我的模型有几个计算列,我只想获取字段A的值大于字段B的记录。

这是我的模特

class Material(models.Model):
    version = IntegerVersionField( )
    code = models.CharField(max_length=30)
    name = models.CharField(max_length=30)
    min_quantity = models.DecimalField(max_digits=19, decimal_places=10)
    max_quantity = models.DecimalField(max_digits=19, decimal_places=10)
    is_active = models.BooleanField(default=True)
    def _get_totalinventory(self):
        from inventory.models import Inventory


        return Inventory.objects.filter(warehouse_Bin__material_UOM__UOM__material=self.id, is_active = true ).aggregate(Sum('quantity'))


    totalinventory = property(_get_totalinventory)

    def _get_totalpo(self):

        from purchase.models import POmaterial     

        return POmaterial.objects.filter(material=self.id, is_active = true).aggregate(Sum('quantity'))  

    totalpo = property(_get_totalpo)




    def _get_totalso(self):

        from sales.models import SOproduct

        return SOproduct.objects.filter(product__material=self.id ,  is_active=true ).aggregate(Sum('quantity'))  

    totalso = property(_get_totalpo)


    @property
    def _get_total(self):
        return (totalinventory + totalpo - totalso) 

    total …
Run Code Online (Sandbox Code Playgroud)

django

3
推荐指数
1
解决办法
2422
查看次数

Django异常类型:KeyError异常值:'pk'

我可能做了一些愚蠢的事情,但无法弄清楚是什么,它让我疯了,因为它是微不足道的,我有其他应用程序使用相同的逻辑.

所以我有一个模型客户和模型说明.每个客户我都可以创建很多Notes.在Notes中,Customer定义为外键.

view.py

@login_required
def note_new(request,pk):
    contact = get_object_or_404(Contacts, pk=pk)
    if request.method == "POST":
        form = NoteForm(request.POST)
        if form.is_valid():
            note = form.save(commit=False)
            note.pub_date = timezone.now()
            note.save()
            return redirect('contact_details',pk=contact.id)
    else:
        form = NoteForm(pk=contact.id)
    return render(request, 'customer/note_edit.html', {'form': form})
Run Code Online (Sandbox Code Playgroud)

forms.py

class NoteForm(forms.ModelForm):
    class Meta:
        model = Note
        fields = [ 'title','body','contact' ]

    def __init__(self,*args,**kwargs):
        contact_id = kwargs.pop('pk')
        # self.fields['contact'].initial = contact_id
        super(NoteForm,self).__init__(*args,**kwargs)
        self.initial['contact'] = contact_id
        self.fields['contact'].widget.attrs['readonly'] = True
Run Code Online (Sandbox Code Playgroud)

所以表格显示确定,点击保存后我就收到了

KeyError at/customer/note/new/9'pk'请求方法:POST请求URL:http://127.0.0.1:8000/customer/note/new/9 Django版本:1.8异常类型:KeyError异常值:
'pk '异常位置:C:\ Users\I812624\dev\mrp\src\customer\forms.py in __init__,第48行Python版本:2.7.1 …

python django keyerror

2
推荐指数
2
解决办法
4919
查看次数

为什么我收到错误:'QuerySet' 对象没有属性?

我有3个模型

class Lease(CommonInfo):
    version = IntegerVersionField( )
    #amount  = models.DecimalField(max_digits=7, decimal_places=2)
    is_renewed = models.BooleanField(default=False)
    unit = models.ForeignKey(Unit)
    is_terminated = models.BooleanField(default=False)

class LeaseTerm(CommonInfo):
    version = IntegerVersionField( )
    start_period = models.ForeignKey(Period, related_name='start_period' )
    end_period = models.ForeignKey(Period, related_name='end_period')
    lease = models.ForeignKey(Lease)
    increase  = models.DecimalField(max_digits=7, decimal_places=2)
    amount  = models.DecimalField(max_digits=7, decimal_places=2)
    is_terminated = models.BooleanField(default=False)

    def clean(self):
    model = self.__class__
    if self.lease_id and (self.is_terminated == False) and model.objects.filter(lease=self.lease, is_active=True ).count() == 1:
        raise ValidationError('!Lease has a active condition already, Terminate prior to creation of new one'.format(self.lease)) …
Run Code Online (Sandbox Code Playgroud)

django django-queryset

2
推荐指数
1
解决办法
8322
查看次数

从获取的对象访问值?

models.py

class Period(CommonInfo):
    order_value = models.PositiveSmallIntegerField()
    start_date = models.DateField()
    end_date = models.DateField()
    name = models.CharField(max_length=30)

class LeaseDiscount(CommonInfo):
    amount  = models.DecimalField(max_digits=7, decimal_places=2)
    amountpayed = models.DecimalField(max_digits=7, decimal_places=2)
    leaseterm = models.ForeignKey(LeaseTerm)
    period_date = models.ForeignKey(Period)
Run Code Online (Sandbox Code Playgroud)

views.py

我想列出我租赁的某些期间的所有折扣,查询如下:

    period = Period.objects.filter(order_value__gte = start, order_value__lte = end).prefetch_related(
        Prefetch(
            "leasediscount_set",
            queryset=LeaseDiscount.objects.filter(is_active=True, leaseterm =  activeterm),
            to_attr="all_discount"
        )
    )
Run Code Online (Sandbox Code Playgroud)

但是当我在模板中显示all_discount的句点列表时,输出就是 [<LeaseDiscount: LeaseDiscount object>]

为什么?我如何访问此对象的值?总的来说,我是以正确的方式做到的吗?

更新:模板

          {% for field1 in data.period%}


                    <td> {{ field1.all_discount }}</td>
Run Code Online (Sandbox Code Playgroud)

django

1
推荐指数
1
解决办法
78
查看次数

从github部署更改的模型时,如何在heroku上运行makemigrations / migrate?

我已经将应用程序从github存储库部署到我的客户作为协作者的heroku帐户中,但这一次我不得不添加一些新模型。

但是我意识到,当我从github部署我的更改时,heroku不会运行makemigrations并进行迁移。

II阅读了关于stackoverflow的一些答案,并理解这是应该的。

但是我的问题是我该怎么办?将变更模型部署到heroku应用程序的最佳实践是什么。(由于客户那里已经有数据,因此我认为它不会再次删除并重新创建我的应用程序。)

(我能够运行makemigrations并从bash手动迁移,但是当我进行30多次部署时,这很痛苦)

django heroku django-models django-migrations

0
推荐指数
1
解决办法
821
查看次数

app中的迁移网址没有迁移类

当我尝试运行迁移时,我得到了 "Migration urls in app *** has no Migration class"吗?我刚刚添加了新应用.

不知道要看什么方向.追溯:

C:\Users\PAPA\DEV\liberty\lib\site-packages\django\db\models\__init__.py:55:
RemovedInDjango19Warning: The utilities in django.db.models.loading are deprecated 
in favor of the new application loading system.
from . import loading

Traceback (most recent call last):   File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
File "...\django\core\management\__init__.py", line 338, in execute_from_command_line
    utility.execute()
File "...\django\core\management\__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
File "...\django\core\management\base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
File "...\django\core\management\base.py", line 441, in execute
    output = self.handle(*args, **options)
File "...\django\core\management\commands\makemigrations.py", line 63, …
Run Code Online (Sandbox Code Playgroud)

django django-migrations

0
推荐指数
1
解决办法
1004
查看次数