我开始了一个新的博客项目来尝试 Laravel。我按照https://laracasts.com/series/laravel-from-scratch-2017/episodes/1?autoplay=true 中的教程进行操作。我更改了 .env 文件
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Run Code Online (Sandbox Code Playgroud)
到
DB_DATABASE=blog
DB_USERNAME=root
DB_PASSWORD=
Run Code Online (Sandbox Code Playgroud)
然后输入
php artisan migrate
并得到一个错误
Illuminate\Database\QueryException : could not find driver (SQL: select * from information_schema.tables where table_schema = blog and table_name = migrations)
at /home/morilon/php_proj/blog/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead …Run Code Online (Sandbox Code Playgroud) 我更改了模型并进行了迁移。然后我又更改了一次模型,当尝试 python manage.py migrate 时,我收到错误:
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, shop
Running migrations:
Applying shop.0004_auto_20180128_1331...Traceback (most recent call last):
File "/home/morilon/dj/intshop/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
File "/home/morilon/dj/intshop/venv/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 301, in execute
return Database.Cursor.execute(self, query)
sqlite3.OperationalError: table "shop_brand" already exists
Run Code Online (Sandbox Code Playgroud)
所以我的问题是 - 如何删除表“shop_brand”???我已经尝试过flush,sqlflush但这只从表中删除数据,而不是实际表“shop_brand”。
我使用 django 2.0.1 和 python 3.6
我有我必须用 Symfony Form 重做的表格,但我坚持在这个地方:
<div class="currency-label">
<input checked id="cur1" name="currency" type="radio">
<label for="cur1">EURO</label>
</div>
<div class="currency-label active">
<input id="cur2" name="currency" type="radio">
<label for="cur2">USD</label>
</div>
Run Code Online (Sandbox Code Playgroud)
如何使用 Symfony Forms 制作单选按钮?在我的表单类中,我添加了:
->add('vacancyCurrency', RadioType::class, ['required' => false])
Run Code Online (Sandbox Code Playgroud)
和我的模板
{{ form_widget(form.vacancyCurrency) }}
Run Code Online (Sandbox Code Playgroud)
我的表格变短了,显然没有 css :
如果我添加 css 类来形成它看起来不同:
{{ form_widget(form.vacancyCurrency, {'attr':
{'class': 'currency-label'}
}) }}
Run Code Online (Sandbox Code Playgroud)