Re: Bug in admin models?

2013-10-25 Thread Sandro Dutra
Sorry, I didn't see the django.contrib.admin. You're overrriding the add
method for you model? Because it's appear the add method is returning None:

Exception Type: TypeError at /admin/myapp/mymodel/add/
Exception Value: 'NoneType' object has no attribute '__getitem__'


2013/10/25 Derek 

> Yes, I simplified the names in the installed list and traceback, and as
> result probably altered the correct grammer slighlty ... but I am hoping
> that someone who understand the "innards" of the Django admin can point
> what is _actually_ wrong; given that the error trace is not actually
> referencing any lines in my app/project.
>
>
>
> On Thursday, 24 October 2013 16:17:17 UTC+2, Nigel Legg wrote:
>
>> In installed apps you have s2.myapp, the traceback is just myapp.  Also
>> you have 's2.myapp, in the installed_apps, should it not be 's2.myapp', (ie
>> missing the end quote)?
>>
>>
>> Cheers, Nigel
>> 07914 740972
>>
>>
>>
>> On 24 October 2013 14:20, Derek  wrote:
>>
>>>  Yes, its there - the line after 'suit'.
>>>
>>>
>>> On Wednesday, 23 October 2013 19:22:54 UTC+2, Odin wrote:
>>>
 Can't see the django.contrib.admin in INSTALLED_APPS.


 2013/10/23 Derek 

> I am trying to add a model entry, via the admin; I get this error
> (which has not happened before), running Django on Ubuntu 12.04 with the
> test server.  Not sure if there is an error with the model (which has
> worked fine up to now) or ...?
>
>
> Request Method: POST
> Request URL: 
> http://127.0.0.1:8000/admin/**my**app/mymodel/add/
>
> Django Version: 1.5.4
> Python Version: 2.7.3
> Installed Applications:
> ('django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.staticfiles',
>  'django.contrib.messages',
>  'django.contrib.admindocs',
>  'django_nose',
>  'django_extensions',
>  'crispy_forms',
>  'autocomplete_light',
>  'admin_enhancer',
>  'smart_selects',
>  'selectable',
>  'massadmin',
>  's2.myapp,
>  'suit',
>  'django.contrib.admin')
> Installed Middleware:
> ('django.middleware.common.**Com**monMiddleware',
>  'django.contrib.sessions.**midd**leware.SessionMiddleware',
>  'django.middleware.csrf.**CsrfV**iewMiddleware',
>  'django.contrib.auth.**middlewa**re.**AuthenticationMiddleware',
>  'django.contrib.messages.**midd**leware.MessageMiddleware',
>  's2s.middle.middleware.**AdminS**essionMiddleware')
>
>
> Traceback:
> File "/usr/local/lib/python2.7/**dist**-packages/django/core/**
> handlers**/base.py" in get_response
>   115. response = callback(request,
> *callback_args, **callback_kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/contrib/**
> admin**/options.py" in wrapper
>   372. return self.admin_site.admin_view(**vie**w)(*args,
> **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/utils/**
> decorat**ors.py" in _wrapped_view
>   91. response = view_func(request, *args,
> **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/views/**
> decorat**ors/cache.py" in _wrapped_view_func
>   89. response = view_func(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/contrib/**
> admin**/sites.py" in inner
>   202. return view(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/utils/**
> decorat**ors.py" in _wrapper
>   25. return bound_func(*args, **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/utils/**
> decorat**ors.py" in _wrapped_view
>   91. response = view_func(request, *args,
> **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/utils/**
> decorat**ors.py" in bound_func
>   21. return func(self, *args2, **kwargs2)
> File "/usr/local/lib/python2.7/**dist**-packages/django/db/**
> transactio**n.py" in inner
>   223. return func(*args, **kwargs)
> File "/usr/local/lib/python2.7/**dist**-packages/django/contrib/**
> admin**/options.py" in add_view
>   1009. self.log_addition(request, new_object)
> File "/usr/local/lib/python2.7/**dist**-packages/django/contrib/**
> admin**/options.py" in log_addition
>   530. action_flag = ADDITION
> File "/usr/local/lib/python2.7/**dist**-packages/django/contrib/**
> admin**/models.py" in log_action
>   18. e = self.model(None, None, user_id, content_type_id,
> smart_text(object_id), object_repr[:200], action_flag, change_message)
>
> Exception Type: TypeError at 

Re: Bug in admin models?

2013-10-25 Thread Derek
Yes, I simplified the names in the installed list and traceback, and as 
result probably altered the correct grammer slighlty ... but I am hoping 
that someone who understand the "innards" of the Django admin can point 
what is _actually_ wrong; given that the error trace is not actually 
referencing any lines in my app/project.


On Thursday, 24 October 2013 16:17:17 UTC+2, Nigel Legg wrote:
>
> In installed apps you have s2.myapp, the traceback is just myapp.  Also 
> you have 's2.myapp, in the installed_apps, should it not be 's2.myapp', (ie 
> missing the end quote)? 
>
>
> Cheers, Nigel 
> 07914 740972
>
>
>
> On 24 October 2013 14:20, Derek  wrote:
>
>> Yes, its there - the line after 'suit'.
>>
>>
>> On Wednesday, 23 October 2013 19:22:54 UTC+2, Odin wrote:
>>
>>> Can't see the django.contrib.admin in INSTALLED_APPS.
>>>
>>>
>>> 2013/10/23 Derek 
>>>
 I am trying to add a model entry, via the admin; I get this error 
 (which has not happened before), running Django on Ubuntu 12.04 with the 
 test server.  Not sure if there is an error with the model (which has 
 worked fine up to now) or ...?


 Request Method: POST
 Request URL: 
 http://127.0.0.1:8000/admin/**myapp/mymodel/add/

 Django Version: 1.5.4
 Python Version: 2.7.3
 Installed Applications:
 ('django.contrib.auth',
  'django.contrib.contenttypes'**,
  'django.contrib.sessions',
  'django.contrib.staticfiles',
  'django.contrib.messages',
  'django.contrib.admindocs',
  'django_nose',
  'django_extensions',
  'crispy_forms',
  'autocomplete_light',
  'admin_enhancer',
  'smart_selects',
  'selectable',
  'massadmin',
  's2.myapp,
  'suit',
  'django.contrib.admin')
 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',
  's2s.middle.middleware.**AdminSessionMiddleware')


 Traceback:
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/core/**handlers/base.py" 
 in get_response
   115. response = callback(request, 
 *callback_args, **callback_kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/options.py"
  
 in wrapper
   372. return self.admin_site.admin_view(**view)(*args, 
 **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py" 
 in _wrapped_view
   91. response = view_func(request, *args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/views/**decorators/cache.py"
  
 in _wrapped_view_func
   89. response = view_func(request, *args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/sites.py" 
 in inner
   202. return view(request, *args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py" 
 in _wrapper
   25. return bound_func(*args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py" 
 in _wrapped_view
   91. response = view_func(request, *args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py" 
 in bound_func
   21. return func(self, *args2, **kwargs2)
 File "/usr/local/lib/python2.7/**dist-packages/django/db/**transaction.py" 
 in inner
   223. return func(*args, **kwargs)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/options.py"
  
 in add_view
   1009. self.log_addition(request, new_object)
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/options.py"
  
 in log_addition
   530. action_flag = ADDITION
 File 
 "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/models.py"
  
 in log_action
   18. e = self.model(None, None, user_id, content_type_id, 
 smart_text(object_id), object_repr[:200], action_flag, change_message)

 Exception Type: TypeError at /admin/myapp/mymodel/add/
 Exception Value: 'NoneType' object has no attribute '__getitem__'

  -- 
 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...@**googlegroups.com.
 To post to this group, send email to 

Re: Bug in admin models?

2013-10-24 Thread Nigel Legg
In installed apps you have s2.myapp, the traceback is just myapp.  Also you
have 's2.myapp, in the installed_apps, should it not be 's2.myapp', (ie
missing the end quote)?


Cheers, Nigel
07914 740972



On 24 October 2013 14:20, Derek  wrote:

> Yes, its there - the line after 'suit'.
>
>
> On Wednesday, 23 October 2013 19:22:54 UTC+2, Odin wrote:
>
>> Can't see the django.contrib.admin in INSTALLED_APPS.
>>
>>
>> 2013/10/23 Derek 
>>
>>> I am trying to add a model entry, via the admin; I get this error (which
>>> has not happened before), running Django on Ubuntu 12.04 with the test
>>> server.  Not sure if there is an error with the model (which has worked
>>> fine up to now) or ...?
>>>
>>>
>>> Request Method: POST
>>> Request URL: 
>>> http://127.0.0.1:8000/admin/**myapp/mymodel/add/
>>>
>>> Django Version: 1.5.4
>>> Python Version: 2.7.3
>>> Installed Applications:
>>> ('django.contrib.auth',
>>>  'django.contrib.contenttypes'**,
>>>  'django.contrib.sessions',
>>>  'django.contrib.staticfiles',
>>>  'django.contrib.messages',
>>>  'django.contrib.admindocs',
>>>  'django_nose',
>>>  'django_extensions',
>>>  'crispy_forms',
>>>  'autocomplete_light',
>>>  'admin_enhancer',
>>>  'smart_selects',
>>>  'selectable',
>>>  'massadmin',
>>>  's2.myapp,
>>>  'suit',
>>>  'django.contrib.admin')
>>> 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',
>>>  's2s.middle.middleware.**AdminSessionMiddleware')
>>>
>>>
>>> Traceback:
>>> File 
>>> "/usr/local/lib/python2.7/**dist-packages/django/core/**handlers/base.py"
>>> in get_response
>>>   115. response = callback(request,
>>> *callback_args, **callback_kwargs)
>>> File 
>>> "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/options.py"
>>> in wrapper
>>>   372. return self.admin_site.admin_view(**view)(*args,
>>> **kwargs)
>>> File "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py"
>>> in _wrapped_view
>>>   91. response = view_func(request, *args, **kwargs)
>>> File 
>>> "/usr/local/lib/python2.7/**dist-packages/django/views/**decorators/cache.py"
>>> in _wrapped_view_func
>>>   89. response = view_func(request, *args, **kwargs)
>>> File 
>>> "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/sites.py"
>>> in inner
>>>   202. return view(request, *args, **kwargs)
>>> File "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py"
>>> in _wrapper
>>>   25. return bound_func(*args, **kwargs)
>>> File "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py"
>>> in _wrapped_view
>>>   91. response = view_func(request, *args, **kwargs)
>>> File "/usr/local/lib/python2.7/**dist-packages/django/utils/**decorators.py"
>>> in bound_func
>>>   21. return func(self, *args2, **kwargs2)
>>> File "/usr/local/lib/python2.7/**dist-packages/django/db/**transaction.py"
>>> in inner
>>>   223. return func(*args, **kwargs)
>>> File 
>>> "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/options.py"
>>> in add_view
>>>   1009. self.log_addition(request, new_object)
>>> File 
>>> "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/options.py"
>>> in log_addition
>>>   530. action_flag = ADDITION
>>> File 
>>> "/usr/local/lib/python2.7/**dist-packages/django/contrib/**admin/models.py"
>>> in log_action
>>>   18. e = self.model(None, None, user_id, content_type_id,
>>> smart_text(object_id), object_repr[:200], action_flag, change_message)
>>>
>>> Exception Type: TypeError at /admin/myapp/mymodel/add/
>>> Exception Value: 'NoneType' object has no attribute '__getitem__'
>>>
>>>  --
>>> 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...@**googlegroups.com.
>>> To post to this group, send email to django...@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/**CAF1Wu3PHp7FM8yge3YLRQuMFaCw24**
>>> ENzTOuuhYmW54QADXRg%2BA%**40mail.gmail.com
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>
>>  --
> You 

Re: Bug in admin models?

2013-10-24 Thread Derek
Yes, its there - the line after 'suit'.

On Wednesday, 23 October 2013 19:22:54 UTC+2, Odin wrote:
>
> Can't see the django.contrib.admin in INSTALLED_APPS.
>
>
> 2013/10/23 Derek 
>
>> I am trying to add a model entry, via the admin; I get this error (which 
>> has not happened before), running Django on Ubuntu 12.04 with the test 
>> server.  Not sure if there is an error with the model (which has worked 
>> fine up to now) or ...?
>>
>>
>> Request Method: POST
>> Request URL: http://127.0.0.1:8000/admin/myapp/mymodel/add/
>>
>> Django Version: 1.5.4
>> Python Version: 2.7.3
>> Installed Applications:
>> ('django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.staticfiles',
>>  'django.contrib.messages',
>>  'django.contrib.admindocs',
>>  'django_nose',
>>  'django_extensions',
>>  'crispy_forms',
>>  'autocomplete_light',
>>  'admin_enhancer',
>>  'smart_selects',
>>  'selectable',
>>  'massadmin',
>>  's2.myapp,
>>  'suit',
>>  'django.contrib.admin')
>> 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',
>>  's2s.middle.middleware.AdminSessionMiddleware')
>>
>>
>> Traceback:
>> File 
>> "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in 
>> get_response
>>   115. response = callback(request, 
>> *callback_args, **callback_kwargs)
>> File 
>> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in 
>> wrapper
>>   372. return self.admin_site.admin_view(view)(*args, 
>> **kwargs)
>> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
>> in _wrapped_view
>>   91. response = view_func(request, *args, **kwargs)
>> File 
>> "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" 
>> in _wrapped_view_func
>>   89. response = view_func(request, *args, **kwargs)
>> File 
>> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in 
>> inner
>>   202. return view(request, *args, **kwargs)
>> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
>> in _wrapper
>>   25. return bound_func(*args, **kwargs)
>> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
>> in _wrapped_view
>>   91. response = view_func(request, *args, **kwargs)
>> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" 
>> in bound_func
>>   21. return func(self, *args2, **kwargs2)
>> File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in 
>> inner
>>   223. return func(*args, **kwargs)
>> File 
>> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in 
>> add_view
>>   1009. self.log_addition(request, new_object)
>> File 
>> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in 
>> log_addition
>>   530. action_flag = ADDITION
>> File 
>> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/models.py" in 
>> log_action
>>   18. e = self.model(None, None, user_id, content_type_id, 
>> smart_text(object_id), object_repr[:200], action_flag, change_message)
>>
>> Exception Type: TypeError at /admin/myapp/mymodel/add/
>> Exception Value: 'NoneType' object has no attribute '__getitem__'
>>
>>  -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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/CAF1Wu3PHp7FM8yge3YLRQuMFaCw24ENzTOuuhYmW54QADXRg%2BA%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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/350f6701-7c49-4aee-9b4b-df9be42dc964%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Bug in admin models?

2013-10-23 Thread Sandro Dutra
Can't see the django.contrib.admin in INSTALLED_APPS.


2013/10/23 Derek 

> I am trying to add a model entry, via the admin; I get this error (which
> has not happened before), running Django on Ubuntu 12.04 with the test
> server.  Not sure if there is an error with the model (which has worked
> fine up to now) or ...?
>
>
> Request Method: POST
> Request URL: http://127.0.0.1:8000/admin/myapp/mymodel/add/
>
> Django Version: 1.5.4
> Python Version: 2.7.3
> Installed Applications:
> ('django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.staticfiles',
>  'django.contrib.messages',
>  'django.contrib.admindocs',
>  'django_nose',
>  'django_extensions',
>  'crispy_forms',
>  'autocomplete_light',
>  'admin_enhancer',
>  'smart_selects',
>  'selectable',
>  'massadmin',
>  's2.myapp,
>  'suit',
>  'django.contrib.admin')
> 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',
>  's2s.middle.middleware.AdminSessionMiddleware')
>
>
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
> in get_response
>   115. response = callback(request,
> *callback_args, **callback_kwargs)
> File
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in
> wrapper
>   372. return self.admin_site.admin_view(view)(*args,
> **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py"
> in _wrapped_view
>   91. response = view_func(request, *args, **kwargs)
> File
> "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py"
> in _wrapped_view_func
>   89. response = view_func(request, *args, **kwargs)
> File
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in
> inner
>   202. return view(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py"
> in _wrapper
>   25. return bound_func(*args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py"
> in _wrapped_view
>   91. response = view_func(request, *args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py"
> in bound_func
>   21. return func(self, *args2, **kwargs2)
> File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in
> inner
>   223. return func(*args, **kwargs)
> File
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in
> add_view
>   1009. self.log_addition(request, new_object)
> File
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in
> log_addition
>   530. action_flag = ADDITION
> File
> "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/models.py" in
> log_action
>   18. e = self.model(None, None, user_id, content_type_id,
> smart_text(object_id), object_repr[:200], action_flag, change_message)
>
> Exception Type: TypeError at /admin/myapp/mymodel/add/
> Exception Value: 'NoneType' object has no attribute '__getitem__'
>
>  --
> 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/CAF1Wu3PHp7FM8yge3YLRQuMFaCw24ENzTOuuhYmW54QADXRg%2BA%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CAH%2Bpf9m42BHXiNJDyU9T0ZhQZ4%2BqO08e%3DkyjKLmYbp6ZT2gW3A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Bug in admin models?

2013-10-23 Thread Derek
I am trying to add a model entry, via the admin; I get this error (which
has not happened before), running Django on Ubuntu 12.04 with the test
server.  Not sure if there is an error with the model (which has worked
fine up to now) or ...?


Request Method: POST
Request URL: http://127.0.0.1:8000/admin/myapp/mymodel/add/

Django Version: 1.5.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.staticfiles',
 'django.contrib.messages',
 'django.contrib.admindocs',
 'django_nose',
 'django_extensions',
 'crispy_forms',
 'autocomplete_light',
 'admin_enhancer',
 'smart_selects',
 'selectable',
 'massadmin',
 's2.myapp,
 'suit',
 'django.contrib.admin')
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',
 's2s.middle.middleware.AdminSessionMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
in get_response
  115. response = callback(request, *callback_args,
**callback_kwargs)
File
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in
wrapper
  372. return self.admin_site.admin_view(view)(*args,
**kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
_wrapped_view
  91. response = view_func(request, *args, **kwargs)
File
"/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py"
in _wrapped_view_func
  89. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py"
in inner
  202. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
_wrapper
  25. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
_wrapped_view
  91. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
bound_func
  21. return func(self, *args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in
inner
  223. return func(*args, **kwargs)
File
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in
add_view
  1009. self.log_addition(request, new_object)
File
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in
log_addition
  530. action_flag = ADDITION
File
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/models.py" in
log_action
  18. e = self.model(None, None, user_id, content_type_id,
smart_text(object_id), object_repr[:200], action_flag, change_message)

Exception Type: TypeError at /admin/myapp/mymodel/add/
Exception Value: 'NoneType' object has no attribute '__getitem__'

-- 
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/CAF1Wu3PHp7FM8yge3YLRQuMFaCw24ENzTOuuhYmW54QADXRg%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Get request.user outside of [admin|models|views].py

2012-05-13 Thread Alireza Savand
Also i found https://github.com/seveas/django-echelon very usefull
Specially *CurrentUserFiled*
For the information, use shoulda be always authenticated so it's not a case
here!
Thank you

On Sun, May 13, 2012 at 6:27 PM, Rafał Stożek  wrote:

> It is possible using simple middleware and
> http://docs.python.org/library/threading.html#threading.local class. But
> note that code doesn't have to always be called from HTTP - it means that
> you must handle situation where user is not known.
>
> Examples:
> http://djangosnippets.org/snippets/2179/
> https://github.com/Proteus-tech/django-request-local
>
>
> W dniu niedziela, 13 maja 2012 09:59:33 UTC+1 użytkownik Alireza napisał:
>
>> Hi
>>
>> Let me explain it. i developing and app to trace the models activity,
>> hmmm. actualy it's reversioning app for other models. As a reversioning
>> model shoulda store user_id. What i'm trying to do is to connect those
>> models post_save signal to create a reversion on each changes. But i don't
>> want to explicity [expose|pass] the user to it
>> And those model that shoulda be reversioning, don't have any ForeignKey
>> to the auth.User.
>> By The dummy way it can be done in the save_model at admin.py to pass the
>> request.user to it. but then the program will stuck in the admin.py area
>> and it's not a encapsulated way!
>> You know it's all about who make this change.
>> So all stuff shoulda be handle it in the app itself, i mean the
>> reversioning app ;)
>> At the django-reversion they did something similar, that i couldn't get
>> it exactly. As *AeroNotix *says at the #django
>>
>>> see, this is the annoying part about using the auth module
>>
>> Which i'm agree with it.
>>
>> But the topic is not about annoying part about auth module, it's about
>> Access to request.user.
>> And a little bit for tiny solution is can we somehow make request.user
>> widely?
>>
>> Thank you!
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/rKMFkoIPC_UJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
+ +
+
+ 
+
+ + 

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



Re: Get request.user outside of [admin|models|views].py

2012-05-13 Thread Rafał Stożek
It is possible using simple middleware 
and http://docs.python.org/library/threading.html#threading.local 
class. But note that code doesn't have to always be called from HTTP - it 
means that you must handle situation where user is not known.

Examples:
http://djangosnippets.org/snippets/2179/
https://github.com/Proteus-tech/django-request-local


W dniu niedziela, 13 maja 2012 09:59:33 UTC+1 użytkownik Alireza napisał:
>
> Hi
>
> Let me explain it. i developing and app to trace the models activity, 
> hmmm. actualy it's reversioning app for other models. As a reversioning 
> model shoulda store user_id. What i'm trying to do is to connect those 
> models post_save signal to create a reversion on each changes. But i don't 
> want to explicity [expose|pass] the user to it
> And those model that shoulda be reversioning, don't have any ForeignKey to 
> the auth.User.
> By The dummy way it can be done in the save_model at admin.py to pass the 
> request.user to it. but then the program will stuck in the admin.py area 
> and it's not a encapsulated way!
> You know it's all about who make this change.
> So all stuff shoulda be handle it in the app itself, i mean the 
> reversioning app ;)
> At the django-reversion they did something similar, that i couldn't get it 
> exactly. As *AeroNotix *says at the #django 
>
>> see, this is the annoying part about using the auth module
>
> Which i'm agree with it.
>
> But the topic is not about annoying part about auth module, it's about 
> Access to request.user.
> And a little bit for tiny solution is can we somehow make request.user 
> widely? 
>
> Thank you! 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rKMFkoIPC_UJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Get request.user outside of [admin|models|views].py

2012-05-13 Thread Alireza Savand
Hi

Let me explain it. i developing and app to trace the models activity, hmmm. 
actualy it's reversioning app for other models. As a reversioning model 
shoulda store user_id. What i'm trying to do is to connect those models 
post_save signal to create a reversion on each changes. But i don't want to 
explicity [expose|pass] the user to it
And those model that shoulda be reversioning, don't have any ForeignKey to 
the auth.User.
By The dummy way it can be done in the save_model at admin.py to pass the 
request.user to it. but then the program will stuck in the admin.py area 
and it's not a encapsulated way!
You know it's all about who make this change.
So all stuff shoulda be handle it in the app itself, i mean the 
reversioning app ;)
At the django-reversion they did something similar, that i couldn't get it 
exactly. As *AeroNotix *says at the #django 

> see, this is the annoying part about using the auth module

Which i'm agree with it.

But the topic is not about annoying part about auth module, it's about 
Access to request.user.
And a little bit for tiny solution is can we somehow make request.user 
widely? 

Thank you! 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Rgni8zC73asJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Need advice on admin models

2012-03-19 Thread django_noob
Hello all, 

I am just starting learning Django and managed to get a basic website 
working with a nice admin section. I am now facing a problem which I am not 
sure how to resolve. 

So I basically have 2 tables in my database: 
- Flat 
- PendingFlat 

The PendingFlat would be a subset of the Flat table. 

The website will offer the ability to a user to sell his flat. The website 
will ask only a few questions to the user such as the price and the 
location and store this information within the PendingFlat table. The admin 
can then go the admin section of the website, view all pending flats from 
the PendingFlat table and approve them as he wish. So I'd like to have an 
approve button next to each line of the records of the PendingFlat table. 
This button should then get the admin to the add view page of the Flat 
table with some prepopulated fields such as the location and the price. 

My first attempt was to do the following in the admin.py file: 
class PendingFlatAdmin(admin.ModelAdmin): 
def button(self, obj): 
return mark_safe('Approve'.format(obj=obj)) 
button.short_description = 'Approve' 
button.allow_tags = True 
list_display = ('id', 'button') 
admin.site.register(PendingFlat, PendingFlatAdmin) 

This will successfully get the admin to the add flat page with the rent 
being prepopulated. Unfortunately, this won't delete the PendingFlat entry 
once the admin has successfully added this flat to the database and it also 
makes it difficult to maintain when new attributes are being added to the 
table. Is there a nice way to achieve this? 

I understand that my choice of database structure might be wrong. It might 
be better to have a single table Flat which has a pending boolean field. 
But if I do this how can I mark certain felds as being optional (blank = 
True) when the pending field is set to True? 

Thanks, 
a noob who hopes to lose his noob status as soon as possible [image: :)]  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/N_1oRVhzIXEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: weird problem with django admin models and webfaction

2010-02-22 Thread Simon Davies
Duh!!  yeah restarting apache did it.  How did I forget something so
simple!!

Thanks

Simon

On 22 Feb, 15:04, Shawn Milochik  wrote:
> Did you manually restart the Apache instance for this app?
>
> I had a similar problem, and it turned out that I had a bit of code in one of 
> my model that was pulling from a table that was no longer defined. Check for 
> that as well.

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



Re: weird problem with django admin models and webfaction

2010-02-22 Thread Shawn Milochik
Did you manually restart the Apache instance for this app?

I had a similar problem, and it turned out that I had a bit of code in one of 
my model that was pulling from a table that was no longer defined. Check for 
that as well. 

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



weird problem with django admin models and webfaction

2010-02-22 Thread Simon Davies
Hi

I'm still developing my app and I have just refactored my models in my
django app.  I dropped most of the existing tables on my local dev
machine and then completely rebuilt everything using syncdb,
everything worked fine, including the admin, no probs at all.

Then I updated everything on my webfaction account, dropped most of
the tables and ran syncdb.  Then I accessed the admin app.  Problem!!!

Things got really weird here,  its still seeing the old models
somehow, and it falls over when I click on any of the models.  The
errors result from the fact that I updated one of the models so
abstract = True, so it won't exist as a sql table and this is causing
the error:

Caught an exception while rendering: (1146, "Table
'simondav.bikeshop_item' doesn't exist")

Original Traceback (most recent call last):
  File "/home/simondav/webapps/django/lib/python2.5/django/template/
debug.py", line 71, in render_node
result = node.render(context)
  File "/home/simondav/webapps/django/lib/python2.5/django/template/
__init__.py", line 936, in render
dict = func(*args)
  File "/home/simondav/webapps/django/lib/python2.5/django/contrib/
admin/templatetags/admin_list.py", line 253, in result_list
'results': list(results(cl))}
  File "/home/simondav/webapps/django/lib/python2.5/django/contrib/
admin/templatetags/admin_list.py", line 247, in results
for res in cl.result_list:
  File "/home/simondav/webapps/django/lib/python2.5/django/db/models/
query.py", line 106, in _result_iter
self._fill_cache()
  File "/home/simondav/webapps/django/lib/python2.5/django/db/models/
query.py", line 692, in _fill_cache
self._result_cache.append(self._iter.next())
  File "/home/simondav/webapps/django/lib/python2.5/django/db/models/
query.py", line 238, in iterator
for row in self.query.results_iter():
  File "/home/simondav/webapps/django/lib/python2.5/django/db/models/
sql/query.py", line 287, in results_iter
for rows in self.execute_sql(MULTI):
  File "/home/simondav/webapps/django/lib/python2.5/django/db/models/
sql/query.py", line 2369, in execute_sql
cursor.execute(sql, params)
  File "/home/simondav/webapps/django/lib/python2.5/django/db/backends/
util.py", line 19, in execute
return self.cursor.execute(sql, params)
  File "/home/simondav/webapps/django/lib/python2.5/django/db/backends/
mysql/base.py", line 84, in execute
return self.cursor.execute(query, args)
  File "/usr/local/lib/python2.5/site-packages/MySQLdb/cursors.py",
line 166, in execute
self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.5/site-packages/MySQLdb/
connections.py", line 35, in defaulterrorhandler
raise errorclass, errorvalue
ProgrammingError: (1146, "Table 'simondav.bikeshop_item' doesn't
exist")

which is correct in that the definition shouldn't exist in the
database any longer, but where is admin getting the model definition
from??

Both the models.py and admin.py files have been updated correctly, I
have completely trashed and rebuilt the whole database, yet it still
seems to be getting these ghost definitions on the webfaction server
somehow,  everything still works fine locally, so I'm puzzled.  Could
it be some kind of cache issue?, but surely anything would have been
deleted when I trashed the database.

Puzzled!!!

Thx in advance

Simon

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



Re: custom permission in admin models

2009-10-06 Thread Bogdan I. Bursuc

Ok, I think your answer is here on creating permissions:
http://docs.djangoproject.com/en/dev/topics/auth/#id1
in the ModelAdmin, override the `save_model` method and check the
current user permission:
request.user.has_perm('permission_name')
for more on checking permission see this:
http://docs.djangoproject.com/en/dev/topics/auth/

On Tue, 2009-10-06 at 01:21 -0700, elminio wrote:
> not exactly,
> for example I want to make custom permission which enables user to
> change one field in model but only to 5 letter length word while other
> users may change that field to 6 letters length word. Thats sily
> example but in some cases it may be useful.
> 
> 
> On Oct 6, 10:19 am, "Bogdan I. Bursuc" 
> wrote:
> > i think you want to create a group.
> >
> > On Tue, 2009-10-06 at 01:05 -0700, elminio wrote:
> > > Hi,
> > > In admin Panel I can choose groups and give them specified
> > > permissions. For example
> >
> > > admin | log entry | can add log entry
> >
> > > And I would like to create my own type of permission which for example
> > > is called all and gives to the specified user permission to do
> > > whatever he likes, and other permission moderator which gives for
> > > example only half. What I mean is there any way to write custom
> > > permission types.
> >
> > > thanks for response
> >
> >
> > 


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



Re: custom permission in admin models

2009-10-06 Thread elminio

not exactly,
for example I want to make custom permission which enables user to
change one field in model but only to 5 letter length word while other
users may change that field to 6 letters length word. Thats sily
example but in some cases it may be useful.


On Oct 6, 10:19 am, "Bogdan I. Bursuc" 
wrote:
> i think you want to create a group.
>
> On Tue, 2009-10-06 at 01:05 -0700, elminio wrote:
> > Hi,
> > In admin Panel I can choose groups and give them specified
> > permissions. For example
>
> > admin | log entry | can add log entry
>
> > And I would like to create my own type of permission which for example
> > is called all and gives to the specified user permission to do
> > whatever he likes, and other permission moderator which gives for
> > example only half. What I mean is there any way to write custom
> > permission types.
>
> > thanks for response
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: custom permission in admin models

2009-10-06 Thread Bogdan I. Bursuc

i think you want to create a group.

On Tue, 2009-10-06 at 01:05 -0700, elminio wrote:
> Hi,
> In admin Panel I can choose groups and give them specified
> permissions. For example
> 
> admin | log entry | can add log entry
> 
> And I would like to create my own type of permission which for example
> is called all and gives to the specified user permission to do
> whatever he likes, and other permission moderator which gives for
> example only half. What I mean is there any way to write custom
> permission types.
> 
> thanks for response
> > 


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



custom permission in admin models

2009-10-06 Thread elminio

Hi,
In admin Panel I can choose groups and give them specified
permissions. For example

admin | log entry | can add log entry

And I would like to create my own type of permission which for example
is called all and gives to the specified user permission to do
whatever he likes, and other permission moderator which gives for
example only half. What I mean is there any way to write custom
permission types.

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



Re: Converting .96 to 1.0 How to admin models?

2008-09-26 Thread Lance F. Squire



On Sep 26, 1:53 pm, bruno desthuilliers
<[EMAIL PROTECTED]> wrote:
>
> # relative import is simpler and safer
> import models
>
> # using introspection
> from django.db.models import Model
> for name in dir(models):
> obj = getattr(models, name)
> if obj is not Model and issubclass(obj, Model):
>try:
> admin.site.register(obj)
>except AlreadyRegistred:
>  # XXX : not sure about this is the exact exception type,
>  # but you should be able to find this out easily
>  pass
>

Got this error trying that...

issubclass() arg 1 must be a class

> > b.t.w. I presume the
>
> > class Admin:
> > pass
>
> > in the Models.py is useless now...
>
> Definitevely. And that's a GoodThing(tm), since it has nothing to do
> in the models.

I can understand why, but is seems like we've made more work from
something that was simple.

Though I suspect the admin.py can now do way more to modify the admin
than previously.

Lance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Converting .96 to 1.0 How to admin models?

2008-09-26 Thread bruno desthuilliers

On 26 sep, 18:07, "Lance F. Squire" <[EMAIL PROTECTED]> wrote:
> Converting a .96 site I was working on to the 1.0 set-up.
>
> Is there a quick way to list all my models in the admin?
>
> Or do I have to :
>
> from HCVGM.systems.models import System
>
> admin.site.register(System)
>
> for every one?

# relative import is simpler and safer
import models

# using introspection
from django.db.models import Model
for name in dir(models):
obj = getattr(models, name)
if obj is not Model and issubclass(obj, Model):
   try:
admin.site.register(obj)
   except AlreadyRegistred:
 # XXX : not sure about this is the exact exception type,
 # but you should be able to find this out easily
 pass


> b.t.w. I presume the
>
> class Admin:
> pass
>
> in the Models.py is useless now...

Definitevely. And that's a GoodThing(tm), since it has nothing to do
in the models.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Converting .96 to 1.0 How to admin models?

2008-09-26 Thread Lance F. Squire

Converting a .96 site I was working on to the 1.0 set-up.

Is there a quick way to list all my models in the admin?

Or do I have to :

from HCVGM.systems.models import System

admin.site.register(System)

for every one?

b.t.w. I presume the

class Admin:
pass

in the Models.py is useless now...

Lance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Admin & Models

2007-08-02 Thread Rohit

Thanks Nathan. I think this solves one part of my problem. Also just
for reference, the method should be modified as so:

def company(self):
  return self.sub_dept.dept.company

and so on. The exclusion of self, leads Django to look for a global
named "sub_dept".

Any idea how I can add company to 'list_filter'?



On Aug 2, 10:27 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
> list_display can use functions as their value... so, you can have:
>
> class Employee(models.Model):
>   sub_dept = ForeignKey(SubDept)
>
>   def company(self):
> return sub_dept.dept.company
>
>   def dept(self):
> return sub_dept.dept
>
>   class Admin:
> list_display = ('first_name, 'last_name', 'company', 'dept',
> 'sub_dept')
>
> On Aug 1, 3:16 pm, Rohit <[EMAIL PROTECTED]> wrote:
>
> > Actually my question is two fold, most likely due to brain farts on my
> > end. I'm relatively a newbie to Django, so please bear with me.
>
> > Here's my scenario. I have this for my relationships:
> > Company->Dept->Sub-Dept->Employees->Roles
> > "->" represents a one-to-many relationship.
>
> > Problem #1:
>
> > If I do something like this:
> > Class Company(models.Model):
> >  name...
>
> > Class Dept(models.Model):
> > company = ForeignKey(Company)
> > name...
>
> > Class Sub-Dept(models.Model):
> > dept = ForeignKey(Dept)
> > name...
>
> > Class Employee(models.Model):
> > sub-dept = ForeignKey(Sub-Dept)
> > first_name...
>
> > Class Admin:
> > list_display = ( 'first_name', 'last_name', 'sub-dept', )
>
> > The problem is when I go into the admin screen and view employees,
> > there is no way of displaying the company and dept. info next to the
> > name of the employee. How can I accomplish that?
>
> > Problem #2:
> > This kinda arises from my efforts trying to fix Problem #1.
>
> > I changed my code like so:
>
> > .
> > .
> > Class Employee(models.Model):
> > company = ForeignKey(Company)
> > dept= ForeignKey(Dept)
> > sub-dept  = ForeignKey(Sub-Dept)
> > first_name...
>
> > Class Admin:
> > list_display = ( 'first_name', 'last_name', 'company', 'dept',
> > 'sub-dept', )
>
> > Now the problem is when I add an employee, I have to add some kind of
> > validation to the admin interface that checks whether the sub-dept,
> > dept and company match. My main issue is where can I add this
> > validation so that it is reflected in the admin interface?
>
> > Thanks in advance for the pointers.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Admin & Models

2007-08-02 Thread Nis Jørgensen

Nathan Ostgard skrev:
> list_display can use functions as their value... so, you can have:
>
> class Employee(models.Model):
>   sub_dept = ForeignKey(SubDept)
>
>   def company(self):
> return sub_dept.dept.company
>
>   def dept(self):
> return sub_dept.dept
>
>   class Admin:
> list_display = ('first_name, 'last_name', 'company', 'dept',
> 'sub_dept')
>   

My guess is that the poster wanted this info available on the page for
an individual employee, not the list. At least that is what I need (and
haven't found an easy way of doing).

Nis

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Admin & Models

2007-08-02 Thread Nathan Ostgard

list_display can use functions as their value... so, you can have:

class Employee(models.Model):
  sub_dept = ForeignKey(SubDept)

  def company(self):
return sub_dept.dept.company

  def dept(self):
return sub_dept.dept

  class Admin:
list_display = ('first_name, 'last_name', 'company', 'dept',
'sub_dept')


On Aug 1, 3:16 pm, Rohit <[EMAIL PROTECTED]> wrote:
> Actually my question is two fold, most likely due to brain farts on my
> end. I'm relatively a newbie to Django, so please bear with me.
>
> Here's my scenario. I have this for my relationships:
> Company->Dept->Sub-Dept->Employees->Roles
> "->" represents a one-to-many relationship.
>
> Problem #1:
>
> If I do something like this:
> Class Company(models.Model):
>  name...
>
> Class Dept(models.Model):
> company = ForeignKey(Company)
> name...
>
> Class Sub-Dept(models.Model):
> dept = ForeignKey(Dept)
> name...
>
> Class Employee(models.Model):
> sub-dept = ForeignKey(Sub-Dept)
> first_name...
>
> Class Admin:
> list_display = ( 'first_name', 'last_name', 'sub-dept', )
>
> The problem is when I go into the admin screen and view employees,
> there is no way of displaying the company and dept. info next to the
> name of the employee. How can I accomplish that?
>
> Problem #2:
> This kinda arises from my efforts trying to fix Problem #1.
>
> I changed my code like so:
>
> .
> .
> Class Employee(models.Model):
> company = ForeignKey(Company)
> dept= ForeignKey(Dept)
> sub-dept  = ForeignKey(Sub-Dept)
> first_name...
>
> Class Admin:
> list_display = ( 'first_name', 'last_name', 'company', 'dept',
> 'sub-dept', )
>
> Now the problem is when I add an employee, I have to add some kind of
> validation to the admin interface that checks whether the sub-dept,
> dept and company match. My main issue is where can I add this
> validation so that it is reflected in the admin interface?
>
> Thanks in advance for the pointers.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---



Admin & Models

2007-08-01 Thread Rohit

Actually my question is two fold, most likely due to brain farts on my
end. I'm relatively a newbie to Django, so please bear with me.

Here's my scenario. I have this for my relationships:
Company->Dept->Sub-Dept->Employees->Roles
"->" represents a one-to-many relationship.

Problem #1:

If I do something like this:
Class Company(models.Model):
 name...

Class Dept(models.Model):
company = ForeignKey(Company)
name...

Class Sub-Dept(models.Model):
dept = ForeignKey(Dept)
name...

Class Employee(models.Model):
sub-dept = ForeignKey(Sub-Dept)
first_name...

Class Admin:
list_display = ( 'first_name', 'last_name', 'sub-dept', )

The problem is when I go into the admin screen and view employees,
there is no way of displaying the company and dept. info next to the
name of the employee. How can I accomplish that?

Problem #2:
This kinda arises from my efforts trying to fix Problem #1.

I changed my code like so:

.
.
Class Employee(models.Model):
company = ForeignKey(Company)
dept= ForeignKey(Dept)
sub-dept  = ForeignKey(Sub-Dept)
first_name...

Class Admin:
list_display = ( 'first_name', 'last_name', 'company', 'dept',
'sub-dept', )

Now the problem is when I add an employee, I have to add some kind of
validation to the admin interface that checks whether the sub-dept,
dept and company match. My main issue is where can I add this
validation so that it is reflected in the admin interface?

Thanks in advance for the pointers.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~--~~~~--~~--~--~---