Closed andy2046 closed 8 years ago
Hi asifpy,
I installed the latest version 0.2.2,
1: got another issue when search:
TypeError at /incident/crud/bd_incident/inventories/
Related Field got invalid lookup: icontains
Request Method: GET
Request URL: http://localhost:8999/incident/crud/bd_incident/inventories/?search=A
Django Version: 1.8.6
Exception Type: TypeError
Exception Value:
Related Field got invalid lookup: icontains
Exception Location: ...\Anaconda2\lib\site-packages\django\db\models\fields\related.py in get_lookup_constraint, line 1764
...\Anaconda2\lib\site-packages\crudbuilder\mixins.py in dispatch
request, *args, **kwargs)
2: I have one inventory model which is parent and 2 child models OS and DB
class inventory(models.Model):
appcode = models.ForeignKey(Applicationin, to_field='code', max_length=10,null=False, blank=False)
appcode_desc=models.CharField(max_length=100,blank=True, null=True)
hostname=models.CharField(max_length=50,null=False, blank=False)
alias =models.CharField(max_length=200,blank=True, null=True)
env=models.CharField(max_length = 10, choices = env_list,null=False, blank=False)
class Meta:
ordering = ('appcode',)
unique_together = (('appcode','hostname','env'),)
def __unicode__(self):
return "%s-%s-%s" % (self.appcode.code, self.env, self.hostname) or u''
class OS(models.Model):
OS_name=models.CharField(max_length=100,blank=False, null=False)
OS_current_version=models.CharField(max_length=100,blank=True, null=True)
inventory = models.ForeignKey(inventory, on_delete=models.CASCADE)
def __unicode__(self):
return "%s" % self.OS_name or u''
class DB(models.Model):
instance_name=models.CharField(max_length=30,blank=True, null=True)
DB_current_version=models.CharField(max_length=100,blank=True, null=True)
inventory = models.ForeignKey(inventory, on_delete=models.CASCADE)
def __unicode__(self):
return "%s" % self.instance_name or u''
3: can I add 2 child models to inline formset so one inventory form include 2 inline form set for OS and DB? inline_model = (OS,DB) doesnot work
any plan to support this?
Thanks.
To add on details for details page issue
AttributeError at /incident/crud/bd_incident/inventories/2/
'ForeignKey' object has no attribute 'get_forward_related_filter'
Request Method: GET
Request URL: http://localhost:8999/incident/crud/bd_incident/inventories/2/
Django Version: 1.8.6
Exception Type: AttributeError
Exception Value:
'ForeignKey' object has no attribute 'get_forward_related_filter'
Exception Location: ..\Anaconda2\lib\site-packages\crudbuilder\templatetags\tags.py in inline_objects, line 69
OK. I used the same models which you posted above and tested crud functionality. Below are my findings:
appcode
, instead of using appcode
, use appcode__code
in search_fields
list where code
is the search item. (You need to span your relation to specific search fields).
You can find similar case in example project. example/crud.py LINE 45.Hi Asifpy,
For the detail page error, any temp solution if I do not upgrade from Django 1.8 to 1.9? Becoz I have to use 1.8 for a while before upgrading to 1.9, thanks.
I fixed it for 1.8 also here https://github.com/asifpy/django-crudbuilder/commit/293404dc138006028e7c1b675e0d8d4bf98bca8a.
Noted, thanks a lot, will test again
pls help to check the issue below:
1: type object 'inventoryCrud' has no attribute 'search_feilds' when I serach
2: 'ForeignKey' object has no attribute 'get_forward_related_filter' when I click to go to detail page
3: if I have one more child model DB for inventory, how to add 2 models to inline formset
inline_model = (OS,DB) doesnot work
thanks