将Django项目从Windows迁移到Mac迁移

时间:2020-05-07 01:26:45

标签: python django macos migration makemigrations

我使用GitHub将项目从Windows计算机移至Mac

当我运行python manage.py runserver

在显示我的登录页面时效果很好,并且由于我没有进行任何迁移,因此应用程序崩溃了,

所以我执行了python manage.py makemigrations,我认为这可以解决问题,但是 在那之后,当我尝试运行服务器时,我得到了dejango主页,我的所有经历也都未定义

Undefined classes issue

Django Home Page

我的数据库(PostgreSQL数据库)未在表中显示任何模型,并且此后每次迁移都显示以下错误

ython manage.py migrate显示在下面

Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
No migrations to apply.

No changes detected

setting.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')
]

Crash.urls:

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('accounts.urls')),
]

accounts.urls:

    path('',views.home,name='home'),

视图中的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)

0 个答案:

没有答案