On Mon, Mar 2, 2009 at 11:11 AM, Dan <[email protected]> wrote:

>
> AttributeError: 'str' object has no attribute '_default_manager' from
> related.py django 1.0.2
> -------------------------------------------get this error when
> accessing any part of site
> -----------------------------------------------------
> MOD_PYTHON ERROR
>
> [snip traceback]
>  File "/usr/lib/python2.5/site-packages/django/db/models/fields/
> related.py", line 694, in formfield
>    'queryset': self.rel.to._default_manager.complex_filter(
>
> AttributeError: 'str' object has no attribute '_default_manager'
>

This means that somehow a string reference to a model has not been
transformed into an actual model reference as would be expected by the time
this code runs.


>
> ----------------------------------------------
>
> extensions.models.py---------------------------------------------------------------
> from django.db import models
> from sipconfig import *
> from django.forms import ModelForm, fields, TextInput, IntegerField
> # Create your models here.
> class Plc(models.Model):
>    name=models.CharField(max_length=30)
>    ip_addr=models.IPAddressField()
>    ip_port=models.IntegerField(default=9600)
>    plc_net=models.IntegerField()
>    plc_node=models.IntegerField()
>    plc_unit=models.IntegerField()
>
>    def __unicode__(self):
>          return self.name
>
>    class Admin: pass
>
> class VoipGateway(models.Model):
>    name=models.OneToOneField('sipconfig.station')
>    def __unicode__(self):
>          return self.name.dev_name
>    class Admin: pass
>
> class Extension(models.Model):
>    PREFIX_CHOICE=(
>        ('1','station'),
>        ('9','lock'),
>        ('8','voicemail'))
>    context=models.ForeignKey('sipconfig.station')


Why are you using quoted strings instead of direct references to the target
models here and in the OneToOneField in VoipGateway?  I don't understand why
it isn't working, but it also doesn't appear to be necessary in your case
(you don't have circular references, which is where you absolutely need to
use string references) so you may avoid the error simply by not using the
quoted-string version here.  At any rate it would be something to try.  (I
cannot experiment with recreating this myself for several days as I am
traveling and do not have access to the machines I would normally use to do
testing under Apache.)

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to