我有一些代码,当它执行时,它抛出一个NoReverseMatch,说:
NoReverseMatch at/my_url/Reverse for'my_url_name',参数'()'和关键字参数'{}'未找到.n模式尝试:[]
这是什么意思,我能做些什么呢?
我正在尝试创建一个与我的图表工具一起使用的管理器类,问题是我使用的工具,对3d和2d图表使用相同的名称,当我尝试添加2d库时导致模糊引用.任何想法如何最好地解决这个问题?
例如,
using tool.2dChartLib;
using tool.3dChartLib;
Run Code Online (Sandbox Code Playgroud)
BorderStyle是这两者的成员
我已经尝试过使用BorderStyle的区域.我想它可以工作,如果我只是参考,tool
但那意味着我将有数百tool.class
行代替class
我最近发现默认情况下默认情况下MessageBoxes不是最顶级的形式,我想知道是否有人知道你不希望消息框显示在其他窗口之上的任何情况?
当我开始在加载应用程序时显示启动画面时,我发现了这个问题,看起来我的程序仍在运行,但是MessageBox
在启动画面后面等待输入...启动画面显示在不同的线程上调用消息框的线程所以我想这就是为什么它没有出现在启动之上; 但这仍然无法解释为什么MessageBox MB_TOPMOST
默认没有标志?
编辑
为了更好地澄清:最后我不得不做一些与此类似的事情来制作一个消息框,代码并不完全正确,就像从内存中写的那样)
[DllImport("User32.dll")]
private int extern MessageBox(windowhandle, message, caption, flag);
public static void MessageBox(windowhandle, string message, string caption)
{
MessageBox(windowhandle, message,caption, MB_TOPMOST);
}
Run Code Online (Sandbox Code Playgroud) 在回答我最近的一个问题(这里)时,汉斯帕斯特说我应该设置DialogResult
关闭我的表格而不是form.Close()
我似乎无法找出原因?
如果我已经正确阅读,MSDN文档说明这样做只会隐藏表单而不是正确处理它我认为.Close()
这样做?
从文档中提取.
当用户单击对话框的"关闭"按钮或设置DialogResult属性的值时,不会自动调用Close方法.相反,表单是隐藏的,可以再次显示,而无需创建对话框的新实例.由于此行为,您必须在应用程序不再需要表单时调用表单的Dispose方法.
另一方面,Microsoft创建了一个支持页面,其中说明了如何使用DialogResult属性,并在其"验证它工作"部分中声明单击这样将关闭表单.
所以我的问题是双重的,我应该继续使用Close或DialogResult; 并且对话框结果关闭或隐藏表单.从我下面的代码(一个带有两个按钮的简单表单),看起来它确实只是作为一个断点点this.Close()
被隐藏...(this.Close()
注释,表单仍然消失,只是不确定是否隐藏)
public Form1()
{
InitializeComponent();
button1.Click += (s, e) =>
{
//I edited my question to include using
using(Form1 form = new Form1())
{
form.ShowDialog();
}
};
button2.Click += (s, e) =>
{
this.DialogResult = DialogResult.OK;
this.Close();
};
}
Run Code Online (Sandbox Code Playgroud) 我有一些简单的模型,Profile,Certifier和Designer,后者继承自Profile(多表继承).在Designer中,有一个Certifier的外键.
class Profile(models.Model):
TYPES = (
('admin', _('Administrator')),
('certifier', _('Certifier')),
('designer', _('Designer'))
)
user = models.OneToOneField(User)
type = models.CharField(max_length=9, choices=TYPES)
def __str__(self):
return self.user.username + ' (' + self.type + ')'
class Admin(Profile):
pass
class Certifier(Profile):
pass
class Designer(Profile):
certifier = models.ForeignKey(Certifier)
Run Code Online (Sandbox Code Playgroud)
在Django 1.8中,这很有效,但在1.9中我得到了;
django.core.management.base.SystemCheckError:SystemCheckError:系统检查发现了一些问题:
错误:
check.Designer.certifier :( models.E006)字段'certifier'与模型'check.profile'中的字段'certifier'冲突.
(在这种情况下,Profile.type是无关紧要的,我只需要它来区分登录的用户配置文件类型).
check.profile显然没有字段'certifier'.这是一个错误还是我错过了什么?同样的事情发生在另一个项目中.
我的应用程序已部署heroku
.
当我通过我的代码推送时git push heroku master
.它给了我这个错误
Collecting pkg-resources==0.0.0 (from -r requirements.txt (line 14))
remote: Could not find a version that satisfies the requirement pkg-resources==0.0.0 (from -r requirements.txt (line 14)) (from versions: )
remote: No matching distribution found for pkg-resources==0.0.0 (from -r requirements.txt (line 14))
remote: ! Push rejected, failed to compile Python app.
Run Code Online (Sandbox Code Playgroud)
requirement.txt
amqp==2.1.1
billiard==3.5.0.2
boto==2.42.0
celery==4.0.0
dj-database-url==0.4.1
Django==1.10.2
django-appconf==1.0.2
django-model-utils==2.6
django-storages==1.5.1
djangorestframework==3.4.7
gunicorn==19.6.0
Jinja2==2.8
kombu==4.0.0
MarkupSafe==0.23
optional-django==0.1.0
pep8==1.7.0
pkg-resources==0.0.0
psycopg2==2.6.2
pyflakes==1.3.0
pytz==2016.7
rcssmin==1.0.6
requests==2.12.1
rjsmin==1.0.12 …
Run Code Online (Sandbox Code Playgroud) 我对编程有些新意,我对C#中的类,继承和多态有疑问.在了解这些主题的同时,我偶尔会遇到类似这样的代码:
Animal fluffy = new Cat(); // where Animal is a superclass of Cat*
Run Code Online (Sandbox Code Playgroud)
这让我很困惑,因为我不明白为什么有人会创建一个类型为Animal的变量来存储Cat类型的对象.为什么一个人不会简单地写这个:
Cat fluffy = new Cat();
Run Code Online (Sandbox Code Playgroud)
我确实理解为什么将子对象存储在父类型变量中是合法的,但不是为什么它有用.是否有充分的理由将Cat
对象存储在Animal
变量与Cat
变量中?一个人可以举个例子吗?我确定它与多态和方法覆盖(和/或方法隐藏)有关,但我似乎无法绕过它.提前致谢!
我正在尝试使用以下代码处理django/python中的表单.
home.html的:
<form action="{% url 'home:submit' %}"method='post'>
Run Code Online (Sandbox Code Playgroud)
views.py:
def submit(request):
a = request.POST(['initial'])
return render(request, 'home/home.html', {
'error_message': "returned"
})
Run Code Online (Sandbox Code Playgroud)
urls.py:
url(r'^submit/$', views.submit, name='submit'),
Run Code Online (Sandbox Code Playgroud)
当我尝试在浏览器中运行它时,我收到错误:
在/ home/u'home'的NoReverseMatch不是一个注册的命名空间,我也知道表单中有错误?
我已经改变了我的模型然后我试图迁移它们,但是得到了这个错误:
python manage.py migrate
Operations to perform:
Apply all migrations: admin, contenttypes, auth, sessions, myapp
Running migrations:
Rendering model states... DONE
Applying myapp.0002_auto_20160315_1544...Traceback (most recent call last):
File "/home/bootuz/final/myvenv/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/bootuz/final/myvenv/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 112, in execute
return self.cursor.execute(query, args)
File "/home/bootuz/final/myvenv/lib/python3.4/site-packages/MySQLdb/cursors.py", line 226, in execute
self.errorhandler(self, exc, value)
File "/home/bootuz/final/myvenv/lib/python3.4/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorvalue
File "/home/bootuz/final/myvenv/lib/python3.4/site-packages/MySQLdb/cursors.py", line 217, in execute
res = self._query(query)
File "/home/bootuz/final/myvenv/lib/python3.4/site-packages/MySQLdb/cursors.py", line 378, in _query
rowcount = self._do_query(q) …
Run Code Online (Sandbox Code Playgroud) django ×6
c# ×4
python ×4
class ×1
dialogresult ×1
django-1.9 ×1
django-urls ×1
heroku ×1
inheritance ×1
messagebox ×1
name-clash ×1
object ×1
pip ×1
polymorphism ×1
topmost ×1
winforms ×1