我正在学习Django并制作一个基本的应用程序,直到现在我已经编写了帐户处理部分,但是当我运行this.myform.setValue(mydata , 1)
时,我得到的是控制台,我无法理解要查看哪个文件,
python manage.py migrate
到目前为止,我记得上次迁移后我已经更新了模板和url.py文件,这是我的urls.py。 我仍然可以运行服务器,并且在前端看不到任何错误!
Operations to perform: Apply all migrations: accounts, admin, auth, contenttypes, sessions
Running migrations: Applying accounts.0003_auto_20180910_1420...Traceback (most recent call last): File "C:\Python\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
return self.cursor.execute(sql, params) File "C:\Python\lib\site-packages\django\db\backends\sqlite3\base.py", line 303, in execute
return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: near ")": syntax error
The above exception was the direct cause of the following exception: Operations to perform: Apply all migrations: accounts, admin, auth, contenttypes, sessions
Running migrations: Applying accounts.0003_auto_20180910_1420...Traceback (most recent call last): File "C:\Python\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
return self.cursor.execute(sql, params) File "C:\Python\lib\site-packages\django\db\backends\sqlite3\base.py", line 303, in execute
return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: near ")": syntax error
The above exception was the direct cause of the following exception: return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "C:\Python\lib\site-packages\django\db\backends\utils.py", line 77, in
_execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Python\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
return self.cursor.execute(sql, params) File "C:\Python\lib\site-packages\django\db\utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value File "C:\Python\lib\site-packages\django\db\backends\utils.py", line 85, in
_execute
return self.cursor.execute(sql, params) File "C:\Python\lib\site-packages\django\db\backends\sqlite3\base.py", line 303, in execute
return Database.Cursor.execute(self, query, params) django.db.utils.OperationalError: near ")": syntax error
编辑1:
这是我的迁移文件-
urlpatterns = [
path('admin/', admin.site.urls),
path("signup/", accounts_views.signup, name='signup'),
path('logout/', auth_views.LogoutView.as_view(), name='logout'),
path('login/', auth_views.LoginView.as_view(template_name='login.html'), name='login'),
path("", views.home, name='home'),
path('reset/', auth_views.PasswordResetView.as_view(template_name='password_reset.html', email_template_name='password_reset_email.html', subject_template_name='password_reset_subject.txt'), name='password_reset'),
path('reset/done/', auth_views.PasswordResetDoneView.as_view(template_name='password_reset_done.html'), name='password_reset_done'),
path('reset/<int:pk>/', auth_views.PasswordResetConfirmView.as_view(template_name='password_reset_confirm.html'), name='password_reset_confirm'),
path('reset/complete/', auth_views.PasswordResetCompleteView.as_view(template_name='password_resert_complete.html'), name='password_reset_complete'),
path('settings/password/', auth_views.PasswordChangeView.as_view(template_name='password_change.html'),
name='password_change'),
path('settings/password/done/', auth_views.PasswordChangeDoneView.as_view(template_name='password_change_done.html'),
name='password_change_done'),
]
第二个迁移文件-
# Generated by Django 2.0.5 on 2018-09-09 13:41
from django.conf import settings
import django.contrib.auth.models
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('auth', '0009_alter_user_last_name_max_length'),
('accounts', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='User',
fields=[
('user_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)),
],
options={
'verbose_name': 'user',
'verbose_name_plural': 'users',
'abstract': False,
},
bases=('auth.user', models.Model),
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
migrations.RemoveField(
model_name='profile',
name='user',
),
migrations.DeleteModel(
name='profile',
),
]
有人可以帮我吗?语法错误到底在哪里?
答案 0 :(得分:0)
更新-我发现解决方案问题与sqllite3数据库有关。我搬到了postgresql,现在一切正常!