Надо связать пользователя моделью Order accounts models py профиль для

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Надо связать пользователя с моделью Order. accounts\models.py - профиль для User, main\models.py - основные модели. Это делается для интернет магазина, у пользователя имеются заказы (Order) с которыми потом дальше работать. При запуске выдается:
django.core.management.base.CommandError: One or more models did not validate:
main.order: 'user' has a relation with model client_profile, which has either no
t been installed or is abstract.
accounts\models.py
#-*-coding:utf8-*-
from django.contrib.auth.models import User
from django.db import models
class client_profile(models.Model):
user = models.ForeignKey(User, unique=True)
city = models.CharField(max_length=24)
address = models.TextField(max_length=200)
is_trade = models.BooleanField(default=False)
main\models.py
#-*-coding:utf8-*-
from django.db import models
from koval_magazine.accounts.models import client_profile
from django.contrib.auth.models import User
import datetime as dt
# Create your models here.
class Order(models.Model):
user = models.ForeignKey('client_profile')
opened = models.BooleanField(default=True)
date_create = models.DateTimeField(auto_now=False)
def closed(self):
self.opened = False
date_create = dt.datetime.now()
class good_to_buy(models.Model):
good_to = models.OneToOneField('good')
order = models.ForeignKey('Order')
count = models.IntegerField(default=0, max_length=3)
class good(models.Model):
title = models.CharField(max_length=250)
barcode = models.IntegerField(max_length=24)
count = models.IntegerField(max_length=4)
image = models.ImageField(upload_to='/images/')
description = models.TextField()