草庐IT

django-syncdb

全部标签

python - Django Celery 任务记录

我在我正在处理的Django项目中设置了Celery。我想将celery任务的日志记录与其余的celery日志(celerycam、celerybeat等)分开。根据Celery文档(http://docs.celeryproject.org/en/latest/userguide/tasks.html#logging),我似乎应该能够为“celery.task”定义一个Django记录器,它应该执行此操作。但是,当我这样做时,日志中没有显示任何内容。如果我创建一个通用的“celery”记录器,一切都会显示出来,这意味着这可能与记录器的名称有关。我在这里错过了什么?有什么办法可以做到这

python - Django - 查询给出一列不等于同一模型中另一列的行

我的模型有3个字段classTable(models.Model):in_time=models.DateTimeField(null=True,blank=True)actual_time=models.DateTimeField(null=True,blank=True)我想以这种方式获取结果:select*fromTablewherein_time>'2013-12-3100:00:00'andin_time!=actual_time谁能帮我完成这个result=Table.objects.filter(in_time__gte='2013-12-3100:00:00')

python - Django修改密码问题,super(type, obj) : obj must be an instance or subtype of type

我的changepassword表单有一些问题,它继续给我同样的错误:super(type,obj):objmustbeaninstanceorsubtypeoftype这是我的表格:classPasswordChangeForm(forms.Form):current_password=forms.CharField(label=u'CurrentPassword',widget=forms.PasswordInput(render_value=False))new_password=forms.CharField(label=u'NewPassword',widget=forms.

python - 从 Django shell 上传图像

我需要将一堆图像导入Django应用程序。我正在shell中进行测试,但在尝试保存图像时无法解决此错误:File"/lib/python3.3/codecs.py",line301,indecode(result,consumed)=self._buffer_decode(data,self.errors,final)UnicodeDecodeError:'utf-8'codeccan'tdecodebyte0xffinposition0:invalidstartbyte模型:importuuidfromdjango.dbimportmodelsfromtaggit.managersi

python - Django:有没有办法让 ManyToManyField 中的 "through"模型与包含 ManyToManyField 的模型在不同的应用程序中?

假设我有两个Django应用程序:competitions-将处理比赛数据entries-将处理与让参赛者参加比赛相关的功能在比赛应用程序中,我有一个代表比赛部分的模型:classDivision(models.Model):competition=models.ForeignKey(Competition)discipline=models.CharField(max_length=1,choices=DISCIPLINE_CHOICES)age_group=models.ForeignKey(AgeGroup)participants=models.ManyToManyField(

python - Django 自定义文件存储系统

我有一个自定义存储importosfromdjango.core.files.storageimportStorageclassAlwaysOverwriteFileSystemStorage(Storage):defget_available_name(self,name):"""DirectlyReturnsafilenamethat'sfromwhatuserinput."""ifself.exists(name):#Removetheexistingfileos.remove(name)#Returntheinputnameasoutputreturnname我想知道我应该把他

python - 在 Django 管理控制台中显示属性的勾号和十字图标

在Django管理中,如果字段是BooleanField或NullBooleanField,Django将显示漂亮的“开”或“关”图标,而不是True或False。现在,我的模型中实际上并没有BooleanField,因为我确实有一个属性fior,我想显示图标,但是当我尝试这样做时,Django尖叫着'SomeAdmin.list_filter[0]'指的是'is_activated',它不指代字段。是否可以在不对Django进行太多攻击的情况下为该字段显示那些漂亮的小图标。谢谢 最佳答案 您不想使用list_filter。您要找的

python - 如何将错误消息附加到 django 中的 form.non_field_errors?

我有一个包含多个字段的表单。我对每个字段都有单独的验证检查,通过表单验证完成。然而,在将用户重定向到不同的View之前,我还需要检查是否填写了几个字段。我希望我能以某种方式将错误附加到forms.non_field_errors,因为它不是针对特定字段的,但我不确定正确的语法是什么。我上网查了一下,发现..form.errors['__all__']=form.error_class(["errormsg"])这会显示错误消息,但它似乎也弄乱了其他页面,如果我单击其他任何内容,就会显示错误消息。我试过了form._errors[NON_FIELD_ERRORS]=form.error_

python - 如何禁用 Django Celery 管理模块?

我不需要我的Django管理中的celery模块。有什么方法可以删除它吗? 最佳答案 更具体地说,在INSTALLED_APPSafter'djcelery'内的任何应用程序的admin.py中/p>fromdjango.contribimportadminfromdjcelery.modelsimport(TaskState,WorkerState,PeriodicTask,IntervalSchedule,CrontabSchedule)admin.site.unregister(TaskState)admin.site.unr

python - django createsuperuser 不工作

.bash_profileexportPATH="/Applications/MAMP/bin:/usr/local/bin:/usr/local/sbin:usr/local/$exportDYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"exportLANG="en_US.UTF-8".个人资料exportPATH="/Applications/MAMP/bin:/usr/local/bin:/usr/local/sbin:usr/local/my$exportDYLD_LIBRARY_PATH="/usr/loc