小编Nic*_*ick的帖子

Django + posgtres 关系不存在错误

我知道这件事有多少问题,但建议的解决方案都没有帮助。我遇到了以下问题:我删除了我的模型并删除了导入admin.py。然后我想更新 django 数据库,makemigrations该数据库显示它删除了模型员工,但在使用migrate命令后,我看到了一个错误,表明该关系不存在。我也从我使用的 postgres 数据库中删除了它。这里奇怪的是 migrate 一直在寻找不存在的模型。即使我创建另一个makemigrations检测到它然后migraterelation project_employee.. 尝试syncdb --all没有成功。这是输出migrate

Apply all migrations: sessions, project, admin, auth, contenttypes
Running migrations:
Applying project.0003_auto_20160318_1215...Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: relation "project_employee" does not exist


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
 File "manage.py", line 10, in <module>
  execute_from_command_line(sys.argv)
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", …
Run Code Online (Sandbox Code Playgroud)

python django postgresql

6
推荐指数
3
解决办法
2万
查看次数

没有实例(Show([(Char,Char)] - > Char))

所以我必须创建一个函数,找到一对第一个字母并返回第二个字母.

我实际上找到了一个答案,但有地图功能,我无法得到它.

      lookUp :: Char -> [(Char, Char)] -> Char
      lookUp x [] = x
      lookUp x ( ( st,nd ): rst) | st == x = nd
                   | otherwise = lookUp x rst
Run Code Online (Sandbox Code Playgroud)

我得到这个消息:

No instance for (Show ([(Char, Char)] -> Char))
arising from a use of `print'
 Possible fix:
  add an instance declaration for (Show ([(Char, Char
  In a stmt of an interactive GHCi command: print it
Run Code Online (Sandbox Code Playgroud)

haskell compiler-errors ghci

4
推荐指数
2
解决办法
2885
查看次数

Haskell递归":"替换为|| 为什么?

我有一个问题,为什么这个函数不能与":"一起使用,但与||一起使用 为什么":"被||取代 我的意思是为什么不能写

包含xs(y:ys)=前缀xs(y:ys):包含xs ys

 contains :: String -> String -> Bool
 contains [] _ = True
 contains _ [] = False
 contains xs (y:ys) = prefix xs (y:ys) || contains xs ys
Run Code Online (Sandbox Code Playgroud)

recursion haskell

3
推荐指数
1
解决办法
189
查看次数

Int to Float转换:Num [Int]没有实例

我需要使用该map函数来获得例如pence到磅的转换.抱歉这个愚蠢的问题..但我是初学者.

del :: Int -> Float
del x =  ( fromIntegral x ) / 100

pounds :: [Int] -> [Float]
pounds = map del 
Run Code Online (Sandbox Code Playgroud)

我收到这个错误..

*Main> pounds 45
<interactive>:90:8:
    No instance for (Num [Int])
      arising from the literal `45'
    Possible fix: add an instance declaration for (Num [Int])
    In the first argument of `pounds', namely `45'
    In the expression: pounds 45
    In an equation for it': it = pounds 45
Run Code Online (Sandbox Code Playgroud)

floating-point int haskell

2
推荐指数
1
解决办法
1257
查看次数

Haskell:功能中的点

有人可以告诉我为什么在这个功能中使用"." ?

     longestProductLen :: [(Barcode, Item)] -> Int
     longestProductLen = maximum . map (length . fst . snd)
Run Code Online (Sandbox Code Playgroud)

haskell max ghci pointfree function-composition

1
推荐指数
1
解决办法
251
查看次数