Here is the stack trace...

Environment:

Request Method: POSTRequest URL: http://127.0.0.1:8000/trending/trend/
Django Version: 1.6Python Version: 2.6.7Installed 
Applications:('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'sitar')Installed Middleware:('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')

Traceback:File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\core\handlers\base.py" in 
get_response
  114.                     response = wrapped_callback(request, *callback_args, 
**callback_kwargs)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\contrib\auth\decorators.py" 
in _wrapped_view
  22.                 return view_func(request, *args, **kwargs)File 
"C:\virtual_env\sitar_env2\cissimp\trending\views.py" in trend
  418.             list_result = utils.convert_queryset_to_lists(q_results, 
form)File "C:\virtual_env\sitar_env2\cissimp\trending\utils.py" in 
convert_queryset_to_lists
  918.                            for dt in affpart.damage_types.all()]),File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\manager.py" in all
  133.         return self.get_queryset()File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\fields\related.py"
 in get_queryset
  539.                 return super(ManyRelatedManager, 
self).get_queryset().using(db)._next_is_sticky().filter(**self.core_filters)File
 "C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\query.py" in 
filter
  590.         return self._filter_or_exclude(False, *args, **kwargs)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\query.py" in 
_filter_or_exclude
  608.             clone.query.add_q(Q(*args, **kwargs))File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\sql\query.py" in 
add_q
  1198.         clause = self._add_q(where_part, used_aliases)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\sql\query.py" in 
_add_q
  1232.                     current_negated=current_negated)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\sql\query.py" in 
build_filter
  1100.                     allow_explicit_fk=True)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\sql\query.py" in 
setup_joins
  1351.             names, opts, allow_many, allow_explicit_fk)File 
"C:\virtual_env\sitar_env2\lib\site-packages\django\db\models\sql\query.py" in 
names_to_path
  1274.                                      "Choices are: %s" % (name, ", 
".join(available)))
Exception Type: FieldError at /trending/trend/Exception Value: Cannot resolve 
keyword u'affectedpart' into field. Choices are: cgs_damage_code, description, 
id, reg_exp, sti


On Tuesday, October 21, 2014 1:00:36 PM UTC-3, Paul Childs wrote:
>
> Hey Collin,
>
> I had no problem in the shell...
>
>
> In [4]: AffectedPart.objects.all().count()
> Out[4]: 4090
>         # pick a random AffectedPart
> In [5]: affpart = AffectedPart.objects.all()[22]
>
> In [6]: affpart.damage_types.all()
> Out[6]: [<DamageType: Dent>]
>
> I'm not sure why this doesn't work running under the server.
>
> My models look like this:
>
> from sitar.models import (Part, DamageType, Aircraft)
> # this model is in trending.modelsclass AffectedPart(models.Model):
>     res = models.ForeignKey(Res, null=True)
>     arising = models.ForeignKey(Arising, null=True)
>
>     aircraft = models.ForeignKey(Aircraft)
>     # filled out automatically only if part to Damage/Repair type matching 
> done
>     maintenance_phase = models.CharField(max_length=10,
>                                          choices=MAINTENANCE_PHASE_CHOICES)
>     occurrence_date = models.DateField()
>     partnumber = models.ForeignKey(Part)
>     damage_types = models.ManyToManyField(DamageType, null=True, blank=True)
>     repair_types = models.ManyToManyField(RepairType, null=True, blank=True)
>
>     def __unicode__(self, ):
>         if self.res:
>             parent = self.res.number
>
>         else:
>             parent = str(self.arising)
>
>         return '{0} - {1}'.format(self.partnumber.number, parent)
> # The following models are in sitar.models    class Part(models.Model):
>     ''' This model is used to create pick-lists so the user can associate
>         one or more applicable parts from a pre-defined list to
>         a tracked item.
>
>         It will also allow for regular CRUD functionality which is
>         implemented by taking advantage of the Django admin interface. '''
>
>     # Added to associate a zone with a part
>     zones = models.ManyToManyField("Zone", null=True, blank=True)
>
>     number = models.CharField(max_length=50, unique=True)
>     description = models.CharField(max_length=100, blank=True)
>     comments = models.TextField(blank=True)
>     material = models.CharField(max_length=100, blank=True)
>
>     class Meta:
>         ''' Order by part number field (ascending) when presenting data '''
>         ordering = ['number']
>
>
>     def __unicode__(self):
>         ''' Return unicode description of a part instance '''
>         if self.description:
>             return '%s -- %s' % (self.number, self.description)
>         else:
>             return self.number
>
>
>     def get_encoded_part_number(self):
>         '''
>            This method will remove any '/' in part numbers and replace them
>            with '~' so that they can be used in URLs.
>         '''
>         return self.number.replace('/','~')
>
> class DamageType(models.Model):
>
>     description = models.CharField(max_length=50, unique=True)
>     # a regular expression to account for possible spelling mistakes when
>     # querying the database
>     reg_exp = models.CharField(max_length=50, blank=True)
>
>     # Added to provide damage code for TRENDING
>     cgs_damage_code = models.CharField(max_length=10, blank=True,
>                                        verbose_name="CGS Damage Code")
>
>     def __unicode__(self):
>         ''' Return unicode representation of a DamageType instance. '''
>         return self.description
>
>     class Meta:
>         ''' Order by description field (ascending) when presenting data '''
>         ordering = ['description']
>
>     def save(self):
>         ''' Override the save method of the DamageType model in order to 
> assign
>             a regexp if one does not exist.'''
>
>         # if the tracked item does not have a reg_exp just use
>         # the description
>         if not self.reg_exp:
>             self.reg_exp = self.description
>
>         super(DamageType,self).save()
>
>
>
> /Paul
>
> On Tuesday, October 21, 2014 12:52:45 PM UTC-3, Collin Anderson wrote:
>>
>> Hi Paul,
>>
>> Interesting. Your code should work fine. So if you run this code in the 
>> shell it gives a FieldError?
>>
>> affpart.damage_types.all()
>>
>> What do your sitar models look like? There should not be a 
>> ManyToManyField in the other direction.
>>
>> Collin
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5c5da304-2902-4146-82ef-a716950ddbcd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to