ON DELETE CASCADE behaviour on M2M?

2011-01-17 Thread Victor Hooi
Hi,

I know that Django's default behaviour on ForeignKey is ON DELETE CASCADE 
(unless you set on_delete to PROTECT). However, I wasn't sure how this 
extended to ManyToManyFields.

I've just tested with one of my own applications - I have an "Article" 
object, with m2m to a "Journalist" object. Deleting either end of the m2m 
didn't affect the other end.

I assume this is intended behaviour - since it simply cascades to the 
invisible join table in the middle, but through to the other actual end of 
the relatinoship?

However, the issue I see with this is that if the m2m can't be empty (as is 
default). You delete one end, and everything seems fine and dandy. But then 
you go into edit the other end of the relationship, and it now complains 
that the m2m field is empty. But during that period until you tried to 
open/edit it, it was fine with having a empty mandatory m2m field. Surely 
there's an integrity issue there?

Secondly, is there a way to tweak the ON DELETE behaviour for m2m. E.g. can 
you set it to PROTECT, just like you do for FK's, to prevent you deleting an 
object, if something else has a m2m link to it? Or can you set it to ON 
CASCADE DELETE, as it does for FK?

Cheers,
Victor

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



Re: listpage question

2011-01-17 Thread Vovk Donets
2011/1/18 Bobby Roberts 

> let's say  i have two simple models
>
>
> model a
> id=IntegerField...
> description = CharField...
>
>
> model b
> id=IntegerField...
> modelavalue=IntegerField...   (a value form modela.id)
> description=CharField...
>
>
> ok in the /admin listing page for model B, how can i return
> modela.description  for modelb.modelavalue
>
>
you can do it by inserting "modelAvalue__description" in the admin.py in the
list_display for modelB model.Admin:

class modelBAdmin(admin.ModelAdmin):
list_display = ( 'id','modelAvalue__description', 'description')
admin.site.register(modelB, modelBAdmin)

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



listpage question

2011-01-17 Thread Bobby Roberts
let's say  i have two simple models


model a
id=IntegerField...
description = CharField...


model b
id=IntegerField...
modelavalue=IntegerField...   (a value form modela.id)
description=CharField...


ok in the /admin listing page for model B, how can i return
modela.description  for modelb.modelavalue

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



Re: Problem with overriding the default Django admin page.

2011-01-17 Thread Mike Dewhirst

On 18/01/2011 1:59pm, Mike Dewhirst wrote:

This is what I do ...

in settings.py

# this is the directory containing settings.py
PROJECT_DIR = os.path.realpath(os.path.dirname(__file__))

# if templates are not found here look in app_name/templates
TEMPLATE_DIRS = (os.path.join(PROJECT_DIR, 'templates/'),)

This makes my templates directory a sub-dir of the project dir and
inside that there are other sub-dirs one for each app and one for the
admin.

I don't really need one for the admin because django knows where the
admin templates live inside the django tree.

However, there is one admin template I override so that I can
personalise the admin. That is called base_site.html. It is ...

PROJECT_DIR/templates/admin/base_site.html

It is the only admin template I change



AND it is the only template in my PROJECT_DIR/templates/admin directory.


and it only contains ...


{% extends "admin/base.html" %}
{# admin/base.html is in
site-packages/django/contrib/admin/templates/admin #}
{% load i18n %}
{% block title %}{{ title }} | {% trans 'My site admin' %}{% endblock %}

{% block branding %}
{% trans 'My administration' %}
{% endblock %}

Note the comment which indicates that it inherits from the django tree
of admin templates.

How does django know to look at my base_site.html while it is processing
the django tree of templates?

The answer is simple and can be found in your settings.py file here ...

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)

If the filesystem loader is ahead of the app_directories loader, django
looks in your project templates before its own. Here is the doc
reference ...

http://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types

Hope this helps

Mike




On 18/01/2011 12:26pm, Chen Xu wrote:

I did try this, and I tried again, but it still doesn't work.
Do I need to do something extra like quit the server, and restart again?
By the way I did try this too.

Now, I am totally lost.

Thanks

On Mon, Jan 17, 2011 at 3:17 AM, Vovk Donets > wrote:

You must specify in the TEMPLATE_DIRS path to the dir where
templates were placed, not abs path file
So
TEMPLATE_DIRS = (
"/Users/xuchen81/Django/mysite/",

)
should work, coz' "In order to override one or more of them, first
create an admin directory in your project's templates directory.
This can be any of the directories you specified in TEMPLATE_DIRS
."


2011/1/17 Chen Xu >

Hi, Django group:
I am floowing the tutorial 1 on Django site, which is a poll
application
I have problem with overriding the admin page
I copied admin/base_site.html from
(django/contrib/admin/templates) to
/Users/xuchen81/Django/mysite/admin/base_site.html

and add this line
"/Users/xuchen81/Django/mysite/admin/base_site.html"
to TEMPLATE_DIRS in my settings.py file. It looks like the
following:

TEMPLATE_DIRS = (
"/Users/xuchen81/Django/mysite/admin/base_site.html",
)

but the admin is just doesn't use this file, it still uses the
default base_site.html.

Could anyone please help me?

--
*Vovk Donets*
python/django developer

skype: suunbeeam
icq: 232490857
mail: donets.vladi...@gmail.com 


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


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




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



Re: Problem with overriding the default Django admin page.

2011-01-17 Thread Mike Dewhirst

This is what I do ...

in settings.py

   # this is the directory containing settings.py
   PROJECT_DIR = os.path.realpath(os.path.dirname(__file__))

   # if templates are not found here look in app_name/templates
   TEMPLATE_DIRS = (os.path.join(PROJECT_DIR, 'templates/'),)

This makes my templates directory a sub-dir of the project dir and 
inside that there are other sub-dirs one for each app and one for the admin.


I don't really need one for the admin because django knows where the 
admin templates live inside the django tree.


However, there is one admin template I override so that I can 
personalise the admin. That is called base_site.html. It is ...


   PROJECT_DIR/templates/admin/base_site.html

It is the only admin template I change and it only contains ...

   {% extends "admin/base.html" %}
   {# admin/base.html is in 
site-packages/django/contrib/admin/templates/admin #}

   {% load i18n %}
   {% block title %}{{ title }} | {% trans 'My site admin' %}{% endblock %}

   {% block branding %}
 {% trans 'My administration' %}
   {% endblock %}

Note the comment which indicates that it inherits from the django tree 
of admin templates.


How does django know to look at my base_site.html while it is processing 
the django tree of templates?


The answer is simple and can be found in your settings.py file here ...

   TEMPLATE_LOADERS = (
   'django.template.loaders.filesystem.Loader',
   'django.template.loaders.app_directories.Loader',
   )

If the filesystem loader is ahead of the app_directories loader, django 
looks in your project templates before its own. Here is the doc 
reference ...


http://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types

Hope this helps

Mike




On 18/01/2011 12:26pm, Chen Xu wrote:

I did try this, and I tried again, but it still doesn't work.
Do I need to do something extra like quit the server, and restart again?
By the way I did try this too.

Now, I am totally lost.

Thanks

On Mon, Jan 17, 2011 at 3:17 AM, Vovk Donets > wrote:

You must specify in the TEMPLATE_DIRS path to the dir where
templates were placed, not abs path file
So
TEMPLATE_DIRS = (
"/Users/xuchen81/Django/mysite/",

)
should work, coz' "In order to override one or more of them, first
create an admin directory in your project's templates directory.
This can be any of the directories you specified in TEMPLATE_DIRS

."

2011/1/17 Chen Xu >

Hi, Django group:
I am floowing the tutorial 1 on Django site, which is a poll
application
I have problem with overriding the admin page
I copied   admin/base_site.html   from
(django/contrib/admin/templates) to
/Users/xuchen81/Django/mysite/admin/base_site.html

and add this line
"/Users/xuchen81/Django/mysite/admin/base_site.html"
to TEMPLATE_DIRS in my settings.py file. It looks like the
following:

TEMPLATE_DIRS = (
"/Users/xuchen81/Django/mysite/admin/base_site.html",
)

but the admin is just doesn't use this file, it still uses the
default base_site.html.

Could anyone please help me?

--
*Vovk Donets*
python/django developer

skype:  suunbeeam
icq:  232490857
mail: donets.vladi...@gmail.com 


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


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


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



Re: Problem with overriding the default Django admin page.

2011-01-17 Thread Vovk Donets
2011/1/18 Chen Xu 

> I did try this, and I tried again, but it still doesn't work.
> Do I need to do something extra like quit the server, and restart again? By
> the way I did try this too.
>
> Now, I am totally lost.
>
>
Django dev server restarts itself, but sometimes you have to manually
restart it.
Well, if you specify paths right and create there is a directory nothing
would go wrong:

TEMPLATE_DIRS = (
"/templates/",
}
and your project for example is here "/var/www/project/" than you go to this
dir and in the dir "templates" create dir "admin" and place here thoose
admin templates that would replace default admin templates. As i have done
it many times if it is done right things works from the start.

for debugging you can delete default admin templates and when Django spills
error that template does not exist's look at path's in traceback where
django searched templates
it can help to understand problem better
-- 
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com

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



Re: Problem with overriding the default Django admin page.

2011-01-17 Thread Chen Xu
I did try this, and I tried again, but it still doesn't work.
Do I need to do something extra like quit the server, and restart again? By
the way I did try this too.

Now, I am totally lost.

Thanks

On Mon, Jan 17, 2011 at 3:17 AM, Vovk Donets wrote:

> You must specify in the TEMPLATE_DIRS path to the dir where templates were
> placed, not abs path file
> So
> TEMPLATE_DIRS = (
> "/Users/xuchen81/Django/mysite/",
>
> )
> should work, coz'  "In order to override one or more of them, first create
> an admin directory in your project's templates directory. This can be any
> of the directories you specified in 
> TEMPLATE_DIRS
> ."
>
> 2011/1/17 Chen Xu 
>
> Hi, Django group:
>> I am floowing the tutorial 1 on Django site, which is a poll application
>> I have problem with overriding the admin page
>> I copied   admin/base_site.html   from (django/contrib/admin/templates)
>> to   /Users/xuchen81/Django/mysite/admin/base_site.html
>>
>> and add this line "/Users/xuchen81/Django/mysite/admin/base_site.html"
>> to TEMPLATE_DIRS in my settings.py file. It looks like the following:
>>
>> TEMPLATE_DIRS = (
>> "/Users/xuchen81/Django/mysite/admin/base_site.html",
>> )
>>
>> but the admin is just doesn't use this file, it still uses the default
>> base_site.html.
>>
>> Could anyone please help me?
>>
>> --
> *Vovk Donets*
>  python/django developer
>
> skype:  suunbeeam
> icq:  232490857
> mail:donets.vladi...@gmail.com
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Migrating custom view to class-based generic views ; Using staticfiles assets in CSS files?

2011-01-17 Thread Victor Hooi
Hi,

I'm currently migrating one of my apps to use the new contrib.staticfiles 
module in Django 1.3.

>From the documentation I can see there's two ways of referring to static 
files:

http://docs.djangoproject.com/en/dev/howto/static-files/

   1. Use {{ STATIC_URL}}
   2. Use {% load static %}, then {% get_static_prefix %}

However, option 1 seems to only work if you're using RequestContext - the 
easiest way of doing this seems to be using Generic (Class-based) Views.

Currently, I'm using a fairly simple custom view that returns a QuerySet of 
"Article" objects matching certain date/filtering criteria, then passes it 
to render_to_response. The start-date and entry-date are passed as part of 
the URL ie.. http://server.com/report_foo/2011-01-01/to/2010-01-05

def report_foo(request, start_date, end_date=None):
if end_date:
article_list = 
Article.objects.filter(in_daily_briefing=True).filter(entry_date__gte=start_date).filter(entry_date__lte=end_date).order_by('category',
 
'headline')
end_date = datetime.datetime.strptime(end_date, '%Y-%m-%d')
else:
article_list = 
Article.objects.filter(in_daily_briefing=True).filter(entry_date=start_date).order_by('category',
 
'headline')
return render_to_response('report_foo.html', {'article_list': 
article_list, 'start_date': datetime.datetime.strptime(start_date, 
'%Y-%m-%d'), 'end_date': end_date})

First question - what is the best way to migrate this to a generic view? I 
was thinking:

from django.views.generic improt TemplateView
class ReportFooView(TemplateView):
if end_date:
article_list = 
Article.objects.filter(in_daily_briefing=True).filter(entry_date__gte=start_date).filter(entry_date__lte=end_date).order_by('category',
 
'headline')
end_date = datetime.datetime.strptime(end_date, '%Y-%m-%d')
else:
article_list = 
Article.objects.filter(in_daily_briefing=True).filter(entry_date=start_date).order_by('category',
 
'headline')
params = {'article_list': article_list, 'start_date': 
datetime.datetime.strptime(start_date, '%Y-%m-%d'), 'end_date': end_date}
template_name = "report_foo.html"

Or is there a smarter way of doing this with the provided mixins/generics 
views?

And now my second question - I can use STATIC_URL or get_static_url in my 
template files - but how do I use these values in my CSS files? I.e. my CSS 
files need to reference assets stored as part of staticfiles.

Cheers,
Victor

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



Re: Hyphens in Django app/project names?

2011-01-17 Thread Victor Hooi
Russ,

Aha, excellent, thanks for clearing that up =).

I can see you point - django-registration has a module called 
"registration", django-extensions has a module called "django_extensions", 
and django-staticfiles has one called "staticfiles". So it seems like I 
either go for a single-word module name, or replace hyphens with 
underscores.

Is there any recommendation from the Django team? Is sing underscores as 
faux-hyphens considered bad practice?

Cheers,
Victor

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



Re: Dates BC

2011-01-17 Thread Christophe Pettus

On Jan 17, 2011, at 2:00 PM, Ben Dembroski wrote:
> I'm a relative newbie to both Python and Django, and in the middle of
> my first Django project.   My client is asking me to store and process
> dates -- including dates BC.

Unless you have a strong need to do date arithmetic on the dates, or you can 
use a different database (like PostgreSQL) that has more robust date support, 
it might be easier to represent the dates as stylized strings, or as integers 
on a uniform calendar like the proleptic Julian calendar, instead of using the 
built-in date type.

--
-- Christophe Pettus
   x...@thebuild.com

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



Dates BC

2011-01-17 Thread Ben Dembroski
Hi all,

I was planning on making a formal introduction to the group when I had
a chance.  I'm afraid I come seek help instead.

I'm a relative newbie to both Python and Django, and in the middle of
my first Django project.   My client is asking me to store and process
dates -- including dates BC.

Is this easily done in Django?   I'm using sqlite3 for the database.

Googling has revealed mxdatetime, but from what I understand Django
doesn't like to play with it at all.

Any suggestion on where to look?

Many thanks!

Ben

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



Using class based views to autoassign certain values?

2011-01-17 Thread Sontek
When I try to add new Attendee with a class based view I get the error
matriculation_attendee.event_id may not be NULL with this code:

class Event(models.Model):
""" Model representing an event """
place = models.ForeignKey(Place, blank=True, null=True)
slug = AutoSlugField(populate_from=('company', 'name'))
name = models.CharField(max_length=200)
company = models.ForeignKey(Company)
description = models.TextField(null=True, blank=True)
start_date = models.DateField()
end_date = models.DateField()
status = models.CharField(max_length=200, null=False, blank=True)
currency = models.CharField(max_length=4,
choices=currency_choices)
payment_gateway = models.ForeignKey(PaymentGateway, blank=True,
null=True)

def registered(self):
return self.attendee_set.count()

def active(self):
return self.attendee_set.filter(is_active=True).count()

def cancelled(self):
return self.attendee_set.filter(is_active=False).count()

def __unicode__(self):
return self.name

class Meta:
ordering = ['name']

def save(self, *args, **kwargs):
if self.end_date < datetime.now().date():
self.status = 'Closed'
elif datetime.now().date() >= self.start_date:
self.status = 'Onsite'
else:
self.status = 'Active'

super(Event, self).save(*args, **kwargs)

class Attendee(CommonDataInfo):
#TODO: Add prefix and suffix choices
event = models.ForeignKey(Event)
prefix = models.CharField(max_length=300, blank=True, null=True)
first_name = models.CharField(max_length=300)
last_name = models.CharField(max_length=300)
suffix = models.CharField(max_length=300, blank=True, null=True)
badge_name = models.CharField(max_length=300, blank=True,
null=True)
birthdate = models.DateField(blank=True, null=True)
reg_date = models.DateTimeField(default=datetime.now())
email = models.CharField(max_length=300, blank=True, null=True)
gender = models.CharField(max_length=1, choices=gender_choices,
blank=True,
null=True)
location = models.ForeignKey(Place, blank=True, null=True)

def __unicode__(self):
return "%s %s" % (self.first_name, self.last_name)

class Meta:
ordering = ['last_name', 'first_name', 'is_active']


class EventContextMixIn(object):
def get_context_data(self, **kwargs):
event = get_object_or_404(Event,
slug=self.kwargs['event_id'])
# Call the base implementation first to get a context
context = super(EventContextMixIn,
self).get_context_data(**kwargs)
context['event'] = event
return context

def get_form_kwargs(self, **kwargs):
context = self.get_context_data()
kwargs = super(EventContextMixIn,
self).get_form_kwargs(**kwargs)
kwargs['initial']['event'] = context['event']
return kwargs


class EventCreateView(EventContextMixIn, CreateView):
pass


class EventUpdateView(EventContextMixIn, UpdateView):
pass


class EventListView(EventContextMixIn, ListView):
context_object_name = "model_list"


class EventDetailView(EventContextMixIn, DetailView):
context_object_name = 'model'


url(r'^events/(?P[-\w]+)/attendees/add/$',
EventCreateView.as_view(form_class=AttendeeForm,
template_name='matriculation/attendee_update.html'),
name='matriculation_attendees_add'),


Am I using this wrong?  I'm basically trying to set this up so I the
url defines the event and then I can create models for the specific
event.

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



Re: South introspection doesn't get registrered

2011-01-17 Thread Ian Clelland
On Mon, Jan 17, 2011 at 9:18 AM, OryBand  wrote:
> Hello.
>
> I am using a simple custom Model:
>
> from django.db.models import ImageField
> class ImageWithThumbsField(ImageField):
>    def __init__(self, verbose_name=None, name=None, width_field=None,
> height_field=None, sizes=None, **kwargs):
>        self.verbose_name=verbose_name
>        self.name=name
>        self.width_field=width_field
>        self.height_field=height_field
>        self.sizes = sizes
>        super(ImageField, self).__init__(**kwargs)
>
> And this is my introspection rule, which I add to models.py:
>
> from south.modelsinspector import add_introspection_rules
> from lib.thumbs import ImageWithThumbsField
> add_introspection_rules(
>    [
>        (
>            (ImageWithThumbsField, ),
>            [],
>            {
>                "verbose_name": ["verbose_name", {"default": None}],
>                "name":         ["name",         {"default": None}],
>                "width_field":  ["width_field",  {"default": None}],
>                "height_field": ["height_field", {"default": None}],
>                "sizes":        ["sizes",        {"default": None}],
>            },
>        ),
>    ],
>    ["^core/.models/.lib.thumbs.ImageWithThumbsField",])
>
> However, when trying to convert my app (named "core") to south, I get
> "freeze" errors, like the rule wasn't registered:
>
>  ! Cannot freeze field 'core.additionalmaterialphoto.photo'
>  ! (this field has class lib.thumbs.ImageWithThumbsField)
>  ! Cannot freeze field 'core.material.photo'
>  ! (this field has class lib.thumbs.ImageWithThumbsField)
>  ! Cannot freeze field 'core.material.formulaimage'
>  ! (this field has class lib.thumbs.ImageWithThumbsField)
>
>  ! South cannot introspect some fields; this is probably because they
> are custom
>  ! fields. If they worked in 0.6 or below, this is because we have
> removed the
>  ! models parser (it often broke things).
>  ! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork
>
> Does anybody know why?

Try changing the last line of your introspection rule, from
>  ["^core/.models/.lib.thumbs.ImageWithThumbsField",])
to something like
 ["^lib.thumbs.ImageWithThumbsField",])

It looks like South is not recognizing your field type, as it is using
a different package name than you are.

It may also need to be something like
'core.models.lib.thumbs.ImageWithThumbsField'
or
'core.models.ImagesWithThumbsField'
depending on how your package is structured.

At the very least, I'm pretty sure that the slashes you have in your
regex are incorrect, and won't ever match.

Regards,
Ian Clelland


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



Re: Odd problem with static files and Lighttpd

2011-01-17 Thread sdonk
Changed the permission and all works good!
Thanks.

On Jan 17, 1:56 pm, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> Hi Alex,
>
> Have you checked to make sure that /home/osmtools/mymedia has read-able
> permissions for the lighttpd user?
>
> Cal
>
> On Mon, Jan 17, 2011 at 10:41 AM, sdonk  wrote:
> > Hi to everybody,
> > I'm facing with a curious problem with Lighttpd and static files
> > serving.
> > Media admin is served by Lighttpd, but mymedia is not served by
> > Lighttpd.
>
> > This is a snippet of my lighttpd.conf
>
> > alias.url = (
> >        "/mymedia/" => "/home/osmtools/mymedia/",
> >        "/media/" => "/usr/lib/python2.5/site-packages/django/contrib/
> > admin/media/",
> > )
>
> > url.rewrite-once = (
> >        "^(/media.*)$" => "/$1",
> >       "^(/mymedia.*)$" => "/$1",
> >        "^/favicon\.ico$" => "/media/favicon.ico",
> >        "^(/.*)$" => "/osmtools.fcgi$1",
> > )
>
> > The result is that in the admin site css and js work well (http://
> > osmtool.com/admin) but in the user site neither the css and the js are
> > loaded (http://osmtool.com).
>
> > Any idea?
>
> > Thanks
>
> > Alex
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Applications Developer contract in Austin, TX

2011-01-17 Thread AlexLBasso
I am recruiting for a 9 month contract (with contract extension
potential) for a company in North Austin.  I am seeking an
Applications Developer very familiar with the JavaScript toolkit.  The
position requires specific experience with Python, Dojo, and JQuery.
In this role, you would be developing front-end applications for the
management and configuration of IPS systems.

If you (or someone you know) is interested in this opportunity, please
contact me at 512.257.6903 or aba...@aerotek.com.

Alex Basso
Aerotek,Inc.

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



Re: error CSRF token missing or incorrect on POST reciever

2011-01-17 Thread crazedpsyc
I fixed it with the not recommended method, but/so any help fixing it
the other way would be appreciated

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



Re: override save()

2011-01-17 Thread Vovk Donets
if self.posrx is not the model field then this is the cause.

*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com

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



Re: error CSRF token missing or incorrect on POST reciever

2011-01-17 Thread crazedpsyc
Ok I did as much of that as I could. I could not return
render_to_response('template.html', c) because I have a dict of other
values I must send, such as the form and the results.
Now I get:
"Reason given for failure:

No CSRF or session cookie.
"
probably because of that one thing

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



Re: Odd problem with static files and Lighttpd

2011-01-17 Thread John Finlay

What do the lighttpd logs say?


On 1/17/11 2:41 AM, sdonk wrote:

Hi to everybody,
I'm facing with a curious problem with Lighttpd and static files
serving.
Media admin is served by Lighttpd, but mymedia is not served by
Lighttpd.

This is a snippet of my lighttpd.conf

alias.url = (
 "/mymedia/" =>  "/home/osmtools/mymedia/",
 "/media/" =>  "/usr/lib/python2.5/site-packages/django/contrib/
admin/media/",
)

url.rewrite-once = (
 "^(/media.*)$" =>  "/$1",
"^(/mymedia.*)$" =>  "/$1",
 "^/favicon\.ico$" =>  "/media/favicon.ico",
 "^(/.*)$" =>  "/osmtools.fcgi$1",
)

The result is that in the admin site css and js work well (http://
osmtool.com/admin) but in the user site neither the css and the js are
loaded (http://osmtool.com).

Any idea?

Thanks

Alex



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



Re: error CSRF token missing or incorrect on POST reciever

2011-01-17 Thread crazedpsyc
I'll look at that article, thanks!

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



Re: a chicken and egg - help please?

2011-01-17 Thread Vovk Donets
>
> additional to this the categories per video need to be detailed as well
> (category the video belongs to is a ManyToMany)
>

If i understand you correctly then If you want some aditional information
to be
putted on the ManyToMany relationship then u need to use "through" parametr
and one more table.
look in docs.

>
> so my question is how to I order the query set by a foreign key that has a
> function to get the surname and also output on the template all the
> categories that the video belongs to?
>
>
>
To get all categories of the Video item u can do:
video.category.all()

About your wish to use method of get_surname to sort queryst - i think it's
not possible to do in this ORM.(well, i'll be happy if im wrong)
But you can sort queryset after you get it or you could subclass
models.query.QuerySet to add you own functionality like
 Item.objects.filter(...).order_by_surname(item.get_surname()) or smth like
this
-- 
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com
www:   vovk.org.ru

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



Re: jquery problem

2011-01-17 Thread Tony Lambropoulos
When I say I am only using the table-formset page, I mean thats the only
template.  I am using the js file, jquery.formset.js it comes with.  Sorry
about my vagueness.

On Mon, Jan 17, 2011 at 8:14 PM, Tony Lambropoulos wrote:

> This is the project I have started with:
> http://code.google.com/p/django-dynamic-formset/
> I've deleted everything except the table-formset page, thats the only one I
> am using.
> This is how I have my scripts entered into the template file.
> 
> ...
> This is the exact same format as the original jquery.formset.js file that
> comes with it.
> Basic Jquery commands seem to work, but when I try to implement a function
> from say
>  type="text/javascript">
> just as I have outside of django, nothing happens.  CSS seems to be
> implemented fine, but when I try to use a function from a script I find, it
> doesn't work and not to repeat myself too much, but I did get them to work
> otuside of django and Ive used firebug to confirm that the scripts are in
> the page when loaded in the browser.
>
>
> On Mon, Jan 17, 2011 at 7:53 PM, Vovk Donets wrote:
>
>>
>>
>> 2011/1/17 Tony 
>>
>> I did what you've recommended, I put in the jquery.js file that I used
>>> while testing outside of django.  There was still no success.  Thus
>>> far I cant get any other plugin to work beside the one it dynamic
>>> formset one I started with.  I even deleted that file temporarily to
>>> see if it was "blocking" the other files somehow.  It didn't work.
>>> Are there any other suggestions on how to get these jquery files to
>>> work in my django project?
>>>
>>>
>> 1) When debugging problems related to Java Script it's a good practice
>> to look at browser JS console to see if there something is wrong.
>>
>> 2) You didnt say a thing about how you JS scripts loaded in your page.
>> via 

Re: jquery problem

2011-01-17 Thread Tony Lambropoulos
This is the project I have started with:
http://code.google.com/p/django-dynamic-formset/
I've deleted everything except the table-formset page, thats the only one I
am using.
This is how I have my scripts entered into the template file.

...
This is the exact same format as the original jquery.formset.js file that
comes with it.
Basic Jquery commands seem to work, but when I try to implement a function
from say

just as I have outside of django, nothing happens.  CSS seems to be
implemented fine, but when I try to use a function from a script I find, it
doesn't work and not to repeat myself too much, but I did get them to work
otuside of django and Ive used firebug to confirm that the scripts are in
the page when loaded in the browser.

On Mon, Jan 17, 2011 at 7:53 PM, Vovk Donets wrote:

>
>
> 2011/1/17 Tony 
>
> I did what you've recommended, I put in the jquery.js file that I used
>> while testing outside of django.  There was still no success.  Thus
>> far I cant get any other plugin to work beside the one it dynamic
>> formset one I started with.  I even deleted that file temporarily to
>> see if it was "blocking" the other files somehow.  It didn't work.
>> Are there any other suggestions on how to get these jquery files to
>> work in my django project?
>>
>>
> 1) When debugging problems related to Java Script it's a good practice
> to look at browser JS console to see if there something is wrong.
>
> 2) You didnt say a thing about how you JS scripts loaded in your page.
> via 

Re: jquery problem

2011-01-17 Thread Vovk Donets
2011/1/17 Tony 

> I did what you've recommended, I put in the jquery.js file that I used
> while testing outside of django.  There was still no success.  Thus
> far I cant get any other plugin to work beside the one it dynamic
> formset one I started with.  I even deleted that file temporarily to
> see if it was "blocking" the other files somehow.  It didn't work.
> Are there any other suggestions on how to get these jquery files to
> work in my django project?
>
>
1) When debugging problems related to Java Script it's a good practice
to look at browser JS console to see if there something is wrong.

2) You didnt say a thing about how you JS scripts loaded in your page.
via 

Re: jquery problem

2011-01-17 Thread Tony
I did what you've recommended, I put in the jquery.js file that I used
while testing outside of django.  There was still no success.  Thus
far I cant get any other plugin to work beside the one it dynamic
formset one I started with.  I even deleted that file temporarily to
see if it was "blocking" the other files somehow.  It didn't work.
Are there any other suggestions on how to get these jquery files to
work in my django project?

On Jan 17, 10:14 am, sureronald  wrote:
> Confirm the plugin's jquery version requirement. Maybe the plugin
> requires another jquery version
>
> On Jan 17, 8:48 am, Tony Lambropoulos  wrote:
>
> > Prashanth,
> > This has to do with django because they work outside of django.
>
> > On Mon, Jan 17, 2011 at 6:12 AM, Prashanth  wrote:
> > > Hi Tony,
>
> > > On Mon, Jan 17, 2011 at 8:57 AM, Tony  wrote:
>
> > >>  Unfortunately, I can't get any other plugins to work that I download.  
> > >> No
> > >> other jquery
> > >> plugins seem to work and Im pretty sure I have the directory paths
> > >> right and everything.
>
> > > Very lame, How would someone know why something dint work?
>
> > >> Then I try to add other plugins and none will work.
>
> > > How is this related to Django? Hit Jquery mailing list.
>
> > > --
> > > regards,
> > > Prashanth
> > > twitter: munichlinux
> > > blog: honeycode.in
> > > irc: munichlinux, JSLint, munichpython.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.

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



Fwd: PostGISAdapter error

2011-01-17 Thread Robinson B. Heath
It has been a couple of weeks without a reply.  Is there somewhere else I 
should post this or am I on my own?

Begin forwarded message:

> From: "Robinson B. Heath" 
> Date: January 4, 2011 11:41:48 PM CST
> To: django-users@googlegroups.com
> Subject: PostGISAdapter error
> 
> I am getting the following error when the queryset tries to generate the SQL: 
> "'str' object has no attribute 'ewkb'"
> 
> Here is what I am doing that causes the problem:
>   shapes = Shape.objects.filter(geom__bboverlaps=bbx)
> shape_info = shape_info.filter(shape__in=shapes)
> 
> Models are:
>   class Shape(models.Model):
>   …
>   geom = models.PolygonField()
>   color = models.IntegerField()
> 
>   class ShapeInfo(models.Model):
>   …
>   name = models.CharField(max_length=25)
>   shape = models.ForeignKey(Shape)
> 
> The code causing the problem seems to be:
> 
> if (len(params) == 1 and params[0] == '' and lookup_type == 'exact'
> and connection.features.interprets_empty_strings_as_nulls):
> lookup_type = 'isnull'
> value_annot = True
> 
> Is this not an appropriate way to use this?
> 
> Here is the stacktrace:
> /Library/Python/2.6/site-packages/django/db/models/query.py in _result_iter
> self._fill_cache() ...
> ▶ Local vars
> /Library/Python/2.6/site-packages/django/db/models/query.py in _fill_cache
> self._result_cache.append(self._iter.next()) ...
> ▶ Local vars
> /Library/Python/2.6/site-packages/django/db/models/query.py in iterator
> for row in compiler.results_iter(): ...
> ▶ Local vars
> /Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in 
> results_iter
> for rows in self.execute_sql(MULTI): ...
> ▶ Local vars
> /Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in 
> execute_sql
> sql, params = self.as_sql() ...
> ▶ Local vars
> /Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in as_sql
> where, w_params = self.query.where.as_sql(qn=qn, 
> connection=self.connection) ...
> ▶ Local vars
> /Library/Python/2.6/site-packages/django/db/models/sql/where.py in as_sql
> sql, params = child.as_sql(qn=qn, connection=connection) 
> ...
> ▶ Local vars
> /Library/Python/2.6/site-packages/django/db/models/sql/where.py in as_sql
> sql, params = self.make_atom(child, qn, connection) ...
> ▶ Local vars
> /Library/Python/2.6/site-packages/django/db/models/sql/where.py in make_atom
> if (len(params) == 1 and params[0] == '' and lookup_type == 'exact' 
> ...
> ▶ Local vars
> /Library/Python/2.6/site-packages/django/contrib/gis/db/backends/postgis/adapter.py
>  in __eq__
> return (self.ewkb == other.ewkb) and (self.srid == other.srid) ...
> ▼ Local vars
> Variable  Value
> other 
> ''
> self  
>  0x10663bf90>

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



Re: [django] error CSRF token missing or incorrect on POST reciever

2011-01-17 Thread Jirka Vejrazka
Hmm,

  have you checked documentation [1] at all? The token is not the only
thing, you need to enable a middleware too (a few things are needed
basically).

  Cheers

 Jirka

[1] http://docs.djangoproject.com/en/dev/ref/contrib/csrf/

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



a chicken and egg - help please?

2011-01-17 Thread MikeKJ

models are:

from django.db import models
from userprofile.models import Lecturer, UserProfile
from django.contrib.auth.models import User
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django import forms


class Category(models.Model):
name = models.CharField(max_length=50)
lecturer = models.ManyToManyField(Lecturer)
description = models.TextField(null=True, blank=True)
data  = models.TextField(help_text='This is the embedded playlist from
SVP', null=True, blank=True)
priority = models.IntegerField(default=50)

def data_chunk(self):
return "%s" % self.data
#data_chunk.allow_tags = True

def __unicode__(self):
return self.name

def get_category(self):
return self.name

class Meta:
verbose_name_plural = "Categories"


class Video(models.Model):
category = models.ManyToManyField(Category)
lecturer = models.ForeignKey(Lecturer)
title = models.CharField(max_length=100)
short_description = models.TextField(null=True, blank=True)
description = models.TextField(null=True, blank=True)
time = models.CharField(max_length=20, help_text='The length, time, of
the video')
is_trailer = models.BooleanField()
is_descriptor = models.BooleanField(help_text='Use this description as
the total lecture description')
meta_title = models.CharField(max_length=100, blank=True)
meta_desc = models.CharField(max_length=250, blank=True)
meta_keywords = models.CharField(max_length=250, blank=True)

def __unicode__(self):
return self.title

class Meta:
verbose_name_plural = "Videos"

problem view is

from video.models import Video, Category
from userprofile.models import Lecturer, UserProfile
from django.shortcuts import render_to_response
from django.http import HttpResponse, HttpResponseRedirect
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User

def cat_view(request, id):
cat = Category.objects.get(pk=id)
vid = Video.objects.select_related().all().filter(category =
cat).filter(is_trailer=False).filter(is_descriptor=True)
return render_to_response('video/list.html', {'cat': cat, 'vid': vid, },
context_instance=RequestContext(request))

The problem is I can get at the foreign key lecturer with the select_related
but I actually want to order_by the query set vid by a function that I can
only get at within the individual video as in
name = v.lecturer.get_surname()

additional to this the categories per video need to be detailed as well
(category the video belongs to is a ManyToMany)

so my question is how to I order the query set by a foreign key that has a
function to get the surname and also output on the template all the
categories that the video belongs to?
 


-- 
View this message in context: 
http://old.nabble.com/a-chicken-and-egg---help-please--tp30676218p30676218.html
Sent from the django-users mailing list archive at Nabble.com.

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



South introspection doesn't get registrered

2011-01-17 Thread OryBand
Hello.

I am using a simple custom Model:

from django.db.models import ImageField
class ImageWithThumbsField(ImageField):
def __init__(self, verbose_name=None, name=None, width_field=None,
height_field=None, sizes=None, **kwargs):
self.verbose_name=verbose_name
self.name=name
self.width_field=width_field
self.height_field=height_field
self.sizes = sizes
super(ImageField, self).__init__(**kwargs)

And this is my introspection rule, which I add to models.py:

from south.modelsinspector import add_introspection_rules
from lib.thumbs import ImageWithThumbsField
add_introspection_rules(
[
(
(ImageWithThumbsField, ),
[],
{
"verbose_name": ["verbose_name", {"default": None}],
"name": ["name", {"default": None}],
"width_field":  ["width_field",  {"default": None}],
"height_field": ["height_field", {"default": None}],
"sizes":["sizes",{"default": None}],
},
),
],
["^core/.models/.lib.thumbs.ImageWithThumbsField",])

However, when trying to convert my app (named "core") to south, I get
"freeze" errors, like the rule wasn't registered:

 ! Cannot freeze field 'core.additionalmaterialphoto.photo'
 ! (this field has class lib.thumbs.ImageWithThumbsField)
 ! Cannot freeze field 'core.material.photo'
 ! (this field has class lib.thumbs.ImageWithThumbsField)
 ! Cannot freeze field 'core.material.formulaimage'
 ! (this field has class lib.thumbs.ImageWithThumbsField)

 ! South cannot introspect some fields; this is probably because they
are custom
 ! fields. If they worked in 0.6 or below, this is because we have
removed the
 ! models parser (it often broke things).
 ! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork

Does anybody know why?

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



[django] error CSRF token missing or incorrect on POST reciever

2011-01-17 Thread crazedpsyc
I tried to make a quick search box for my site-in-progress and
expected it to be as simple as keeping the database updated.
Unfortunately I ran into the following error as soon as I POSTed a
query:
[QUOTE]
Forbidden (403)

CSRF verification failed. Request aborted.

Help

Reason given for failure:
CSRF token missing or incorrect. In general, this can occur when there
is a genuine Cross Site Request Forgery, or when Django's CSRF
mechanism has not been used correctly. For POST forms, you need to
ensure:

The view function uses RequestContext for the template, instead of
Context.
In the template, there is a {% csrf_token %} template tag inside
each POST form that targets an internal URL.
If you are not using CsrfViewMiddleware, then you must use
csrf_protect on any views that use the csrf_token template tag, as
well as those that accept the POST data.

You're seeing the help section of this page because you have DEBUG =
True in your Django settings file. Change that to False, and only the
initial error message will be displayed.
You can customize this page using the CSRF_FAILURE_VIEW setting.
[/QUOTE]
I tried adding "{% csrf_token %}" to my template, but still got the
same error. I don't really know what the rest of the suggestions mean,
so any translation help would be appreciated

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



Re: override save()

2011-01-17 Thread Santiago Caracol

> Since these attributes
> are "ordinary" attributes, they aren't saved to the database, so they
> aren't loaded from it neither.

It seems that this was the problem. Thank you.

Santiago

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



Re: override save()

2011-01-17 Thread bruno desthuilliers
On 17 jan, 15:36, Santiago Caracol  wrote:
> Sorry the formatting of the code went wrong. Here it is again:
>
> #
>
> class ContentClassifier(models.Model):
>
>     # 
>     def save(self, *args, **kwargs):
>         self.compile()
>         super(ContentClassifier, self).save(*args, **kwargs)
>     # 
>
>     def compile(self):
>         ...
>         self.posrx = re.compile(regex_string, re.IGNORECASE)
>
>     def classify(self, message):
>         # 
>         # self.compile()
>         # 
>
> #


What does ContentClassifier.__init__ looks like ? Thing is - from what
I can tell from your code at least - that it's the compile() method
that creates the posrx (and negrx) attributes. Since these attributes
are "ordinary" attributes, they aren't saved to the database, so they
aren't loaded from it neither. IOW : you have to call the compile
method (directly or indirectly) before trying to access these
attributes.

FWIW, given the required processing, storing the compiled regexps in
the DB might be a good idea anyway...

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



Re: following ManyToManyField related objects

2011-01-17 Thread Daniel Roseman
On Monday, January 17, 2011 3:33:36 PM UTC, ranadave wrote:
>
> Hi, 
>
> Thanks for the reply.  I am using an old version of Django so maybe they 
> got rid of it.
>
> What I have found out is that the object is found if I explicitly define a 
> through table.
>
> ie: 
>
> zzz = models.ManyToManyField('xxx', through = 'zzz.xxx_linked', 
> related_name = 'xxx_of_zzz', blank = True)
>
> Works but
>
> zzz = models.ManyToManyField('xxx', related_name = 'xxx_of_zzz', blank = 
> True)
>
> Does not.
>
> Seems like  a bug to me.
>
> Rana
>

It might well be a bug, but _collect_sub_objects is not part of any 
published/documented API - as implied by the leading backslash - so you 
should not be relying on its behaviour.
--
DR.

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



Re: following ManyToManyField related objects

2011-01-17 Thread ranadave
Hi, 

Thanks for the reply.  I am using an old version of Django so maybe they got 
rid of it.

What I have found out is that the object is found if I explicitly define a 
through table.

ie: 

zzz = models.ManyToManyField('xxx', through = 'zzz.xxx_linked', related_name 
= 'xxx_of_zzz', blank = True)

Works but

zzz = models.ManyToManyField('xxx', related_name = 'xxx_of_zzz', blank = 
True)

Does not.

Seems like  a bug to me.

Rana

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



Re: override save()

2011-01-17 Thread Daniel Roseman
On Monday, January 17, 2011 2:24:39 PM UTC, Santiago Caracol wrote:
>
> Hello, 
>
> I have got a model called ContentClassifier which uses regular 
> expressions to classify the content of messages. It has a method 
> compile() that compiles an instance's regular expressions into 
> self.posrx. When the classify method calls compile, i.e. when each 
> ContentClassifier compiles its regular expressions every time it's 
> classify-method is called, then the ContentClassifiers work as 
> expected. (I.e. if, in the code given below snippet 2 instead of 
> snippet 1 is used). If, on the other hand, I want each instance to 
> compile its regular expressions when it is saved (i.e. if I use 
> snippet 1 instead of snippet 2), Django says 
>
> AttributeError: ... ContentClassifier' object has no attribute 'posrx' 
>
> Why? 
>
>
When does Django raise that - on save, or when you later try and use the 
object? Why didn't you post the full traceback?

What actually is `self.posrx`? Is it a model field? If so, how are you 
storing the compiled regexes? 
--
DR. 

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



Re: override save()

2011-01-17 Thread Santiago Caracol
Sorry the formatting of the code went wrong. Here it is again:

#

class ContentClassifier(models.Model):

# 
def save(self, *args, **kwargs):
self.compile()
super(ContentClassifier, self).save(*args, **kwargs)
# 

def compile(self):
...
self.posrx = re.compile(regex_string, re.IGNORECASE)

def classify(self, message):
# 
# self.compile()
# 

#

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



override save()

2011-01-17 Thread Santiago Caracol
Hello,

I have got a model called ContentClassifier which uses regular
expressions to classify the content of messages. It has a method
compile() that compiles an instance's regular expressions into
self.posrx. When the classify method calls compile, i.e. when each
ContentClassifier compiles its regular expressions every time it's
classify-method is called, then the ContentClassifiers work as
expected. (I.e. if, in the code given below snippet 2 instead of
snippet 1 is used). If, on the other hand, I want each instance to
compile its regular expressions when it is saved (i.e. if I use
snippet 1 instead of snippet 2), Django says

AttributeError: ... ContentClassifier' object has no attribute 'posrx'

Why?

#

class ContentClassifier(models.Model):

def save(self, *args,
**kwargs):  # snippet 1
 
self.compile()
# snippet 1
super(ContentClassifier, self).save(*args, **kwargs)   #
snippet 1


def compile(self):
...
self.posrx = re.compile(regex_string, re.IGNORECASE)

def classify(self, message):
# self.compile() # snippet 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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: sitemap() got an unexpected keyword argument 'template_name'

2011-01-17 Thread spenoir
Thanks Shawn, thats a good solution but just seems unnecessary and the
docs are misleading.

adam


On Jan 14, 6:51 pm, Shawn Milochik  wrote:
> On Jan 14, 2011, at 12:19 PM, spenoir wrote:
>
> > I pretty sure I've set up my sitemaps correctly but I get this error
> > when I try to specify a custom template for thesitemap. anyone any
> > ideas? I'm using Django 1.2
>
> Because the function declaration doesn't accept template_name. You can 
> replace the view with your own and have it accept the argument.
>
> I see it's in the GIS app, which I know nothing about, but I have had to do 
> this in the past when a template argument was not an accepted kwarg elsewhere.
>
> Shawn

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



Re: Query Set involving Model Method

2011-01-17 Thread rmschne
Much thanks to all.

I could not get something like:
gs=DinnerHost.objects.all().filter(complete()=True

to work. probably think fingers on my side to get the nomenclature
write; but I suspect not possible.

While I liked the idea of computing a new field "complete" in the
database which is updated on Save.  While initially thought to be a
good idea I changed my mind because:
1.  reqireired running the Python/Django program to update ... yet
some of the data in the db gets update via many other tools and so
there will be an consistency issue.
2.  writing a stored procedure to update in MysQL ... too complicated
3.  doing it as a batch update in Python/Django ... means hitting all
the records and then sort of messes up the value of the timestamp on
each record.  I'd rather that timestamp mean something more real than
that.
4.  add a related table which does this computation (fixing problem
3) ... too complicated

in the end what I did was in the program where I want to do something
with the "not complete" records, I write a small routine in the
program that extracts a query set with all records, then loops through
all records and finds where, using the Model definition, "if not
h.complete():" where "h" is the record from the loop in the query set.
Then I just append to a list the ID of that record.  Then i re-query
the database for those records where ID is in the list.

Works.  understandable for those who follow, etc.  No db changes and
no added maintenance.

 
hosts1=DinnerHost.objects.all().filter(year__exact=CURRENT_YEAR)
tablelist=[]
for h in hosts1:
if not h.complete():
tablelist.append(h.tablename)
 
hosts2=DinnerHost.objects.filter(year__exact=CURRENT_YEAR).filter(tablename__in=tablelist)

Now hosts2 has what I want.

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



Re: jQuery UI Stylesheet

2011-01-17 Thread Torbjorn
Does any of the link to the static files work?
Can you point your browser to: {{ STATIC_URL }}jqueryui/css/style.css
(exchange STATIC_URL of course)?
Can you point it to {{ STATIC_URL }}jqueryui/css/ui-lightness/jquery-
ui-1.8.8.custom.css
{{ STATIC_URL }}jqueryui/js/jquery-1.4.4.min.js
{{ STATIC_URL }}jqueryui/js/jquery-ui-1.8.8.custom.min.js

If any of the above works, then there must be a typo in the path. If
none of them works then investigate the STATIC_URL variable.

/Torbjörn



On 17 Jan, 04:26, Fletcher Haynes  wrote:
> Hello,
> I'm having some trouble getting jQuery UI to work. It doesn't seem to be
> finding the CSS static file...here is my base.html and the page that
> inherits from it. It does find my style.css file fine, which is my
> non-jQuery stylesheet.
>
> http://dpaste.com/324572/
>
> I'd appreciate any help.

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



Re: django url question

2011-01-17 Thread Matias Aguirre
The '?' should be quoted as '%3F' (urllib.urlquote('?')) or it will be treated
as a query parameter (check request.GET in your view ;))

Matías

Excerpts from yanghq's message of Mon Jan 17 05:59:23 -0200 2011:
> hi,
> 
>  In urls.py a pattern like this:
> (r'^test/(?P\w{3,4})/(?P.*)$', 'djprj.test.views.info'),
> 
> In views.py,info defined as follows:
> def info(request,protocol='',url=''):
> 
> 
> when I access "test/http/bbs.test.com/viewforum.php?f=12"
> 
> url is bbs.test.com/viewforum.php,"?f=12" is missing
> 
> can someone explain this? than you for any help
> 
> 
> ---
> Confidentiality Notice: The information contained in this e-mail and any 
> accompanying attachment(s) 
> is intended only for the use of the intended recipient and may be 
> confidential and/or privileged of 
> Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of 
> this communication is 
> not the intended recipient, unauthorized use, forwarding, printing,  storing, 
> disclosure or copying 
> is strictly prohibited, and may be unlawful.If you have received this 
> communication in error,please 
> immediately notify the sender by return e-mail, and delete the original 
> message and all copies from 
> your system. Thank you. 
-- 
Matías Aguirre 

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



Re: Odd problem with static files and Lighttpd

2011-01-17 Thread Cal Leeming [Simplicity Media Ltd]
Hi Alex,

Have you checked to make sure that /home/osmtools/mymedia has read-able
permissions for the lighttpd user?

Cal

On Mon, Jan 17, 2011 at 10:41 AM, sdonk  wrote:

> Hi to everybody,
> I'm facing with a curious problem with Lighttpd and static files
> serving.
> Media admin is served by Lighttpd, but mymedia is not served by
> Lighttpd.
>
> This is a snippet of my lighttpd.conf
>
> alias.url = (
>"/mymedia/" => "/home/osmtools/mymedia/",
>"/media/" => "/usr/lib/python2.5/site-packages/django/contrib/
> admin/media/",
> )
>
> url.rewrite-once = (
>"^(/media.*)$" => "/$1",
>   "^(/mymedia.*)$" => "/$1",
>"^/favicon\.ico$" => "/media/favicon.ico",
>"^(/.*)$" => "/osmtools.fcgi$1",
> )
>
> The result is that in the admin site css and js work well (http://
> osmtool.com/admin) but in the user site neither the css and the js are
> loaded (http://osmtool.com).
>
> Any idea?
>
> Thanks
>
> Alex
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Using arbitrary queries to populate InlineModelAdmin instances

2011-01-17 Thread Dan Farina
Hello list,

I have a use case where I want to show a few other objects as inline
editable fields, but have been stymied by the fact that there exists
no direct foreign key relationship between them.  Here is an example:
Outermost_Model -> Inner_Model -> Django User Model, where '->' is a
foreign key reference.  I want to edit Outermost_Model instances from
a Django User instance. I feel as though I studied the documentation
at http://docs.djangoproject.com/en/dev/ref/contrib/admin/ and even
some of the admin source code carefully, but am left unenlightened
after some experimentation on how to accomplish this without severe
hackery, or if there's another way I should be approaching this
entirely.

In general, I do not fully understand why there are no *apparent*
provisions to allow for a developer to provide model instances
(writing their own queries...) that they desire to be inline-editable
given the "parent" instance.  If passed a User object, for example, I
could fairly easily return the Outermost_Model instances I want
rendered inline.

--
Seeking enlightenment,
fdr

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



Odd problem with static files and Lighttpd

2011-01-17 Thread sdonk
Hi to everybody,
I'm facing with a curious problem with Lighttpd and static files
serving.
Media admin is served by Lighttpd, but mymedia is not served by
Lighttpd.

This is a snippet of my lighttpd.conf

alias.url = (
"/mymedia/" => "/home/osmtools/mymedia/",
"/media/" => "/usr/lib/python2.5/site-packages/django/contrib/
admin/media/",
)

url.rewrite-once = (
"^(/media.*)$" => "/$1",
   "^(/mymedia.*)$" => "/$1",
"^/favicon\.ico$" => "/media/favicon.ico",
"^(/.*)$" => "/osmtools.fcgi$1",
)

The result is that in the admin site css and js work well (http://
osmtool.com/admin) but in the user site neither the css and the js are
loaded (http://osmtool.com).

Any idea?

Thanks

Alex

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



django url question

2011-01-17 Thread yanghq
hi,

 In urls.py a pattern like this:
(r'^test/(?P\w{3,4})/(?P.*)$', 'djprj.test.views.info'),

In views.py,info defined as follows:
def info(request,protocol='',url=''):


when I access "test/http/bbs.test.com/viewforum.php?f=12"

url is bbs.test.com/viewforum.php,"?f=12" is missing

can someone explain this? than you for any help


---
Confidentiality Notice: The information contained in this e-mail and any 
accompanying attachment(s) 
is intended only for the use of the intended recipient and may be confidential 
and/or privileged of 
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of 
this communication is 
not the intended recipient, unauthorized use, forwarding, printing,  storing, 
disclosure or copying 
is strictly prohibited, and may be unlawful.If you have received this 
communication in error,please 
immediately notify the sender by return e-mail, and delete the original message 
and all copies from 
your system. Thank you. 
---

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



Re: Current Django 1.3 Alpha 2 Documentation as PDF

2011-01-17 Thread Sam Walters
at the very least use mysqldump on you db or a table before you play
with the code.
though depending on what you are doing backup should be even more
structured than ad-hoc sql dumps.

http://www.thegeekstuff.com/2008/09/backup-and-restore-mysql-database-using-mysqldump/

On Mon, Jan 17, 2011 at 10:45 PM, Vovk Donets  wrote:
>
>
> 2011/1/17 ckar...@googlemail.com 
>>
>> Sry for the wrong url. It's now
>> http://g2007.ch/media/static/uploads/django.pdf
>>
>
> Great work, many thanks!
>
> --
> Vovk Donets
>  python/django developer
> skype:  suunbeeam
> icq:      232490857
> mail:    donets.vladi...@gmail.com
> www:   vovk.org.ru
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Current Django 1.3 Alpha 2 Documentation as PDF

2011-01-17 Thread Vovk Donets
2011/1/17 ckar...@googlemail.com 

> Sry for the wrong url. It's now
> http://g2007.ch/media/static/uploads/django.pdf
>
>
Great work, many thanks!

-- 
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com
www:   vovk.org.ru

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



Re: Current Django 1.3 Alpha 2 Documentation as PDF

2011-01-17 Thread ckar...@googlemail.com
Sry for the wrong url. It's now http://g2007.ch/media/static/uploads/django.pdf

On 13 Jan., 19:53, "ckar...@googlemail.com" 
wrote:
> Better use this url:http://riesenhirni.de/media/static/uploads/django.pdf
>
> On 13 Jan., 19:47, "ckar...@googlemail.com" 
> wrote:
>
>
>
>
>
>
>
> > Brand new @http://karrié.de/media/static/uploads/django.pdf
>
> > On 27 Dez. 2010, 22:58, "ckar...@googlemail.com"
>
> >  wrote:
> > > Current Doc:http://ubuntuone.com/p/Vb6/(Is's1.3.0Beta 1 now [1])
>
> > > Changelog according to [2]
>
> > > [1]http://code.djangoproject.com/changeset/15066/django/trunk?old=14893#...
> > > [2]  
> > > http://code.djangoproject.com/changeset/15066/django/trunk/docs?old=1...

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



Re: Execute code after the model with m2m is completely saved

2011-01-17 Thread Vovk Donets
2011/1/17 Martin Tiršel 

> I found two ways how to do it:
>
> *) m2m_changed signal - this is the best way
>
> *) save_model(self, request, obj, form, change) method for ModelAdmin - obj
> has current relations, form contains the new relations
>
> Martin
>
> The third way would be creating a custom model field that handle work with
images

-- 
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com

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



Re: Thinking to change my db schema

2011-01-17 Thread Dan Fairs
Hi,

> The problem is with date, frequency and ends. With this info I can
> know all the dates in which transactions occurs and use it to fill a
> cashflow table. Doing things this way involves creating a lot of
> structures(dictionaries, lists and tuples) and iterating them a lot.
> Maybe there is a very simple way of solving this with the actual
> schema, but I couldn't realize how.
> 
> I think that the app would be easier to code if, at the creation of a
> transaction, I could save all the dates in the db. I don't know if
> it's possible or if it's a good idea.

You might want to look at python-dateutil, which lets you model repeating 
events.

  http://niemeyer.net/python-dateutil

For Django, you might find that glamkit-eventtools is worth a look. I've used 
it to model holiday/vacation departure information for a travel site. You might 
find inspiration in its approach, even if you can't use it directly.

Cheers,
Dan
--
Dan Fairs | dan.fa...@gmail.com | www.fezconsulting.com


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



Re: Problem with overriding the default Django admin page.

2011-01-17 Thread Vovk Donets
You must specify in the TEMPLATE_DIRS path to the dir where templates were
placed, not abs path file
So
TEMPLATE_DIRS = (
"/Users/xuchen81/Django/mysite/",

)
should work, coz'  "In order to override one or more of them, first create
an admin directory in your project's templates directory. This can be any of
the directories you specified in
TEMPLATE_DIRS
."

2011/1/17 Chen Xu 

> Hi, Django group:
> I am floowing the tutorial 1 on Django site, which is a poll application
> I have problem with overriding the admin page
> I copied   admin/base_site.html   from (django/contrib/admin/templates)
> to   /Users/xuchen81/Django/mysite/admin/base_site.html
>
> and add this line "/Users/xuchen81/Django/mysite/admin/base_site.html"
> to TEMPLATE_DIRS in my settings.py file. It looks like the following:
>
> TEMPLATE_DIRS = (
> "/Users/xuchen81/Django/mysite/admin/base_site.html",
> )
>
> but the admin is just doesn't use this file, it still uses the default
> base_site.html.
>
> Could anyone please help me?
>
> --
*Vovk Donets*
 python/django developer

skype:  suunbeeam
icq:  232490857
mail:donets.vladi...@gmail.com

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



Re: Execute code after the model with m2m is completely saved

2011-01-17 Thread Martin Tiršel

I found two ways how to do it:

*) m2m_changed signal - this is the best way

*) save_model(self, request, obj, form, change) method for ModelAdmin -  
obj has current relations, form contains the new relations


Martin


On Sun, 16 Jan 2011 19:33:09 +0100, Martin Tiršel   
wrote:



Hello,

I am using (only) django admin to insert data and have:

class ImageSize(models.Model):
 ...

class Image(models.Model):
 size = models.ManyToManyField(ImageSize)
 ...

I need to save original image that have been uploaded (this is ok) and  
then make resized copies depending on selected sizes. But my problem is,  
I don't know where to put my resize code. I can not use save method on  
Image class, because at this point, there are no ImageSize instances. So  
I wanted to use ImageAdmin class but it seems that save_model method  
behaves the same way - no related objects at this point. Is there a  
point in admin, where I have all models completely saved and can do  
custom code? Where is that point?



Thanks,
Martin


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



Re: m2m_changed signal called multiple times?

2011-01-17 Thread Martin Tiršel

Yes, I just got it:

2011-01-17 11:57:07,389 DEBUG pre_clear
2011-01-17 11:57:07,392 DEBUG post_clear
2011-01-17 11:57:07,393 DEBUG pre_add
2011-01-17 11:57:07,395 DEBUG post_add

It is the first time I am working with signals and forget about action  
argument :(


But why is there pre_clear and post_clear action when I am creating a new  
Image record?


Thanks,
Martin


On Mon, 17 Jan 2011 11:53:05 +0100, bruno desthuilliers  
 wrote:



On 17 jan, 11:09, Martin Tiršel  wrote:

(snip)

m2m_changed.connect(ready_to_resize, sender=Image.size.through,  
dispatch_uid="38fy3f73")


I am using Django admin interface. I insert 2 sizes into ImageSize and  
now I am creating new Image record. I select both sizes and in my log I  
get 4 times:


2011-01-17 10:57:01,749 DEBUG ready_to_resize called
2011-01-17 10:57:01,751 DEBUG ready_to_resize called
2011-01-17 10:57:01,753 DEBUG ready_to_resize called
2011-01-17 10:57:01,754 DEBUG ready_to_resize called

Does anybody know why? It is always 4 times.



First change your logging message to this:

def ready_to_resize(sender, instance, action, reverse, model,
pk_set,
**kwargs):
 logging.debug("ready_to_resize called with action '%s'" %
action)


Then read the FineManual about m2m_changed and the meaning of the
'action' argument.
http://docs.djangoproject.com/en/dev/ref/signals/#m2m-changed


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



Re: m2m_changed signal called multiple times?

2011-01-17 Thread bruno desthuilliers
On 17 jan, 11:09, Martin Tiršel  wrote:

(snip)

> m2m_changed.connect(ready_to_resize, sender=Image.size.through,  
> dispatch_uid="38fy3f73")
>
> I am using Django admin interface. I insert 2 sizes into ImageSize and now  
> I am creating new Image record. I select both sizes and in my log I get 4  
> times:
>
> 2011-01-17 10:57:01,749 DEBUG ready_to_resize called
> 2011-01-17 10:57:01,751 DEBUG ready_to_resize called
> 2011-01-17 10:57:01,753 DEBUG ready_to_resize called
> 2011-01-17 10:57:01,754 DEBUG ready_to_resize called
>
> Does anybody know why? It is always 4 times.


First change your logging message to this:

def ready_to_resize(sender, instance, action, reverse, model,
pk_set,
**kwargs):
 logging.debug("ready_to_resize called with action '%s'" %
action)


Then read the FineManual about m2m_changed and the meaning of the
'action' argument.
http://docs.djangoproject.com/en/dev/ref/signals/#m2m-changed

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



Re: urgent, undo delete

2011-01-17 Thread Vovk Donets
.delete() performs SQL DELETE command on DB so there is no "undo"  to this
operation.

On Jan 17, 10:18 am, gintare  wrote:
> > Is it possible to undo  model.filter( field_gte = datemin ).delete()
> > if it was the action, which happened from function in views.py, by
> > accidentaly uncommenting the line
>


-- 
*Vovk Donets*
 python/django developer

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



m2m_changed signal called multiple times?

2011-01-17 Thread Martin Tiršel

Hello,

I have:

* settings.py:

...
import logging

logging.basicConfig(
level = logging.DEBUG,
format = '%(asctime)s %(levelname)s %(message)s',
filename = LOG_FILE,
filemode = 'w'
)

* models.py:

class ImageSize(models.Model):
...

class Image(models.Model):
size = models.ManyToManyField(ImageSize)
...

def ready_to_resize(sender, instance, action, reverse, model, pk_set,   
**kwargs):

logging.debug("ready_to_resize called")

m2m_changed.connect(ready_to_resize, sender=Image.size.through,  
dispatch_uid="38fy3f73")


I am using Django admin interface. I insert 2 sizes into ImageSize and now  
I am creating new Image record. I select both sizes and in my log I get 4  
times:


2011-01-17 10:57:01,749 DEBUG ready_to_resize called
2011-01-17 10:57:01,751 DEBUG ready_to_resize called
2011-01-17 10:57:01,753 DEBUG ready_to_resize called
2011-01-17 10:57:01,754 DEBUG ready_to_resize called

Does anybody know why? It is always 4 times. I can add third item into  
ImageSize or select only one ImageSize for Image, there are always 4  
records in the log.


Thanks,
Martin

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



Re: urgent, undo delete

2011-01-17 Thread ge...@aquarianhouse.com
you should have a backup of your data in the case

where is no way to get the data back

On Jan 17, 10:18 am, gintare  wrote:
> Is it possible to undo  model.filter( field_gte = datemin ).delete()
> if it was the action, which happened from function in views.py, by
> accidentaly uncommenting the line
>
> regards,
> gintare statkute

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



urgent, undo delete

2011-01-17 Thread gintare
Is it possible to undo  model.filter( field_gte = datemin ).delete()
if it was the action, which happened from function in views.py, by
accidentaly uncommenting the line

regards,
gintare statkute

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



Re: Problem with overriding the default Django admin page.

2011-01-17 Thread robin nanola
try this,

TEMPLATE_DIRS = (
"/Users/xuchen81/Django/mysite/admin",
)

look  here: http://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs

On Mon, Jan 17, 2011 at 4:25 PM, Chen Xu  wrote:

> Hi, Django group:
> I am floowing the tutorial 1 on Django site, which is a poll application
> I have problem with overriding the admin page
> I copied   admin/base_site.html   from (django/contrib/admin/templates)
> to   /Users/xuchen81/Django/mysite/admin/base_site.html
>
> and add this line "/Users/xuchen81/Django/mysite/admin/base_site.html"
> to TEMPLATE_DIRS in my settings.py file. It looks like the following:
>
> TEMPLATE_DIRS = (
> "/Users/xuchen81/Django/mysite/admin/base_site.html",
> )
>
> but the admin is just doesn't use this file, it still uses the default
> base_site.html.
>
> Could anyone please help me?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Problem with overriding the default Django admin page.

2011-01-17 Thread Chen Xu
Hi, Django group:
I am floowing the tutorial 1 on Django site, which is a poll application
I have problem with overriding the admin page
I copied   admin/base_site.html   from (django/contrib/admin/templates) to
/Users/xuchen81/Django/mysite/admin/base_site.html

and add this line "/Users/xuchen81/Django/mysite/admin/base_site.html"
to TEMPLATE_DIRS in my settings.py file. It looks like the following:

TEMPLATE_DIRS = (
"/Users/xuchen81/Django/mysite/admin/base_site.html",
)

but the admin is just doesn't use this file, it still uses the default
base_site.html.

Could anyone please help me?

Thanks

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



Re: jquery problem

2011-01-17 Thread sureronald
Confirm the plugin's jquery version requirement. Maybe the plugin
requires another jquery version

On Jan 17, 8:48 am, Tony Lambropoulos  wrote:
> Prashanth,
> This has to do with django because they work outside of django.
>
> On Mon, Jan 17, 2011 at 6:12 AM, Prashanth  wrote:
> > Hi Tony,
>
> > On Mon, Jan 17, 2011 at 8:57 AM, Tony  wrote:
>
> >>  Unfortunately, I can't get any other plugins to work that I download.  No
> >> other jquery
> >> plugins seem to work and Im pretty sure I have the directory paths
> >> right and everything.
>
> > Very lame, How would someone know why something dint work?
>
> >> Then I try to add other plugins and none will work.
>
> > How is this related to Django? Hit Jquery mailing list.
>
> > --
> > regards,
> > Prashanth
> > twitter: munichlinux
> > blog: honeycode.in
> > irc: munichlinux, JSLint, munichpython.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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