1

I moved my project from my windows machine to Mac using GitHub

when I run python manage.py runserver

it worked fine showing my login page and since I didn't do any migration the app crashed,

so I executed python manage.py makemigrations I thought this will solve the problem but after that when I am trying to runserver I am getting the dejango home page also all my clasess are Undefined

Undefined classes issue

Django Home Page

and my database which is postgresql not showing any of my models in the table and make migrations showing below error every time after that

and ython manage.py migrate showing below

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',
]

database:

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'crashDB',
    'USER': 'postgres' ,
    'PASSWORD': '1234',
    'HOST': 'localhost',
}
}

what is the issue in here ?? and what is the best way to move my project from windows to Mac ?

the path in the setting:

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'),

the home function in the view:

@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)
IOS777
  • 35
  • 3
  • 9
  • Did you use absolute paths in settings.py ? – RaoufM May 07 '20 at 01:53
  • I did not change the path, I just update the question check the path – IOS777 May 07 '20 at 01:55
  • Did you import customer and order in your views.py ? – RaoufM May 07 '20 at 02:01
  • yes using this "from .models import *" but I have an underline below that saying "Unused import Tag from wildcard importpylint(unused-wildcard-import)" – IOS777 May 07 '20 at 02:04
  • can you try to replace * with the name of the functions ? – RaoufM May 07 '20 at 02:06
  • "from .models import Customer,Tag,Product,Order,OrderHistory" still showing the same error – IOS777 May 07 '20 at 02:08
  • try to delete migrations . So for each app go to migrations folder and delete all of them except for the `__init__.py` file and then run `makemigrations` and then `migrate` – RaoufM May 07 '20 at 02:13
  • already did that and same error , I noticed that __init__.py is empty, is that normal ? – IOS777 May 07 '20 at 02:17
  • Yes it is empty ... You can always try to create a new project and just copy paste all the code from one project to the other , I mean it worked for me once – RaoufM May 07 '20 at 02:18

0 Answers0