反向重定向不起作用,但将数据插入db

时间:2016-09-30 14:16:40

标签: python django python-2.7

from django.db import models
from django.core.urlresolvers import reverse


class Gallery(models.Model):
    Title = models.CharField(max_length=250)
    Category = models.CharField(max_length=250)
    Gallery_logo = models.CharField(max_length=1000)

    def get_absolute_url(self):
        return reverse('photos:detail', kwargs={'pk', self.pk})

    def __str__(self):
        return self.Title + '_' + self.Gallery_logo


class Picture (models.Model):
    Gallery = models.ForeignKey(Gallery, on_delete=models.CASCADE)
    Title = models.CharField(max_length=250)
    Artist = models.CharField(max_length=250)
    Price = models.CharField(max_length=20)
    interested = models.BooleanField(default=False)

    def __str__(self):
        return self.Title

我收到此错误

TypeError at /photos/gallery/add/
_reverse_with_prefix() argument after ** must be a mapping, not set
Request Method: POST
Request URL:    http://127.0.0.1:8000/photos/gallery/add/
Django Version: 1.10.1
Exception Type: TypeError
Exception Value:    
_reverse_with_prefix() argument after ** must be a mapping, not set
Exception Location: C:\Users\JK\AppData\Local\Programs\Python\Python35\lib\site-packages\django-1.10.1-py3.5.egg\django\urls\base.py in reverse, line 91
Python Executable:  C:\Users\JK\AppData\Local\Programs\Python\Python35\python.exe
Python Version: 3.5.2
Python Path:    
['C:\\Users\\JK\\PycharmProjects\\catalog',
 'C:\\Users\\JK\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\django-1.10.1-py3.5.egg',
 'C:\\Users\\JK\\PycharmProjects\\catalog',
 'C:\\Users\\JK\\AppData\\Local\\Programs\\Python\\Python35\\python35.zip',
 'C:\\Users\\JK\\AppData\\Local\\Programs\\Python\\Python35\\DLLs',
 'C:\\Users\\JK\\AppData\\Local\\Programs\\Python\\Python35\\lib',
 'C:\\Users\\JK\\AppData\\Local\\Programs\\Python\\Python35',
 'C:\\Users\\JK\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages']
Server time:    Fri, 30 Sep 2016 17:15:55 +0300

再次,我只是一个新手

1 个答案:

答案 0 :(得分:2)

您将import React, { Component } from 'react'; import { ... Dimensions, ... WebView, } from 'react-native'; let ScreenHeight = Dimensions.get("window").height; let ScreenWidth = Dimensions.get("window").width; class App extends Component { render() { return ( <View style={styles.container}> ... <WebView source={{uri: 'http://foo.com'}} style={{height: ScreenHeight, width: ScreenWidth}} /> ... </View> ); } } ... const styles = StyleSheet.create({ container: { backgroundColor: '#bbb', flex: 1, }, ... }); AppRegistry.registerComponent('myApp', () => App); 作为传递给kwargs,而它应该是字典:

reverse