我正在关注https://docs.djangoproject.com/en/1.8/intro/tutorial03/ 我已经按照教程中的方式配置了我的项目目录.我正在为民意调查配置网址.根据教程我定义了详细信息,结果,在投票的urls.py中的views.py和poll url中投票,这是在项目目录的urls.py中定义的.当我访问
本地主机:8000 /调查/
有用.但是,当我试图访问一个民意调查的细节,因为他们描述它抛出404.I我尝试了我的实际问题ID,但都是徒劳的.
在Docs中他们说"at"/ polls/34 /".它将运行detail()方法"但对我来说它会抛出404
本地主机:8000 /调查/ 34 /
Using the URLconf defined in DjangoFirst.urls, Django tried these URL patterns, in this order:
^polls ^$ [name='index']
^polls ^(?P<question_id>[0-9]+)/$ [name='detail']
^polls ^(?P<question_id>[0-9]+)/results/$ [name='results']
^polls ^(?P<question_id>[0-9]+)/votes/$ [name='vote']
^admin/
The current URL, polls/34/, didn't match any of these.
Run Code Online (Sandbox Code Playgroud)
这是位于ProjectName/ProjectName/urls.py中的urls.py
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url (r'^polls', include('polls.urls')),
url(r'^admin/', include(admin.site.urls)),
]
Run Code Online (Sandbox Code Playgroud)
这是我的民意调查urls.py位于ProjectName/polls/urls.py中
from django.conf.urls import url
from . import views
urlpatterns = …Run Code Online (Sandbox Code Playgroud) 我试图以编程方式向UIView添加渐变,但它无法正常工作.它似乎根本没有颜色.我附上了相关代码以及截图.注意我应用渐变的底部正方形.有人能帮我弄清楚我在做错了什么吗?

let sundayView = UIView()
override func viewDidLoad() {
super.viewDidLoad()
setupViews()
setupSundayView()
}
func setupViews() {
sundayView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(sundayView)
}
func setupSundayView() {
sundayView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activateConstraints([
sundayView.centerXAnchor.constraintEqualToAnchor(view.centerXAnchor),
sundayView.topAnchor.constraintEqualToAnchor(fridayView.bottomAnchor, constant: 16.0),
sundayView.trailingAnchor.constraintEqualToAnchor(view.trailingAnchor, constant: -8.0),
sundayView.heightAnchor.constraintEqualToAnchor(mondayView.heightAnchor),
sundayView.widthAnchor.constraintEqualToAnchor(mondayView.widthAnchor)
])
let gradient = CAGradientLayer()
gradient.frame = sundayView.bounds
gradient.colors = [
UIColor(red:1.00, green:0.37, blue:0.23, alpha:1.0).CGColor,
UIColor(red:1.00, green:0.16, blue:0.41, alpha:1.0).CGColor
]
sundayView.layer.insertSublayer(gradient, atIndex: 0)
}
Run Code Online (Sandbox Code Playgroud)