Re: Q about wizard.form.forms

2013-02-24 Thread Rob Slotboom
Babatunde wrote:

It is satisfied when the step contains a formset



-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Q about wizard.form.forms

2013-02-22 Thread Rob Slotboom
Hi,

Django’s documentation shows a sample form wizard template.
In that template there is a conditional tag: {% if wizard.form.forms %}{% 
else %}
I can’t figure out when this condition will ever by met.

Does sombody have a clue?

Cheers and happy coding,

Rob

  

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




problems getting the development version running on Leopard

2010-01-19 Thread Rob Slotboom
I followed all instructions regarding the intallation of the
development version of Django on Leopard.
I’ve created the symbolic links but I keep getting two error messages:

The first one trying to rum django-admin.py   command not found
The seccond trying to import django in the python shell     No
module named django.core

I can see the symbolic links in finder and the show the content the
should give.

Some time ago I used exactly the same procedure on FreeBSD and all
went fine.

Do I have to something special to get this running on Leopard?

Cheers,

Rob
-- 
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: object and related object on one form (newforms)

2007-10-29 Thread Rob Slotboom

Hi Thomas,

Thank you. I managed to get 2 forms in a view but I dont know how to
provide some 'default' data to some fields in the related form.

I'll give you some code:

class Infocard(models.Model):
   from django.conf import settings
   content_type = models.ForeignKey(ContentType, limit_choices_to =
{'id__in': settings.CARD_ITEMS})
   object_id = models.PositiveIntegerField('item')
   content_object = generic.GenericForeignKey()
   photo = models.ForeignKey(Photo, related_name='infocards',
blank=True, null=True, unique=True)
   text = models.TextField()
   description = models.TextField(maxlength=300)
   tag_field = TagField(verbose_name='Keyword(s)')
   pubdate = models.DateTimeField(auto_now_add=True, editable=False)
   moddate = models.DateTimeField(auto_now=True, editable=False)
   publish = models.BooleanField(default=True)
   author = models.ForeignKey(User, blank=True, null=True)
   allow_comment = models.BooleanField()

class Sectie(models.Model):
   viewname = models.CharField('url', maxlength=50, unique=True,
db_index=True, choices=settings.VIEW_CHOICES,)
   name = models.CharField(maxlength=70, unique=True, db_index=True)
   parent = models.ForeignKey('self', blank=True, null=True,
verbose_name="parent section", related_name='child_set',)
   infocard = generic.GenericRelation(Infocard)

As you can see, I use an infocard to attach extended information to a
section. I can also attach cards to other kind of objects.
While adding, or editing a section I want to provide the form for an
infocard on the same page.

section = get_section_by_viewname_or_none(viewname)
SectionForm = forms.models.form_for_instance(section)
try:
 infocard = section.infocard.all()[0:1].get()
 InfocardForm = forms.models.form_for_instance(infocard)
 except Infocard.DoesNotExist:
 InfocardForm = forms.models.form_for_model(Infocard)

sform = SectionForm()
iform = InfokaartForm()
# and now I lost my way

In above example I expect a section to exist so I'll get it using a
custom function. For the given section I'll call a form.
If the section has a card it is fetched and a form is called.
Otherwise I call an empty form for it.

My question is about the last part, the empty infocard form. Doe you
know how to handle it a field value for the content_type and object_id
of the given section?

Rob


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



object and related object on one form (newforms)

2007-10-28 Thread Rob Slotboom

Can someone please explain to me how to create a form which provides
not only the fields for the object but also the fiels for a related
object (foreign key) and the best method to validate and save the
data?

Thanks in advance,

Rob


--~--~-~--~~~---~--~~
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: pattern question

2007-10-10 Thread Rob Slotboom

Hi Malcolm,

SMART

Thanks
Rob


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



pattern question

2007-10-10 Thread Rob Slotboom

I want to create a pattern to get one or more occurences of, let's
say, slug.

/bla/
/bla/blob/
/bla/blob/blebber/
/bla/blob/blebber/and_a_lot_more
etc.

I get it working for up to two slugs with

('^([^/]+)/([^/]+)/$', 'page'),


def page(request, *slugs):
   slug_list = []
   for slug in slugs:
  slug_list.append(slug)
   return render_to_response('platte_pagina.html', {
  'slug_list' : slug_list,
   }, context_instance=RequestContext(request))


I studied some regex tutorials but I still can't figure out how to fix
repetition in the pattern.


--~--~-~--~~~---~--~~
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: Custom validation for models in admin

2007-10-03 Thread Rob Slotboom

Hi Mike,

I have the same problem with my model. (Link below)
Reading your "points to a .validate() on the model" raises the
following question.
Have you tried it?

http://groups.google.com/group/django-users/browse_thread/thread/bd2b2c24f3879690


--~--~-~--~~~---~--~~
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: Please help with extra validation in admin

2007-10-03 Thread Rob Slotboom

Addition:

> This is my model and I use a custom save to prevent the creation of a
> category with a parent_id which is the same a the current_id (child of
> itself)

When an error occurs an ugly error message apears so I tried to create
a custom validator.
Custom validator didn't work because of "no object_id to check upon".
Creating a Custom manipulator doesn't seem to work in admin.

Can someone show me a solution to get the validation done in admin?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Is there a {% if_less_than %} template tag

2007-10-01 Thread Rob Slotboom

Hi Greg:

Just started using it yesterday :-)

http://code.google.com/p/django-template-utils/


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



Please help with extra validation in admin

2007-10-01 Thread Rob Slotboom

This is my model and I use a custom save to prevent the creation of a
category with a parent_id which is the same a the current_id (child of
itself)

class Category(models.Model):
   name = models.CharField(maxlength=70, unique=True)
   slug = models.SlugField(maxlength=50, unique=True,
prepopulate_from=('naam',))
   parent = models.ForeignKey('self', blank=True, null=True,
limit_choices_to = {'parent__isnull': True})

   def save(self):
  try:
 cur_id = int(self.id)
  except:
 cur_id = None
  if cur_id and self.parent_id:
 if int(self.parent_id) == cur_id:
raise validators.ValidationError("Same parent and child ")
  super(Categorie, self).save()

I tried everything but I can't find a better approach than to use the
save method.
Custom validator: no object_id to check upon.
Custom manipulator: doesn't seem to work in admin.

So I cry for help on this one...


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



Getting an object's meta value

2007-09-18 Thread Rob Slotboom

For a class method I want to use the value of the
Model>Meta>verbose_name.
Can someone tell me how to get this value?

Thanks, Rob


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



parent child question

2007-09-17 Thread Rob Slotboom

class Category(models.Model):
   name = models.CharField(maxlength=70)
   parent = models.ForeignKey('self', blank=True, null=True,
limit_choices_to = {'parent__isnull': True})

I dont want to be able to select a parent which is actualy the
category currently edited.

I tried a custom validator but I dont have access to the category_id.
So I tried a custom manipulator but I couldn't fix it to work in admin
The only possible solution I have now is the raise an error in the
custom save method, which is a terrible ugly solution.

Does anyone have a pointer to a simple method to extend the automatic
manipulator???

Thanks,

Rob


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



best alternative for subclassing

2007-09-13 Thread Rob Slotboom

For a model I need subclassing which is work on progres. Falling back
to a OneToOne approach seems tricky because "the semantics of one-to-
one relationships will be changing soon". I'm wondering now what to
do. Here's my model in the OneToOne approach.

class Cropcat(models.Model):
   parent = models.ForeignKey('self', blank=True, null=True,
related_name='child_set')
   name = models.CharField(maxlength=70)
   slug = models.SlugField(unique=True, prepopulate_from=('name',))
   text = models.TextField()

class Cropdescription(models.Model):
   name = models.CharField(maxlength=70)
   history = models.TextField()
   etc.

class Crop(models.Model):
   cropcat = models.ForeignKey(Cropcat, blank=True, null=True,
limit_choices_to = {'parent__isnull': False})
   cropdescription = models.OneToOneField(Cropdescription)

class Cropvar(models.Model):
   parent = models.ForeignKey(Crop)
   cropdescription = models.OneToOneField(Cropdescription)


As you can see, all common fiels for Crop and Cropvar live in
Cropdescription. Crop has an extra field for Cropcat.  Cropvar has an
extra field for patent which is a Crop.


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



site/section/app

2007-08-29 Thread Rob Slotboom

I'm trying to implement a kind of model but I'm stuck. Maybe someone
outhere can give me some help?

This is what I'm thinking about:

A site can have sections and a section can have apps. Also a site can
have apps.

For example:

Site: gardening.org
app: news
sections: garden/kitchen
garden apps: news/crop/tips
kitchen apps: news/recipes/tips

Site: canoein.org
app: news
sections: workshop/on the water
workshop apps: news/tools/tips
on the water apps: news/events/routes

I know I can create two sites (projects) but I'm thinking about some
database solution: One project and the abillity to add apps to sites
and/or site-sections.


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



menu application

2007-08-24 Thread Rob Slotboom

For a given django site there are many urls.py's. The system also
knows what apps are installed. Wouldn't it be nice to make an app that
uses this knowledge and add some extra functionality to manage a
website menu?

At the moment I have no idea how to implement it but it should be
something website editors can use to organize their menutree (order/
label/etc.) I have seen samples for platpages, generic relations...
but none of these used the systems 'knowledge'.

Maybe we can start a discussion about this?

My thoughts:
A system wide menu app for managing a kind of main menu.
A menu functionality within the apps to manage the submenu's
Making use of installed apps and urls.py's


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



Unicode question

2007-08-20 Thread Rob Slotboom

After moving to the latest version of Django one of the functions I
wrote fails to work.
I'll drop the code...

def year_cal(sectie, req_year = None, req_month=None):
   cur_year= str(datetime.datetime.now().year)
   cur_month= datetime.datetime.now().strftime("%b")
   all_month_list = ['jan', 'feb', 'maa', 'apr', 'mei', 'jun', 'jul',
'aug', 'sep', 'okt', 'nov', 'dec']
   month_list = []
   if req_year is None:
  req_year = cur_year
  req_month= cur_month
   else:
  if int(req_year) > int(cur_year):
 req_year = cur_year
  if req_month is None:
 req_month = trans_month('jan')
  else:
 req_month = trans_month(req_month)

   prev_year_url = sectie.get_absolute_url() + str(int(req_year) - 1)
+ '/' + req_month
   next_year_url = sectie.get_absolute_url() + str(int(req_year) + 1)
+ '/' + req_month

   if int(req_year) == int(cur_year):
  next_year_url = False
  toggle_latest = False
  for month in all_month_list:
 if trans_month(month) == str.lower(req_month):
current = True
 else:
current = False
 if trans_month(month) ==  str.lower(cur_month):
url =  sectie.get_absolute_url() + str(req_year) + '/' +
month
toggle_latest = True
 else:
if(toggle_latest):
   url = False
else:
  url = sectie.get_absolute_url() + str(req_year) + '/' +
month

 month_dict = {
'url' : url,
'caption' : month,
'current' : current,
 }

 month_list.append(month_dict)
   else:
  for month in all_month_list:
 url = sectie.get_absolute_url() + str(req_year) + '/' + month
 if trans_month(month) == str.lower(req_month):
current = True
 else:
current = False
 month_dict = {
'url' : url,
'caption' : month,
'current' : current,
 }

 month_list.append(month_dict)

   return {'prev_year_url': prev_year_url, 'req_year': req_year,
'next_year_url': next_year_url, 'month_list': month_list }

register.inclusion_tag('year_cal.html')(year_cal)


The first error I get is about the line

str.lower(cur_month)

because str expects a str but gets a unicode.

Can some of you please give some simple tricks about moving from str
to unicode?


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



ifchanged

2007-04-03 Thread Rob Slotboom

Within a template I want to use the folowing construction.

  {% for item in object_list reversed %}
 {% ifchanged %}
{% if not forloop.first %}{% endif %}
{{ item.pub_date|
date:"F" }}

 {% endifchanged %}
 {{ item.title }}
 {% if forloop.last %}{% endif %}
  {% endfor %}

It will generate
2007

march
february

2006

december etc

I run in to problems because of the "if" statement within the
ifchanged tag.

Any ideas

Rob


--~--~-~--~~~---~--~~
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: Installation Question

2007-02-12 Thread Rob Slotboom

Also beware that mod_php can give you session troubles on some systems.


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



When to restart Apache?

2007-02-12 Thread Rob Slotboom

When running Django using mod_python you have to restart Apache
whenever you make changes to your code. Some changes don't require a
restart so I wonder which changes trigger mod_python to reload and
which don't.


--~--~-~--~~~---~--~~
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: fiter for week

2007-02-12 Thread Rob Slotboom

For those interested:

### INIT ###

import datetime, time
from django.http import Http404

def trans_month(month):
   """Vertaald de locale maandweergave naar globale"""
   if month == "maa": month = "mar"
   elif month == "mei": month = "may"
   elif month == "okt": month = "oct"

   return month


def get_week_range(year=None, week=None):
   """Geeft de begin en einddatum voor een optioneel meegegeven
week"""
   if year is None:
  year= str(datetime.datetime.now().year)
   if week is None:
  week= datetime.datetime.now().strftime("%W")

   try:
  start_date = datetime.date(*time.strptime(year + '-1-' + week,
'%Y-%w-%W')[:3])
   except ValueError:
  raise Http404
   end_date = start_date + datetime.timedelta(days=7)

   return [ start_date, end_date ]


def get_month_range(year=None, month=None):
   """Geeft de begin en einddatum voor een optioneel meegegeven
week"""
   if year is None:
  year= str(datetime.datetime.now().year)
   if month is None:
  month= datetime.datetime.now().strftime("%b")
   else:
  month = trans_month(month)

   try:
  date = datetime.date(*time.strptime(year+month, '%Y%b')[:3])
   except ValueError:
  raise Http404

   first_day = date.replace(day=1)
   if first_day.month == 12:
  last_day = first_day.replace(year=first_day.year + 1, month=1)
   else:
  last_day = first_day.replace(month=first_day.month + 1)
   return [ first_day, last_day ]

### VIEW ###
def sectie_intro(request, sectie_slug):
   now = datetime.datetime.now()
   sectie = get_sectie_by_slug_or_404(sectie_slug)
   sectie_sjabloon = sectie.get_template()
   sectie_periode = sectie.get_periode()

   berichten_relevant = Bericht.objects.filter(sectie__id__exact =
sectie.id).exclude(publiceren=False).order_by('publicatiedatum')
   if(sectie_periode == 'day'):
  subtitel = "vandaag"
  lookup_kwargs = {
 'publicatiedatum__range' : (datetime.datetime.combine(now,
datetime.time.min), datetime.datetime.combine(now,
datetime.time.max)),
  }
   elif(sectie_periode == 'week'):
  subtitel = "deze week"
  range = get_week_range()
  start_date = range[0]
  end_date = range[1]
  lookup_kwargs = {'publicatiedatum__range': (start_date,
end_date)}
  if end_date >= now.date():
 lookup_kwargs['publicatiedatum__lte'] = now
   elif(sectie_periode == 'month'):
  subtitel = "deze maand"
  lookup_kwargs = {'publicatiedatum__month': now.month,
'publicatiedatum__year' : now.year}
   else:
  subtitel = "dit jaar"
  lookup_kwargs['publicatiedatum__year'] = now.year

   sectie_periodiek = sectie.periodiek_set.filter(**lookup_kwargs)
   berichten_nieuw = berichten_relevant.filter(**lookup_kwargs)
   return render_to_response(sectie_sjabloon, {
  'sectie' : sectie,
  'subtitel' : subtitel, ## voor in sjabloon achter de titel
  'sectie_periodiek' : sectie_periodiek,
  'berichten_nieuw' : berichten_nieuw,
  'kruimelprefix' : '',
  }, context_instance=RequestContext(request))


--~--~-~--~~~---~--~~
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: block.super

2007-02-12 Thread Rob Slotboom

Sorry that isn't working (at least not in my template )



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



Filtering foreign items in admin

2007-02-09 Thread Rob Slotboom

For a several models I use a FK to photos. The drop down in admin to
choose from lists all photos.
Can this list be filtered so I can restrict the available photos for
some 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
-~--~~~~--~~--~--~---



fiter for week

2007-01-30 Thread Rob Slotboom

Before re-inventing, I want to ask if there is some build-in for 
getting objects for [a || this] week.

Something like:

objects.filter(pubdate__week=now.week)


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



block.super

2007-01-29 Thread Rob Slotboom

On my base template I have a block, say X
One level down there is a section template (extending base) 
overwriting block X
Further down there are templates (extending section). On these 
templates I want to be able to get the original value of  X.

I tried
 {{ block.super }}
 {{ block.super.super }}
 {{ block.super.block.super }}
But none of these are doing the right thing. Is there a way to call 
the parents parent blocks?


--~--~-~--~~~---~--~~
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: define odd, even in a loop

2007-01-27 Thread Rob Slotboom

This is working great, thanks!!
While on it, there are more filter like solutions for instance ADD. Is
there also something like DIVIDE, MULTIPLY etc? Or can these be custom
made?


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



define odd, even in a loop

2007-01-26 Thread Rob Slotboom

{% ifequal forloop.counter 1 %}odd{% endifequal %}
{% ifequal forloop.counter 3 %}odd{% endifequal %}
{% ifequal forloop.counter 5 %}odd{% endifequal %}

Is there a way to calculate this kind of thing, something like:
{% ifodd forloop.counter %}I am very odd{% endifodd %}


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



slicing an loops

2007-01-24 Thread Rob Slotboom

Kamil Wdowicz wrote regarding to handling loops:

{% for a in list|slice:"1" %}
{{ something }}
{% endfor %}



{% for a in list|slice:"1:3" %}
{{ something }}
{% endfor %}



{% for a in list|slice:"3:" %}
{{ something }}
{% endfor %}
 

What can be done to fill a table with a given list?


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



ImageField Question

2007-01-22 Thread Rob Slotboom

"Like FileField, but validates that the uploaded object is a valid
image. Has two extra optional arguments, height_field and width_field,
which, if set, will be auto-populated with the height and width of the
image each time a model instance is saved."

So I made this model:

class Foto(models.Model):
   # import os, os.path, Image
   PhotoFile = models.ImageField(upload_to= PH_FOLDER + "/%Y/%m/%d/",
height_field="H", width_field="W")
   titel = models.CharField(maxlength=80)

I tried to get the dimension of the imageobject in my template using
{{ object.W }}
{{ object.width }}
{{ object.width_field }}

Without succes. After adding the fields to the model I got an error
because I had to fill the fields. No auto population!!

How does this work?


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



Custom manipulator, default form?

2007-01-16 Thread Rob Slotboom


For one of my models I need to do some extra validation.
Because of what I want it isn't possible to just rely on a validator, I
need a manipulator to get a request object.

The manipulator only has to add an extra validator to one field. This
validator validates using the database. No custom form is needed. The
manipulator will be used within Django's admin.

I searched and red and searched and red again but I couldn't find an
answer on this one:
How to add a custom manipulator, extending the default one, to a model
using the default form?

--
Robert Slotboom


--~--~-~--~~~---~--~~
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 > custom error message

2007-01-11 Thread Rob Slotboom

Hi James et all,

Because of what I want it isn't possible to just rely on a validator, I
need a manipulator to get a request object.

The manipulator only has to add an extra validator to one field. This
validator validates using the database. No custom form is needed. The
manipulator will be used within Django's admin.

I searched and red and searched and red again but I couldn't find an
answer on this one:
How to add a custom manipulator, extending the default one, to a model
using the default form?

--
Robert Slotboom


--~--~-~--~~~---~--~~
 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: sorting the results of a queryset

2007-01-11 Thread Rob Slotboom

And of course a new kind of sorting function. Thank's to 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-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: sorting the results of a queryset

2007-01-10 Thread Rob Slotboom

Sorted works great but I have problems using it im my custom manager.
I'm trying and trying but I can't figure out how to handle the
following situation.

class SortedTestcatManager(models.Manager):
   def get_query_set(self):
  QS = super(SortedTestcatManager, self).get_query_set()
  SQS = sorted(QS, key=self.model.get_absolute_url)
  return SQS

>> sorted = Testcat.sorted_objects.all()
>> sorted
[]
>> sorted.filte(title="nope")
AttrbuteError: 'list' object has no attribute 'filter'

Because I cant handle my prefered sorting in a query, I need to sort
the result afterward.
I could define some other functions in the custom manager to handle all
and filter
But this isn't a solution:

allcats = Cat.sorted_objects.all()
allcats.filter(var='val') <<

Isn't there a way to grap the result from the QS, sort it and place it
back?


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



sorting the results of a queryset

2007-01-09 Thread Rob Slotboom

My model uses a single table parent-child relationship.
I got the parent representation working but I isn't sorted right.
So I tried to sort the list of objects, returned by objects.all()

in the model class:
   def __cmp__(self, other):
   return cmp(self.get_absolute_url, other.get_absolute_url)

In a function:
   cat_list = []
   for cat in Category.objects.all():
  cat_list.append(cat)
   cat_list.sort()


No errors, no sorting???


--~--~-~--~~~---~--~~
 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 > custom error message

2007-01-09 Thread Rob Slotboom

Hmm,

I wrote this in my models.py. Errors rased are just for debugging.

class HasUniquePath(object):
   def __init__(self, cat_obj, error_message=gettext_lazy("No unique
path!")):
  self.cur_cat = cat_obj
  self.error_message = error_message
  self.always_test = True

   def __call__(self, field_data, all_data):
  if not field_data:
 # check for unique foldername
 folder = all_data.get('folder')
 raise validators.ValidationError("Only a folder %s no path") %
folder
  else:
 parent = field_data
 folder = all_data.get('folder')
 raise validators.ValidationError("A folder %s and a path %s")
% (folder, parent)

class Testcat(models.Model):
   title = models.CharField()
   folder = models.SlugField(prepopulate_from=('title',))
   parent = models.ForeignKey('self', blank=True, null=True,
related_name='child_set', validator_list=[HasUniquePath(self)])

Of course this wil not work because class "HasUniquePath" isn't a
manupulator.
I dont know however how to extend the object's manipulators.

Can yoy please give me a hint?


--~--~-~--~~~---~--~~
 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 > custom error message

2007-01-09 Thread Rob Slotboom

Thanks James,

I'll try this one

def IsUniqueForPath():
...


class Category(models.Model):
...
parent = models.ForeignKey('self', blank=True, null=True,
related_name='child_set', validator_list=[IsUniqueForPath])


--~--~-~--~~~---~--~~
 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 > custom error message

2007-01-09 Thread Rob Slotboom

Hi James,

When I write a custom validator like: isValidCategory() I need a
manipulator, validator and a form. Is there a way to use the 'current'
ones and to expand these or do I need to create them from scratch?


--~--~-~--~~~---~--~~
 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 > custom error message

2007-01-08 Thread Rob Slotboom


Given this save function in one of my models, I want to display an
error message in admin instead of a errorpage.

  def save(self):
 try:
cur_id = int(self.id)
 except:
cur_id = 0
 p_list = self._recurse_for_parents(self)
 cats = Category.objects.filter(folder__exact=self.folder)
 for cat in cats:
catp_list = cat._recurse_for_parents(cat)
if(cat.id != int(cur_id) and p_list == catp_list):
   raise validators.ValidationError("This category already
exists within this path!")
 super(Category, self).save()

Is there a way to do this?


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



special characters in model

2006-12-31 Thread Rob Slotboom


In my model I need a special character for the verbose_name_plural.

I need an ë but admin gives a questionmark.
What do I need to do?

The folowing things don't work.

verbose_name_plural = 'categoriën'
verbose_name_plural = 'categoriën'
verbose_name_plural = 'categori%sn' % chr(235)


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



including a template in itself

2006-12-30 Thread Rob Slotboom


I've a template which will be included. Within the template I want to
include it again if needed.

child_list.html

{% if categorie %}
  {{ categorie.title }}
  {% if categorie.child_set.all %}
 
 {% for categorie in categorie.child_set.all %}
{% include "child_list.html" %}
 {% endfor %}
 
  {% endif %}
{% endif %}

When I do this Django crashes


--~--~-~--~~~---~--~~
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: custom manipulator in admin

2006-12-20 Thread Rob Slotboom


Hello Aidas,


Exactly. You answered your question yourself.


Seems I'm on the right way then :-)

Thanks for anwering, I'll give it a try.

Regards,

Rob


--~--~-~--~~~---~--~~
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: custom manipulator in admin

2006-12-20 Thread Rob Slotboom


On 20 dec, 10:54, "patrick k." <[EMAIL PROTECTED]> wrote:

do it like in any other application:
custom view, custom template, change urls


Hi Patrick,

That's exactely what I wanted to know for one exception.
How to call the custom view when using admin.?
By overriding the 'default' call:

(r'^admin/mine/', include('mysite.admin.urls')),
(r'^admin/', include('django.contrib.admin.urls')),

Rob


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



custom manipulator in admin

2006-12-19 Thread Rob Slotboom


For a model I want to add a custom manipulator which can be used in the
admin.
With this manipulator I want to be able to add an extra formfield for
displaying some additional data from a related object. There is no need
for database storage.

In this group I red that it isn't possible to extend manipulators in
admin so the first question is if it is possible to replace the
'default' manipulator by providing a custom one?

The next question is how to feed the form? From a custom template I
suppose.


Cheers,

Rob


--~--~-~--~~~---~--~~
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: Reverse ForeignKey lookups

2006-12-19 Thread Rob Slotboom

Hi Cathy,

Chris is right. User in entrystatus is a relation to User. This isnt't
the same as a 'normal' field like Name or Title. Look at these:

Entry.objects.filter(blog__id__exact=3) # Explicit form
Entry.objects.filter(blog__id=3) # __exact is implied
Entry.objects.filter(blog__pk=3) # __pk implies __id__exact

This are simple relations from one table to another.
Your filter is spanning three tables acualy
Entry.objects.filter(entrystatus__user=3)  << what about the user,
his/her name, his/her e-mail?

That's why you need to specify some extra argument like firstname,
name, etc or of course id or pk.

Thanks, I learned a lot myself by this question :-)

Rob


--~--~-~--~~~---~--~~
 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: generic relation | contenttypes issue

2006-12-19 Thread Rob Slotboom

Please provide your model. Something is wrong with the tags attribute.

Rob


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



extra field in edit_inline

2006-12-19 Thread Rob Slotboom

This is my model and it works in Admin due to the efforts of Antoni.
(see link at the bottom)
What I want to do is to add a collumn to the inline editing list
representing some field from the related content_object. Is there an
easy way to do this?


class Category(models.Model):
   name = models.CharField(maxlength=20)
   parent = models.ForeignKey('self', blank=True, null=True,
related_name='child_set')

   def __str__(self):
  return self.name

   def get_absolute_url(self):
  return "./%i/" % self.id

   def admin_links(self):
  return 'edit | view | delete' % (self.id, self.get_absolute_url(),
self.id)

   admin_links.allow_tags = True
   admin_links.short_description = 'Actions'

   class Admin:
  pass

class CatItem(models.Model):
   category = models.ForeignKey(Category, edit_inline=models.TABULAR,
num_in_admin=3)
   content_type = models.ForeignKey(ContentType)
   object_id = models.PositiveIntegerField(db_index=True, blank=True,
null=True,core=True,)
   content_object = models.GenericForeignKey()





###
http://net-x.org/weblog/2006/nov/29/django-generic-relations-made-easier/


--~--~-~--~~~---~--~~
 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: OneToOneField and edit_inline

2006-12-18 Thread Rob Slotboom

Maybe we should create some kind of pressure group for this :-)
I don't have any idea who can be consulted for this subject, do you?

Cheers,

Rob


--~--~-~--~~~---~--~~
 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: urls question django_website

2006-12-18 Thread Rob Slotboom

> I still can't figure out however how the flatfiles are loaded?

Or maybe the homepage template from flatfiles is used, without using
the content for the flatpage at all.


--~--~-~--~~~---~--~~
 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: urls question django_website

2006-12-18 Thread Rob Slotboom

> The 'homepage' is a flatpage with an address of '/'.

Hi Kwe,

Great help!!!
I still can't figure out however how the flatfiles are loaded?
For example:
http://code.djangoproject.com/browser/djangoproject.com/django_website/templates/flatfiles/homepage.html


--~--~-~--~~~---~--~~
 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: OneToOneField and edit_inline

2006-12-18 Thread Rob Slotboom

> I'd like to be able to edit Project and News separately with Content inline
> instead. Do you know what i mean?

Hi Dirk,

I get the point though I think this will not work. I've tried similar
things when creating a menu, where a menu "one to oned" to a poll item
or blog entry. I gave up.

In the meanwhile there is a discussion going on about generic
relations, these will solve this kind of problems. Actualy generic
relations already are available..but the do not (yet) work in the
admin (p) Please have a look at djangoproject and search for
generic relations. 

My guess is to sit and wait.


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



urls question django_website

2006-12-18 Thread Rob Slotboom

When I look at the urls.py file belonging to django_website I can't
figure out how the website handles the pattern for
www.djangoproject.com/

The only option seems to be the included flatpages.urls but this one
needs a pattern for an url.

Does anybody have a clue?

Here is the code:

urlpatterns = patterns('',
(r'^weblog/', include('django_website.apps.blog.urls')),
(r'^documentation/', include('django_website.apps.docs.urls')),
(r'^comments/$', 'django.views.generic.list_detail.object_list',
comments_info_dict),
(r'^comments/', include('django.contrib.comments.urls.comments')),
(r'^community/$', 'django.views.generic.list_detail.object_list',
aggregator_info_dict),
(r'^rss/(?P.*)/$', 'django.contrib.syndication.views.feed',
{'feed_dict': feeds}),
(r'^password_reset/',
include('django.conf.urls.admin_password_reset')),
(r'^r/', include('django.conf.urls.shortcut')),
(r'^sitemap.xml$', cache_page(sitemap_views.sitemap, 60 * 60 * 6),
{'sitemaps': sitemaps}),
(r'^admin/', include('django.contrib.admin.urls')),
(r'', include('django.contrib.flatpages.urls')),
)


--~--~-~--~~~---~--~~
 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: Would Django be a good framework for developing and engineering/science application

2006-12-16 Thread Rob Slotboom

> I guess the next thing for me to do is to spend alot of
> time with the documentation and built a couple of simple apps/tutorials
> to flush out my understanding of how Django will work.
>
Hi Thomas,

And don't forget to look at the http://www.djangobook.com/


Rob


--~--~-~--~~~---~--~~
 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: Why does Django think my browser isn't accepting cookies?

2006-12-16 Thread Rob Slotboom

Try to delete your cookies.


--~--~-~--~~~---~--~~
 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: OneToOneField and edit_inline

2006-12-16 Thread Rob Slotboom

Hi Dirk,
I think it's the other way around, try this


class Content(models.Model):
 title = models.CharField('Title', maxlength=255, core=True)
 body  = models.TextField('Body text')

class Admin:
  fields = (
 (None, {'fields': ('title','body',)}),
  )
  list_display = ('title')
  list_filter = ['title']   ## optional
  search_fields = ['title']   ## optional
  date_hierarchy = 'title'   ## optional
  pass

class Project(models.Model):
content  = models.OneToOneField(Content,
edit_inline=models.TABULAR,  num_in_admin=1, core=True,
related_name='project_content')
subtitle = models.CharField('Subtitle', maxlength=255, core=True)
   def __str__(self):
  return self.Subtitle


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



HttpResponseRedirect

2006-12-15 Thread Rob Slotboom

For my project I created a templatetag which handles login, logout, get
profile etc. This way I can show a login/out box on every page by
including the tag in the main template.

There is one problem.

After logging out I want to redirect the user so the cookies etc, are
gone.
This is what I did (without success) because the result is passed over
to the template I suppose

### snippet ###
if current_user.is_authenticated():
  if current_action == "logout":
 try:
del request.session['member_id']
 except KeyError:
pass
 logout(request)
 return HttpResponseRedirect("http://www.google.com";)  << just
to test
  elif current_action == "get_profile":
 .
  elif current_action == "change_password":
 .
### end snip ###

Is there a way to pass the command to the correct handler???


--~--~-~--~~~---~--~~
 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: help with tagging app

2006-12-15 Thread Rob Slotboom

> tagging app from Luke Plant
> zyons
> the tagging app that jay parlar developed

It seems that more and more tagging apps appear while using generic
relations in admin will be available in a future Django. The last few
days I've been strugling to create a menusystem. A kind of tag system
but using a one to one relation. The model is as follows:

Menuitem
   caption
   parent (self may be null)
   linked object

The model and the idea is really very very simple but implementing it
isn't.
Should I wait till Django does support the generic relation in admin?


--~--~-~--~~~---~--~~
 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: GenericForeignKey

2006-12-15 Thread Rob Slotboom

> paulh, take a look at 
> thishttp://net-x.org/weblog/2006/nov/29/django-generic-relations-made-eas...

Hi Antoni,

Seems interesting but the code isn't yet available I suppose...

Rob


--~--~-~--~~~---~--~~
 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: help with tagging app

2006-12-14 Thread Rob Slotboom

> >That's easy.

Hi Timm,

Okay, this is a very simple example :-)
But Luke Plant's Tagging App modell is realy a bit more comple.

See>>

http://groups-beta.google.com/group/django-users/browse_frm/thread/a7cbd4fd843583be/5ef4a59b78dbb2e1?lnk=gst&rnum=1&hl=nl#5ef4a59b78dbb2e1


--~--~-~--~~~---~--~~
 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: alternatives to edit_inline

2006-12-13 Thread Rob Slotboom

Hi Milan,

>  Is there a workaround for that?
Sorry I don't know.

>I'll write my own views.

Maybe you can expand the admin using your own views. Take a look at the
next app for some ideas:

http://trac.dedhost-sil-076.sil.at/trac/filebrowser/wiki

Success.
Rob


--~--~-~--~~~---~--~~
 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: alternatives to edit_inline

2006-12-13 Thread Rob Slotboom

Hi Milan,

>  Is there a workaround for that?
Sorry I don't know.

>I'll write my own views.

Maybe you can expand the admin using your own views. Take a look at the
next app for some ideas:

http://trac.dedhost-sil-076.sil.at/trac/filebrowser/wiki

Success.
Rob


--~--~-~--~~~---~--~~
 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: alternatives to edit_inline

2006-12-12 Thread Rob Slotboom

Maybe this may be of any help. In the model you can add adminlinks like
this:


class Admin:
  fields = (

  )
  list_display = ('name', 'admin_links')

  def admin_links(self):
 return 'edit | view | delete' % (self.id, self.get_absolute_url(),
self.id)

  admin_links.allow_tags = True
  admin_links.short_description = 'Actions'


Mind the indentation :-)


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



help with tagging app

2006-12-12 Thread Rob Slotboom

I installed Luke Plant's Tagging App and started reading the README
file and the comments provided in the source. Compared to the marvelous
Django Book and -tutorial this reading isn't very funny :-)

Has someone a simple example for how to include a tag in another model,
say Poll or Article?
And now I'm on it: can related tags for a given model be used in the
admin app?


--~--~-~--~~~---~--~~
 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: changing values just before saving

2006-12-12 Thread Rob Slotboom

> Your solution seems to be some misunderstanding :)
> If you set a foreign key to ContentType, then it already gets the
> choices from the relation.

Dear Aidas,

I know, I know. The point is that I want to be able to use the damn
generic relation in admin. I abuse the given field to collect real
content items (poll, page etc) in the val:val form. With the selected
value I want to set the appropriate fields using split.

This way it may be possible to create menuitems for the various
content.   

Cheers,

Rob


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



changing values just before saving

2006-12-12 Thread Rob Slotboom

In a model I feed a contenttype form field some initial data to choose
from.

class MenuItem(models.Model):
   CONTENT_TYPE_CHOICES = tuple(get_available_content())
   content_type = models.ForeignKey(ContentType,
choices=CONTENT_TYPE_CHOICES)

The data is provided using the folowing function which returns a tuple
for every stored (in this case) Poll in the form of 13:xxx where xxx is
the poll_id. Just before saving the data I split the two parts in
content_type_id and content_id. Then I want to hand them over to the
corresponding values. This way it must be possible to add some kind of
menu_app to django which works within the admin interface.

def get_available_content():
   available_content_list = [('13','testpoll')]
   from mysite.polls.models import Poll
   polls_list = Poll.objects.all().order_by('-question')
   for poll in polls_list:
  key = '13:%s' % poll.id
  caption = poll.question
  poll_tup = ( key, caption )
  available_content_list.append(poll_tup)
   return available_content_list

The only thing I can't get working is setting the new value befor
saving

content_type_id, object_id = self.content_type_id.split(':', 1)
self.content_type.id = int(content_type_id)
self.object_id = int(object_id)

Maybe someone has an idea???


--~--~-~--~~~---~--~~
 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: Cannot resolve keyword 'caption' into field

2006-12-11 Thread Rob Slotboom

On 10 dec, 17:42, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> What is the error you are getting?

It's the 'subject'

Cannot resolve keyword 'caption' into 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
-~--~~~~--~~--~--~---



model problem "matching query does not exist"

2006-12-09 Thread Rob Slotboom

After solving a problem described at:
http://groups-beta.google.com/group/django-users/browse_frm/thread/b453f0c91e29cc04?hl=nl

I continued developping my model. Unfortunately a new problem arose.
Given the following model, I get an error message in admin after
successfully saving an article and then selecting it.

MenuItem matching query does not exist.

The model describes an article 1to1 to menuitem
and a menuitem Mt1 to itself.
This way I try to get some kind of menustructure.
What causes the problem?

# model #
from django.db import models
from django.core import validators

class Article(models.Model):
   headline = models.CharField(maxlength=200)
   body = models.TextField()
   art_image = models.CharField(maxlength=200, help_text="FileBrowser:
/", blank=True, null=True)
   pub_date = models.DateTimeField('date published')
   published = models.BooleanField()

   def __str__(self):
  return self.headline
   class Admin:
  fields = (
 (None, {'fields': ('headline','body','art_image')}),
 ('Publication information', {'fields':
('pub_date','published'), 'classes': 'collapse'}),
  )
  date_hierarchy = 'pub_date'
  list_filter = ['pub_date']
  search_fields = ['headine']
  js = (
 'js/tiny_mce/tiny_mce.js',
 'js/textareas.js',
 'js/AddFileBrowser.js',
  )

class MenuItem (models.Model):
   article = models.OneToOneField(Article, edit_inline=models.TABULAR,
num_in_admin=1)
   caption = models.CharField(maxlength=40, db_index=True, core=True)
   parent = models.ForeignKey('self', blank=True, null=True,
related_name='child', core=True)

   def __str__(self):
  return self.caption


--~--~-~--~~~---~--~~
 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: Cannot resolve keyword 'caption' into field

2006-12-09 Thread Rob Slotboom

After many many trail and error I maybe found a 'bug'.

I simplefied the above model till it worked again. Then I added the
next field option and the error arose.

"unique=True" in MenuItem > name

Complete simplefied model with error:
###

from django.db import models

class Article(models.Model):
   headline = models.CharField(maxlength=200)
   body = models.TextField()
   pub_date = models.DateTimeField('date published')
   published = models.BooleanField()

   def __str__(self):
  return self.headline
   class Admin:
  pass

class MenuItem (models.Model):
   article = models.OneToOneField(Article, edit_inline=models.TABULAR,
num_in_admin=1)
   naam = models.CharField(maxlength=200, unique=True, core=True)
   def __str__(self):
  return self.caption


replace
   naam = models.CharField(maxlength=200, unique=True, core=True)
with
   naam = models.CharField(maxlength=200, core=True)
and it works again.


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



Cannot resolve keyword 'caption' into field

2006-12-08 Thread Rob Slotboom

I get this error in admin when saving a new article.


Can someone please help me?

Complete model...

from django.db import models
from django.core import validators


class Article(models.Model):
   pub_date = models.DateTimeField('date published')
   published = models.BooleanField()
   headline = models.CharField(maxlength=200)
   article = models.TextField()
   art_image = models.CharField(maxlength=200, help_text="FileBrowser:
/", blank=True, null=True)
   # reporter = models.ForeignKey(Reporter)

   def __str__(self):
  return self.headline
   class Admin:
  fields = (
 (None, {'fields': ('headline','article','art_image',)}),
 ('Publication information', {'fields':
('pub_date','published'), 'classes': 'collapse'}),
  )
  date_hierarchy = 'pub_date'
  list_filter = ['pub_date']
  search_fields = ['headine']
  js = (
 'js/tiny_mce/tiny_mce.js',
 'js/textareas.js',
 'js/AddFileBrowser.js',
  )

class MenuItem (models.Model):
   article = models.OneToOneField(Article, edit_inline=models.TABULAR,
num_in_admin=1)
   caption = models.CharField(maxlength=40, unique=True, db_index=True,
core=True)
   parent = models.ForeignKey('self', blank=True, null=True,
related_name='child_set', core=True)

   def __str__(self):
  p_list = self._recurse_for_parents(self)
  p_list.append(self.caption)
  return self.get_separator().join(p_list)

   def _recurse_for_parents(self, cat_obj):
  p_list = []
  if cat_obj.parent_id:
 p = cat_obj.parent
 p_list.append(p.caption)
 more = self._recurse_for_parents(p)
 p_list.extend(more)
  if cat_obj == self and p_list:
 p_list.reverse()
  return p_list

   def get_separator(self):
  return ' :: '

   def _parents_repr(self):
  p_list = self._recurse_for_parents(self)
  return self.get_separator().join(p_list)
   _parents_repr.short_description = "Item parents"

   def save(self):
  p_list = self._recurse_for_parents(self)
  if self.caption in p_list:
 raise validators.ValidationError("U kunt geen menuiten in
zichzelf opslaan!")
  super(MenuItem, self).save()
   """
   class Admin:
  list_display = ('caption', '_parents_repr')
  pass 
   """


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



model field question

2006-12-07 Thread Rob Slotboom

For a model I have defined two table fields.
To fill those fields in admin I want to provide an extra dropdown
field.

Is it possible to add an extra field to the model without creating a
corresponding database field?


The use:

field1 = content_type_id
field2 = content_item_id

Extra dropdown field = "id1 id2", "id1 id2","id1 id2","id1 id2",
Befor saving I grap the values using split.


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



cursor.fetchall() attribute error

2006-11-11 Thread Rob Slotboom

In a models.py I have created the folowing function. Top level, not in
a class.

def get_unvoted_polls_for_voter_ip(ip):
   from django.db import connection
   cursor = connection.cursor()
   sql = """SELECT polls_poll.* FROM polls_poll
  LEFT OUTER JOIN polls_vote ON polls_poll.id = polls_vote.poll_id
  WHERE polls_vote.voter_ip <> '%s' OR polls_vote.voter_ip IS
NULL;""" % ip
   cursor.execute(sql)
   return [Poll.__class__(*row) for row in cursor.fetchall()]

This is the Poll object

class Poll(models.Model):
   question = models.CharField('vraag', maxlength=200)
   pub_date = models.DateTimeField('publicatie datum')
   

I've tested the function using a "bare" list as result.
Trying to store the resulting data in poll entities using the above
construction raised an error:

'datetime.datetime' object has no attribute 'pop'.

Can someone tell me how to solve this?

### DEBUG SNIPPET ###

/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/base.py
in __new__
"Metaclass for all models"
def __new__(cls, name, bases, attrs):
# If this isn't a subclass of Model, don't do anything special.
if not bases or bases == (object,):
return type.__new__(cls, name, bases, attrs)
# Create the class.
new_class = type.__new__(cls, name, bases, {'__module__':
attrs.pop('__module__')}) ...
new_class.add_to_class('_meta', Options(attrs.pop('Meta',
None)))
new_class.add_to_class('DoesNotExist',
types.ClassType('DoesNotExist', (ObjectDoesNotExist,), {}))
# Build complete list of parents
for base in bases:
# TODO: Checking for the presence of '_meta' is hackish.
▼ Local vars
VariableValue
attrs  datetime.datetime(2006, 10, 23, 12, 4)
bases  'Wat is Django?'
cls
name2


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



cursor.fetchall() attribute error

2006-11-11 Thread Rob Slotboom

In a models.py I have created the folowing function. Top level, not in
a class.

def get_unvoted_polls_for_voter_ip(ip):
   from django.db import connection
   cursor = connection.cursor()
   sql = """SELECT polls_poll.* FROM polls_poll
  LEFT OUTER JOIN polls_vote ON polls_poll.id = polls_vote.poll_id
  WHERE polls_vote.voter_ip <> '%s' OR polls_vote.voter_ip IS
NULL;""" % ip
   cursor.execute(sql)
   return [Poll.__class__(*row) for row in cursor.fetchall()]

This is the Poll object

class Poll(models.Model):
   question = models.CharField('vraag', maxlength=200)
   pub_date = models.DateTimeField('publicatie datum')
   

I've tested the function using a "bare" list as result.
Trying to store the resulting data in poll entities using the above
construction raised an error:

'datetime.datetime' object has no attribute 'pop'.

Can someone tell me how to solve this?

### DEBUG SNIPPET ###

/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/base.py
in __new__
"Metaclass for all models"
def __new__(cls, name, bases, attrs):
# If this isn't a subclass of Model, don't do anything special.
if not bases or bases == (object,):
return type.__new__(cls, name, bases, attrs)
# Create the class.
new_class = type.__new__(cls, name, bases, {'__module__':
attrs.pop('__module__')}) ...
new_class.add_to_class('_meta', Options(attrs.pop('Meta',
None)))
new_class.add_to_class('DoesNotExist',
types.ClassType('DoesNotExist', (ObjectDoesNotExist,), {}))
# Build complete list of parents
for base in bases:
# TODO: Checking for the presence of '_meta' is hackish.
▼ Local vars
VariableValue
attrs  datetime.datetime(2006, 10, 23, 12, 4)
bases  'Wat is Django?'
cls
name2


--~--~-~--~~~---~--~~
 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: model question

2006-11-10 Thread Rob Slotboom

Thank you guys.
Without a poll_id in vote it isn't possible to check integrity in the
database so I keep it :-)


--~--~-~--~~~---~--~~
 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: model question

2006-11-09 Thread Rob Slotboom

Rob Hudson schreef:

> I'd kind of think that in Vote you don't need the poll FK, just the
> choice since the choice then maps to a particular poll.

But how do I prevent a voter to vote more than once on a poll?


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



model question

2006-11-09 Thread Rob Slotboom

I'm trying to get a very simple relationship to work but I can't figure
ou how to do this in Django.
This is what I want.

Poll ---<< question

Poll ---<< vote

A user can vote a poll just once. I check this using a function which
gets the remote ip.

This is the models.py snippet

class Poll(models.Model):
   question = models.CharField('vraag', maxlength=200)
   pub_date = models.DateTimeField('publicatie datum')

   def has_remote_addr_voted(self, ip):
  result = False
  if (self.vote_set.filter(voter_ip = ip).count() > 0):
 result = True
  return result

   class Admin:
  fields = (
 (None, {'fields': ('question','pub_date',)}),
  )
  pass

class Choice(models.Model):
   poll = models.ForeignKey(Poll, edit_inline=models.TABULAR,
num_in_admin=3)
   choice = models.CharField(maxlength=200, core=True)
   votes = models.IntegerField(core=True)

class Vote(models.Model):
   poll = models.ForeignKey(Poll, edit_inline=models.TABULAR,
num_in_admin=3)
   voter_ip = models.IPAddressField(core=True)
   choice = models.ForeignKey(Choice, edit_inline=models.TABULAR,
num_in_admin=3)

   class Meta:
  unique_together = (("poll", "voter_ip"),)

The model is correct but the problem occurs in admin.

Editing a poll you get the related choices and votes. For a vote you
can select a choice from a list which contains all choices, not the
choices for the current poll.


--~--~-~--~~~---~--~~
 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: What's the best way to make a custom publishing workflow?

2006-11-04 Thread Rob Slotboom

Hi Kevn,

May be of interest:

http://www.b-list.org/weblog/2006/09/02/django-tips-user-registration

http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model


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



setting and using an object variable without using a field

2006-11-03 Thread Rob Slotboom

To be able to control a template output based on a current remote
address, I created this model.

class Poll(models.Model):
   question = models.CharField('vraag', maxlength=200)
   pub_date = models.DateTimeField('publicatie datum')
   voted_by_remote_addr = False

   def set_voted_by_remote_addr(self, ip):
  if (self.vote_set.filter(voter_ip = ip).count() > 0):
 self.voted_by_remote_addr = True


I use the model in a view like this:

def list(request):
   poll_list = Poll.objects.all().order_by('-pub_date')
   for poll in poll_list:
  poll.set_voted_by_remote_addr(request.META["REMOTE_ADDR"])

   return render_to_response('polls_list.html', {
  'object_list': poll_list,
  'title': 'List of polls',
   }, context_instance=RequestContext(request))



The template contains:

{% if object_list %}

{% for poll in object_list %}
{{ poll.question
}} {{ poll.voted_by_remote_addr }}
{% endfor %}

{% else %}
No polls are available.
{% endif %}

And. it's working.
Just one question: Is this the right way to do such things?


--~--~-~--~~~---~--~~
 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: custom or build in register/login/logout

2006-10-29 Thread Rob Slotboom

Sorry, I should have searched smarter before posting.
Found the anwers at
http://www.b-list.org/weblog/2006/09/02/django-tips-user-registration


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



custom or build in register/login/logout

2006-10-29 Thread Rob Slotboom

For a project I need to record customer information such as name,
address etc.
I doubt about the best approach to create this functionality.
Shall I use the user class in contrib.auth and extend it or shall I
create an independent customer class/app?

The first approach serves me the default authentication.
The second brings me an app wich I can comprehend.
Or, can I use the second and still use the basic authentication?

Please advise..


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



Re: include tag and urls

2006-10-29 Thread Rob Slotboom

> Can you give some more details, please? I cannot puzzle out what you are
> currently doing here.

Hello Malcolm,

It's about  in the template.
Here come the details...

### mysite/polls/templatetags/poll_tags.py

from django import template
from mysite.polls.models import Poll
register = template.Library()

def show_latest_polls(count=5):
   latest_polls = Poll.objects.all().order_by('-pub_date')[:count]
   return {'latest_polls' : latest_polls}

register.inclusion_tag('latest_polls.html')(show_latest_polls)

### mysite/polls/templates/latest_polls.html

{% for poll in latest_polls %}
   {{ poll.question }}
{% endfor %}


### mysite/templates/index.html
...
   {% load poll_tags %}
   {% show_latest_polls 10 %}
...


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



include tag and urls

2006-10-27 Thread Rob Slotboom

Using an inlude tag on my homepage to get a list of current polls
requires a template. This template lists the polls and provides a link
for the details. I need to give an url including the modulename:
(a href="/polls/5")

I don't like this approach so I want to ask if it is possible to use
an object variable to get the right prefix?

Futhermore, I also want to keep the tag templates within the
templatetags directory. I tried this using
register.inclusion_tag('/dirto/template.html')(...) but that doesn't
work out. Is it possible (without the use of settings.py)?


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



Re: Template question

2006-03-12 Thread Rob Slotboom

Thank you, I'll have a look.


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



Re: Template question

2006-03-12 Thread Rob Slotboom

Hi Malcolm,

{{forloop.counter|add:offset}} works fine.

Thanks,
Rob


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



Re: Breaking up long lists

2006-03-11 Thread Rob Slotboom

I don't know. I'll have a look.


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



Breaking up long lists

2006-03-10 Thread Rob Slotboom

I've added an example view and template at:

http://code.djangoproject.com/wiki/CookBookViews

Good luck.


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



Template question

2006-03-10 Thread Rob Slotboom

Is it possible to add some initial value to a forloop.counter?

This would be handy when using limit and offset.

More general, is is possible to use template vars as values for
calculations:
{{ var1 }} + {{ var 2 }}


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



Re: stringformat in template

2006-03-09 Thread Rob Slotboom

Dear Geert,

I entered {{ total_amount|stringformat:".2f" }} and it realy worked :-)

Actualy I red the STRINGFORMAT docu but I didn't get the clue. Now I
do...

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Getting an object' content_type_id

2006-03-09 Thread Rob Slotboom

Is there a way to get an object's content_type_id?

I need it to store an object's id and content_type_id in another table.

Currently I solved this by using an sql-statement but maybe there is
some 'hidden' property or function like:
self.content_type or self.get_content_type


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



stringformat in template

2006-03-08 Thread Rob Slotboom

I tried to use stringformat within a template but without success.
This is what I want in 'normal' syntax':

return "%.2f" % total_amount

It returns a two decimal value.

But how to use it in the template???


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



getting a model's content_type_id

2006-03-06 Thread Rob Slotboom

Is there a way to get a model's content_type_id?
I need it to store an object's id and content_type_id in another
table.
Currently I solved this by using an sql-statement but maybe there is
some 'hidden' property or function like:

self.content_type or self.get_content_type


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



Re: Creating a menu structure

2006-03-03 Thread Rob Slotboom

To create hierarchical menu's, the first thing I thought about was
some kind of parent child relation on just one table but then you have
to submit many queries. A better approach wil be the Modified Preorder
Tree Traversal. See:
http://www.sitepoint.com/print/hierarchical-data-database

On the Django site you can find an example at:
http://code.djangoproject.com/wiki/ModifiedPreorderTreeTraversal

I'm still experimenting but I use one table to store some kind of
collection (id, content_type, object_id) so I can relate to different
types of content (tables)

After saving content -say a book- I run _post_save to add the book to
the collection.

For the menu itself I create a table, containing the collection_id and
the fields for ordering (lft, rgt)

This is just a startingpoint but I hope it will help you on the run.


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



admin > site

2006-03-03 Thread Rob Slotboom

Hi guys,

Can someone please tell me what can be done with the site feature in
admin?
And now I'm on it: from the ducumentation I understand that it is
possible to use admin interface parts in your own apps by calling
classes. Am I correct?


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