Re: Multi table inheritance and reverse lookup

2009-09-25 Thread Bogdan I. Bursuc
Don't know if this is the solution for you, but you could take a look here: http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1 and do something like this: class Product(models.Model): name = models.CharField(max_length=64) class Meta: abst

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 exampl

Re: custom permission in admin models

2009-10-06 Thread Bogdan I. Bursuc
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 w

Re: Getting model's ID in save() method

2009-10-06 Thread Bogdan I. Bursuc
You could do something like this: def save(self, force_insert=False, force_update=False): # first save the model using the base class save method super(MyModel, self).save(force_insert, force_update) # then self will have an id set v = self.id On Tue, 2009-10-06 at

Re: Add some fields on form.save()

2009-10-07 Thread Bogdan I. Bursuc
If you want to set the status field on the model after you save the form, you can do something like this: msg_instance = form.save(commit=False) msg_instance.status = 'F' msg_instance.save() # don't forget the save, because the form didn't # save the model On Wed, 2009-10-

Re: ModelForm

2009-10-08 Thread Bogdan I. Bursuc
I think we need a little more info here, post your urls.py that contain mostro_permesso url and your view that is linked to that url. On Thu, 2009-10-08 at 00:04 -0700, luca72 wrote: > Hello this is my model: > from django.db import models > > > class Per(models.Model): > dip = models.CharF

Re: ModelForm

2009-10-08 Thread Bogdan I. Bursuc
.urls.defaults import * > from django.contrib import admin > admin.autodiscover() > > > urlpatterns = patterns('', > (r'^admin/', include(admin.site.urls)), > (r'^mostro_permesso/', 'rm.remi.views.mostro_permesso'), > ) > > &g

Re: ModelForm

2009-10-08 Thread Bogdan I. Bursuc
uot;> > http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> > > {{titolo}} > > > > > {{form.as_table}} > > > > > > > Luca > > On 8 Ott, 10:33, "Bogdan I. Bursuc"

Re: Overriding the default field types

2009-10-08 Thread Bogdan I. Bursuc
Yes is simple: just add the field to the form and will override the model one: class PerForm(ModelForm): dri = forms.CharField(max_length=100, widget=forms.HiddenInput()) class Meta: model = Per You should check the docs on the Widgets to make sure: http://docs.djan

Re: Overriding the default field types

2009-10-08 Thread Bogdan I. Bursuc
You want the field hidden or not on the form at all ? if you want it out of the form user exlude = ('dri',) on Meta but type exclude with a 'd' :) On Thu, 2009-10-08 at 07:14 -0700, luca72 wrote: > I have try it but the field dri is show in the form > > Luca > > On 8 Ott, 16:06, "Mark (Nosred

Re: accessing dictionry values in templates

2009-10-09 Thread Bogdan I. Bursuc
Why don't you set the value directly from the view functions ? return render_to_response('index.html', {'val': dict[msg.status]}) On Thu, 2009-10-08 at 23:51 -0700, valler wrote: > How can i use dictionary values in example below? > > def index(request): > msg = Msg.objects.all() > dict =

Re: Quick syntax query - translating a piece of API code for use in a django view

2009-10-09 Thread Bogdan I. Bursuc
You forgot a ")" sign. That's why syntax error. On Thu, 2009-10-08 at 23:48 -0700, Eva Hamilton wrote: > >From the django documentation (here: > >http://www.djangoproject.com/documentation/models/select_related/) > I obtained this bit of code for performing a select_related on a list > of object

Re: accessing dictionry values in templates

2009-10-09 Thread Bogdan I. Bursuc
I, see. Don't know an alternative. Don't know if it's possible. You may consider creating a tag or a filter for this job. That will result in a clean, pretty solution. On Fri, 2009-10-09 at 00:28 -0700, valler wrote: > On Oct 9, 11:14 am, "Bogdan I. Bursuc" > w

Re: Quick syntax query - translating a piece of API code for use in a django view

2009-10-09 Thread Bogdan I. Bursuc
a typo in the post - but not present in the actual > code. > > It should have read... > > world = Species.objects.all.select_related() > family_list = [o.genus.family for o in world] > > Or is there another missing ")" that I'm not seeing? > > Thank y

Re: accessing dictionry values in templates

2009-10-09 Thread Bogdan I. Bursuc
It can be improved. My suggestion is to use lower_underscored for methods names and you can do something like this: delete the method in your model because django models allready provides a method for your choice fields: get_field_display() for your field would be:

Re: Quick syntax query - translating a piece of API code for use in a django view

2009-10-09 Thread Bogdan I. Bursuc
I know the shell and view are the same i meant the view and the template are different, you didn't specify the brackets after the all method like: all(), this because your might be used with the template syntax, I made this mistake, too. That why i was telling you about the difference between view

Re: new permission

2009-10-09 Thread Bogdan I. Bursuc
Try to delete the auth_permissions table the sync db see if it helps On Fri, 2009-10-09 at 01:29 -0700, elminio wrote: > Up Up > > On Oct 8, 12:10 pm, elminio wrote: > > Hi, > > I've extended my model with new permission. > > > > class Meta: > > permissions = ( > > ("total

Re: Cannot import other model

2009-10-09 Thread Bogdan I. Bursuc
from shcbelpa.season.models import Game This is the line of code that generates the error right? Is myapp = shcbelpa ? On Fri, 2009-10-09 at 10:39 +0200, Christian Wittwer wrote: > Hi, > I have a strange problem with importing models from an other app. > > /myapp/season/models.py > ---

Re: Selecting multiple models in the UI, each needs to have unique "order"

2009-10-20 Thread Bogdan I. Bursuc
chefsmart wrote: > I have a particular scenario that I can't seem to figure out how to > accomplish in Django. > > I have the following models: - > > class Process(models.Model): > name = models.CharField(max_length=50) > is_active = models.BooleanField(db_index=True) > > class Phase(model

Re: Selecting multiple models in the UI, each needs to have unique "order"

2009-10-20 Thread Bogdan I. Bursuc
their > respective orders in a single "screen/page"? The way I see it, I would > use a ModelMultipleChoiceField to allow the user to select all the > phases that they want. But how do I allow the user to specify the > order of each selected phase in the same "screen/