validate fields in the admin as some local flavor form fields

2008-11-17 Thread TeenSpirit83

I'm writing an app with some italian zip and vat number fields and
also a province select field
can i force the admin class to validate the fields like
class it.forms.ITVatNumberField
class it.forms.ITZipCodeField
class it.forms.ITProvinceSelect
??
--~--~-~--~~~---~--~~
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: validate fields in the admin as some local flavor form fields

2008-11-19 Thread TeenSpirit83

no answers!
i think there's no solution :(
how can i create my validation rules for those fields?

On 18 Nov, 01:00, TeenSpirit83 <[EMAIL PROTECTED]> wrote:
> I'm writing an app with some italian zip and vat number fields and
> also a province select field
> can i force the admin class to validate the fields like
> class it.forms.ITVatNumberField
> class it.forms.ITZipCodeField
> class it.forms.ITProvinceSelect
> ??
--~--~-~--~~~---~--~~
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: validate fields in the admin as some local flavor form fields

2008-11-24 Thread TeenSpirit83

Yes, I think we should isolate the condition to he interested field
without touching every other.
So could it be
if db_field == cuit
??

thanks ramiro ;)


On 20 Nov, 00:01, "Ramiro Morales" <[EMAIL PROTECTED]> wrote:

> The condition in line 16 can (and in fact should) be made more
> specific to include the name
> of the field.
>

--~--~-~--~~~---~--~~
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] can i use both a ModelAdmin and an Inline for the same model class? How?

2009-01-21 Thread TeenSpirit83

I'm developing a little webapp starting from the contrib.admin
at the moment i manage a class in the model with a modeladmin class
but i need to edit the entries as a tabular inline of another class.
if i write both the inline and the modeladmin classes in admin.py and
try to register them both, django raises an error on the second
registrarion instruction sayoing the mode class is already registered.
is there a solution?
thanks
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



'module' object has no attribute 'TabularInLine' Attribute Error in Django 1

2008-09-11 Thread TeenSpirit83

I'm trying to upgrade my skills from django 096 to 1.0 so I started a
new app and tried to create an admin class for a class within its
model.
I got the error I specified in the subject. I paste down the
traceback .Can you help me?

Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.0-final-SVN-unknown
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'retailcenter.publicsite']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.locale.LocaleMiddleware')


Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in
get_response
  77. request.path_info)
File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py" in
resolve
  178. for pattern in self.urlconf_module.urlpatterns:
File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py" in
_get_urlconf_module
  197. self._urlconf_module =
__import__(self.urlconf_name, {}, {}, [''])
File "C:\Django-1.0\retailcenter\..\retailcenter\urls.py" in 
  5. admin.autodiscover()
File "C:\Python25\Lib\site-packages\django\contrib\admin\__init__.py"
in autodiscover
  40. __import__("%s.admin" % app)
File "C:\Django-1.0\retailcenter\publicsite\admin.py" in 
  22. class DocumentoInLine(admin.TabularInLine):

Exception Type: AttributeError at /admin/
Exception Value: 'module' object has no attribute 'TabularInLine'

--~--~-~--~~~---~--~~
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: 'module' object has no attribute 'TabularInLine' Attribute Error in Django 1

2008-09-11 Thread TeenSpirit83

>
> The L in Inline should not be capitalized.  Is it in some doc you are
> working from?
>
> Karen

The docs are correct!
I'm so dumb, it is the first time I notice the L is not capitalized!
I was sure of the opposite!
Thanks a lot Karen!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



IndexError (list index out of range) in admin when updating a regex char primary key

2009-03-26 Thread TeenSpirit83

I can't find nothing similar on this group! Can you please help me?
I get this error trace in the django 1.0.2 admin when updating a char
primary key in a regex field.
Thank you in advance!

Environment:

Request Method: POST
Request URL: http://localhost/admin/webamf/azienda/04573030659/
Django Version: 1.0.2 final
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.databrowse',
 'django.contrib.flatpages',
 'retailcenter.webamf']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.cache.UpdateCacheMiddleware',
 'django.middleware.cache.FetchFromCacheMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')


Traceback:
File "C:\Django-1.0.2\django\core\handlers\base.py" in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Django-1.0.2\django\contrib\admin\sites.py" in root
  157. return self.model_page(request, *url.split('/',
2))
File "C:\Django-1.0.2\django\views\decorators\cache.py" in
_wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "C:\Django-1.0.2\django\contrib\admin\sites.py" in model_page
  176. return admin_obj(request, rest_of_url)
File "C:\Django-1.0.2\django\contrib\admin\options.py" in __call__
  199. return self.change_view(request, unquote(url))
File "C:\Django-1.0.2\django\db\transaction.py" in _commit_on_success
  238. res = func(*args, **kw)
File "C:\Django-1.0.2\django\contrib\admin\options.py" in change_view
  578.   instance=new_object)
File "C:\Django-1.0.2\django\forms\models.py" in __init__
  468. queryset=qs)
File "C:\Django-1.0.2\django\forms\models.py" in __init__
  352. super(BaseModelFormSet, self).__init__(**defaults)
File "C:\Django-1.0.2\django\forms\formsets.py" in __init__
  67. self._construct_forms()
File "C:\Django-1.0.2\django\forms\models.py" in _construct_forms
  474. super(BaseInlineFormSet, self)._construct_forms()
File "C:\Django-1.0.2\django\forms\formsets.py" in _construct_forms
  76. self.forms.append(self._construct_form(i))
File "C:\Django-1.0.2\django\forms\models.py" in _construct_form
  477. form = super(BaseInlineFormSet, self)._construct_form
(i, **kwargs)
File "C:\Django-1.0.2\django\forms\models.py" in _construct_form
  356. kwargs['instance'] = self.get_queryset()[i]
File "C:\Django-1.0.2\django\db\models\query.py" in __getitem__
  221. return self._result_cache[k]

Exception Type: IndexError at /admin/webamf/azienda/04573030659/
Exception Value: list index out of range


this is the code of my admin class

class MyAziendaAdminForm(ModelForm):
partitaiva = forms.RegexField(regex=r'^(\d{11})$')
#ragionesociale = forms.CharField(max_length=50)
class Meta:
model = Azienda

def clean_partitaiva(self):
value=self.cleaned_data["partitaiva"]
try:
vat_number = int(value)
except ValueError:
raise ValidationError('Partiva IVA non valida')
vat_number = str(vat_number).zfill(11)
check_digit = vat_number_check_digit(vat_number[0:10])
if not vat_number[10] == check_digit:
raise ValidationError('Partita IVA non valida')
return value


and this is the code for the model

class Azienda(models.Model):
partitaiva=models.CharField("Partita IVA", max_length=11,
primary_key=True)
ragionesociale=models.CharField("Ragione Sociale", max_length=50)
riferimento=models.CharField
(max_length=30,db_column='riferimento',verbose_name='Persona di
riferimento',null=True,blank=True)
note=models.CharField
(max_length=30,db_column='note',null=True,blank=True)

def __unicode__(self):
return u'%s' % (self.ragionesociale)

class Meta:
verbose_name = "Azienda Cliente"
verbose_name_plural = "Aziende Clienti"
ordering = ['ragionesociale']
--~--~-~--~~~---~--~~
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: IndexError (list index out of range) in admin when updating a regex char primary key

2009-03-29 Thread TeenSpirit83

Karen you're always a big help for me on django. Thank you so much!
I was imaging the same thing you explained about problems with the
objects pointing to the key i want to change.
So I was thinking to create a new counter primary key for that model
and turn the current primary key into a simple unique attribute.
But I posted this thread hoping there could be some error and some
solution without the need to change the model.
I think this is what I'm gonna do.

On 26 Mar, 20:57, Karen Tracey  wrote:
> On Thu, Mar 26, 2009 at 7:06 AM, TeenSpirit83
> wrote:
>
>
>
> > I can't find nothing similar on this group! Can you please help me?
> > I get this error trace in the django 1.0.2 admin when updating a char
> > primary key in a regex field.
> > Thank you in advance!
>
> I think there's a bit more going on here than you actually describe.  Based
> on the traceback, you are dealing with an admin page that contains an inline
> formset, and you don't mention that at all.  I've recreated what you are
> describing with a couple of simplified models and admin defs:
>
> # models.py
> from django.db import models
>
> class ExplicitPK(models.Model):
>     expk = models.CharField(max_length=24, primary_key=True)
>
>     def __unicode__(self):
>         return self.expk
>
> class AssociatedThing(models.Model):
>     name = models.CharField(max_length=8)
>     expk = models.ForeignKey(ExplicitPK)
>
>     def __unicode__(self):
>         return u'%s associated with %s' % (self.name, self.expk)
>
> # admin.py
> from django.contrib import admin
> from expk.models import ExplicitPK, AssociatedThing
>
> class AssocInline(admin.TabularInline):
>     model = AssociatedThing
>
> class ExplicitPKAdmin(admin.ModelAdmin):
>     inlines = [AssocInline]
>
> admin.site.register(ExplicitPK, ExplicitPKAdmin)
>
> If I now go into admin and create an ExplicitPK object with the primary key
> 'First', and  a couple of AssociatedThing objects inline, all is well.  If,
> however, I then try to change the 'expk' field value from 'First' to
> 'Second', and select 'Save', I get a traceback similar to what you report
> (slightly different because I'm running with trunk code, not 1.0.2).
>
> The reason, I think, has to do with the fact that the POST data for the
> admin page with inlines contains information for the (in the case I tested
> 2) related objects that point to 'First', but after I change the primary key
> value to 'Second', a queryset of AssociatedThing objects that point to
> 'Second' returns 0 results.  The admin tries to create a formset using a
> queryset that specifies the new pk value, but the objects in that queryset
> don't match up to the POST data in the request. This mismatch results in the
> the formset creation code causing list index out of range when trying to
> match up the POST data with a non-existent matching objects in the queryset
> of AssociatedThings related to 'Second'.
>
> Now, the admin (or maybe it's basic formset) creation code might should
> handle this more gracefully, when the POST data doesn't match the actual
> queryset (and there's at least one ticket open on that issue, since it also
> surfaces when ordering differs from call to call), but I'm not sure even if
> it did that you'd be getting the results you are expecting.  What do you
> expect to happen when you change the primary key of an object?
>
> What does happen is that an entirely new object is created.  The primary key
> value of the existing database row is not changed.  That's just how the ORM
> works, I believe.  When you change the primary key value in the in-memory
> model object, the ORM has no way, so far as I know, to know that the primary
> key value used to be something else.  So when the object is saved, you just
> wind up creating a new object (assuming you pick a primary key value that
> doesn't already exist in the table), because the ORM has no way of knowing
> that this in-memory model object used to refer to a database row that has a
> different primary key value.
>
> If this is not what you were expecting, you might want to re-think having
> your models declare an explicit primary key, particularly if you are
> expecting to allow changing the values.
>
> Karen
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



button for filtering changelist based on callable

2009-12-30 Thread TeenSpirit83
Hi,
I have a callable "" which calculates a value for every object in
a model "XX".
I want to add a tool button on the changelist for XX that filters the
list showing only the objects having this  value less than 30.
How would you implement such a stuff?
Thanks

--

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.




button for filtering the admin changelist based on callable

2009-12-30 Thread TeenSpirit83
Hi,
I have a  callable in the modeladmin for an object XX.
Now I want to add a tool button (or something clickable) for filtering
the changelist displaying only the object having  value less than
30.
How would you implement somthing like this?
Thanks a lot!

--

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.




filtering admin changelist by callable

2010-04-15 Thread TeenSpirit83
Hi,
I have a  callable in the modeladmin for an object XX.
Now I want to add a tool button (or something clickable) for
filtering
the changelist displaying only the object having  value less than
30.
How would you implement somthing like this?
Thanks a lot!

-- 
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.



Admin (when saving): manipulating a parent field based on an inline object's field

2010-05-14 Thread TeenSpirit83
I have a Parent model having some Child objects edited as an inline in
the change view of the Parent.
I want to write some data in a Parent's field which is a calculation
based on some other field of all its Child objects.
I think i have to intercept child data in the save_model or
save_formset methods of ParentAdmin class but I'm not sure which one
of the two I have to modify and what is the way to do it.
How would you do it?

I'd prefer to don't show the Parent's calculated field in the page.
This means I would not include this field in the MyParentAdminForm
class

Thank you!

-- 
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.



custom view in admin

2011-12-07 Thread TeenSpirit83
i'm customizing the django admin with custom views
for a model i need to create a  custom view which is a little
different frome the default changelist
we all know clicking on the records in the default changelist just to
open the object detail page , the django admin calls an url like this
admin/site/model/objectID

so i created a custom changelist-like view and specified its pattern
into the get_urls method so i can call it with
site/model/custompattern
but if i click on the records to open the object detail page django
admin calls an url like this
site/model/custompattern/objectID
the admin goes into ValueError
invalid literal for int() with base 10: 'inattivi/4692'

How can I arrange the url pattern and the view just to make it work
like the original changelist ?

-- 
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.