我使用 GitHub 将我的项目从我的 Windows 机器移到了 Mac
当我跑步时python manage.py runserver
显示我的登录页面效果很好,因为我没有进行任何迁移,所以应用程序崩溃了,
所以我执行python manage.py makemigrations
了,我认为这会解决问题,但是在那之后,当我尝试运行服务器时,我得到了 dejango 主页,我的所有课程都是未定义的
并且我的数据库是 postgresql 没有在表中显示我的任何模型,并且之后每次迁移都显示以下错误
并ython manage.py migrate
在下面显示
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
No migrations to apply.
No changes detected
设置.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts',
'xadmin',
'django_filters',
'crispy_forms',
]
数据库:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'crashDB',
'USER': 'postgres' ,
'PASSWORD': '1234',
'HOST': 'localhost',
}
}
这里有什么问题?将我的项目从 Windows 移动到 Mac 的最佳方法是什么?
设置中的路径:
STATIC_URL = '/static/'
MEDIA_URL = '/images/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'crash/static')
]
崩溃网址:
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('accounts.urls')),
]
帐户网址:
path('',views.home,name='home'),
视图中的主页功能:
@login_required(login_url='Login')
def home(request):
TotalNumberOfOrders = Order.objects.all().count()
#orderbycustomer = Order.objects.values('customer','customer_id').annotate(dcount=Count('product_id'))
orderbycustomer= Order.objects.values('customer_id').annotate(dcount=Count('customer_id')).values('customer_id__name','dcount','customer_id')
Customers = Customer.objects.all()
Orders = Order.objects.all().order_by('-date_created')[:4]
TotalInProgress = Order.objects.filter(status__icontains='للتوصيل').count()
TotalDelivredOrders = Order.objects.filter(status__icontains='تم التوصيل').count()
TotalPindingOrders = Order.objects.filter(status__icontains='متأخر').count()
print('total of orders',orderbycustomer)
context = {
'Customers':Customers,
'TotalNumberOfOrders':TotalNumberOfOrders,
'TotalDelivredOrders':TotalDelivredOrders,
'TotalPindingOrders':TotalPindingOrders,
'TotalInProgress':TotalInProgress,
'Orders':Orders,
'orderbycustomer':orderbycustomer
}
return render(request,'accounts/dashboard.html',context)