我已经使用django一段时间了,我决定开始一个新项目,但这次在Codeigniter中,我曾经在我的视图中扩展模板文件,并将内容放在{%block content%}块内,但它看起来是在CodeIgniter中有所不同.
在CodeIgniter中我有类似的东西:
<?php
$this->load->view('header');
$this->load->view('form_add_customer');
$this->load->view('footer');
?>
Run Code Online (Sandbox Code Playgroud)
但有没有办法像这样有一个标题,内容和页脚的独特文件?
<html>
<head><title>Test</title></head>
<body>
<div id="header">Welcome</div>
<div id="content">
</div>
<div id="footer"> 2013 - Tectcom Telecom</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
并在内容div中放置一个带有表单的视图文件?
我有以下代码:
settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'tectcom',
'USER': 'test',
'PASSWORD': '***146***',
'HOST': '',
'PORT': '',
},
'cdr': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'ast',
'USER': '123',
'PASSWORD': '654',
'HOST': '',
'PORT': '',
}
Run Code Online (Sandbox Code Playgroud)
views.py
def cdr_user(request):
cursor = connections['cdr'].cursor()
calls = cursor.execute('SELECT * FROM cdr')
return render_to_response("cdr_user.html",
{'result':calls }, context_instance=RequestContext(request))
Run Code Online (Sandbox Code Playgroud)
cdr_user.html
{% for res in result %}
{{ res.billsec }}<br />
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
表就是这样的:
+-------------+--------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra …Run Code Online (Sandbox Code Playgroud) 我刚刚开始学习Angular,但是我遇到了以下错误:无法绑定到'disabled',因为它不是已知的属性<button>.在互联网上搜索我发现了类似的错误,但它们与未导入FormsModule的事实有关,这似乎不是我的情况.
app.components.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
Button = false;
}
Run Code Online (Sandbox Code Playgroud)
app.component.html
<div style="text-align:center">
<h1>
Welcome to {{title}}!!
</h1>
<button [Disabled]="!Button">Click me</button>
</div>
Run Code Online (Sandbox Code Playgroud)
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
FormsModule,
],
providers: [],
bootstrap: [AppComponent] …Run Code Online (Sandbox Code Playgroud) 我不知道如何在excel中做到这一点:
如果A1/6休息!= 0,则A1的下一个倍数为6.
谢谢.