Re: timeit module put my app into infinite loop

2008-10-07 Thread K*K

Thank you, Bruno.

My program running ok with your guide.

My goal is to compare the ORM performance of Django and
TurboGears(SQLObject or SQLAlchemy).

So write the test scripts.

To process 1000 times data, django's test result is below:

Insert Speed: 0.766191005707
Select Speed: 0.027615070343
Update Speed: 3.05239295959
Drop Speed: 0.941470146179

It looks not very good, my codes need more optimization.

PS: I don't want to delete the p1 from database, just want to unset
the variable. So use the del p1 and not p1.delete()


On Oct 8, 5:54 am, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 7 oct, 17:54, "K*K" <[EMAIL PROTECTED]> wrote:
>
> > Hi, all
>
> > I'm writing a program to test django's mysql performance, use timeit
> > to profile. But it make my app into infinite loop.
>
> I'm probably a bit tired, but I don't see how the below snippet could
> cause an infinite loop - unless you did something very wrong in the
> parts of the code that are called but you didn't post.
>
> > always write data
> > into database.
>
> Err... Wait... This is what asked for, didn't you ? (cf below...)
>
> > 
> > import timeit
>
> > from django.shortcuts import render_to_response
> > from testDjango.benchmark.models import Django
>
> > loop_range = 10
>
> > def benchmark(request):
> >         global loop_range
>
> 
> You don't need the global statement here since you're not rebinding
> loop_range. FWIW, you could declare it as a local variable anyway
> 
>
> >         insert_timer = timeit.Timer("benchmark_insert()", "from
> > testDjango.bench import benchmark_insert")
> >         insert_timer.repeat(loop_range)
> >         insert_speed = insert_timer.timeit()
>
> I suspect you misread the doc for timer.repeat and timer.timeit.
> Timer.timeit will already repeat the given statement quite a few times
> (100 by default). Timer.repeat will call Timer.timeit x times. So
> with your above code, you will first call benchmark_insert() 10 *
> 100 times, discard the result, then call benchmark_insert()
> 100 more times.
>
> If you meant to only call Timer.timeit once and make it call
> benchmark_insert only 10 times, you want :
>
>       insert_timer = timeit.Timer(
>           "benchmark_insert()",
>           "from testDjango.bench import benchmark_insert"
>           )
>       insert_speed = insert_timer.timeit(loop_range)
>
> > def benchmark_insert():
> >         p1 = Django(foobar='Test foo',)
> >         p1.save()
> >         del p1
>
> I think you meant p1.delete().  'del p1' unbind the name p1 in the
> current namespace - which is pretty useless here FWIW -, but won't
> remove anything from your database.
>
> HTH
>
> > 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Generating widget based on class type for a Custom Form

2008-10-07 Thread Ronny Haryanto

On Tue, Oct 7, 2008 at 7:31 PM, Leon Yeh | New Avenue.net
<[EMAIL PROTECTED]> wrote:
> Hi Ronny, terima kasih... :-)

Sama-sama :-)

> I am trying to generate different output for css styling purpose.
>
> For example for select widget I need to generate
>   
>
> and for other controls, I need to generate
>   
>
> I don't know how field.as_widget would help.

Right. I can see how this is useful for creating a generic form template.

In that case, I'd probably write a custom tag to do the job, probably
something along the line of:

{% if_widget_select field %}

This is something similar that I had done previously:

from djblets.util.decorators import blocktag

register = Library()

@register.tag
@blocktag
def if_is_select_field(context, nodelist, field):
if isinstance(field, forms.MultipleChoiceField):
return nodelist.render(context)
else:
return ''

You can find djblets tag helpers here: http://www.chipx86.com/blog/?p=245

Cheers,
Ronny

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



Re: i18n in templates and views

2008-10-07 Thread J

This is perfect! Thank you Malcolm.

One more question--simpler this time:

How would I include the "date" field from the first model ("Post") in
the queryset created from "PostI18N", using something similar to:

queryset =
PostI18N.objects.filter(lang=get_language()).order_by('post__date')

Would that date field already be included? How would I access it from
the template?

Thanks,
J



Malcolm Tredinnick wrote:
> On Tue, 2008-10-07 at 18:23 -0400, J wrote:
>   
>> Hi everyone,
>>
>> I'm working on a bilingual website in django for which the visitor has
>> the option of choosing which language he/she prefers. All the
>> interface, as well as the content, will be available in Spanish and
>> English. The interface is set up to be handled by gettext and django's
>> has excellent support for that.
>>
>> I'm having a hard time right now with the bilingual "posts" system,
>> which is for contributors to add articles in different categories.
>> Each post will have two items for it, one in each language.
>>
>> The way I've got it set up in the models is:
>>
>> ##
>> # The parent of all the posts,
>> # only one item per post in here
>> ##
>> class Post(models.Model):
>> referencetitle = models.CharField(max_length=30)
>> date = models.DateTimeField('Date')
>>
>> ##
>> # language content for each post
>> # there will be two items per post in here, one for each language
>> ##
>> class PostI18N(models.Model):
>> post = models.ForeignKey(Post)
>> slug = models.SlugField(
>> 'Slug',
>> help_text='Automatically built from the title.'
>> )
>> title = models.CharField('Title', max_length=30)
>> body = models.TextField('Body Text')
>> lang = models.CharField(max_length = 5, choices =
>> settings.LANGUAGES)
>>
>>
>>
>> How do it do this in views so that I only get the "PostI18N" items
>> that are in the current language chosen by the users,
>> 
>
> There's a currently undocumented function in django.utils.translation
> called get_language() that you can use to return the currently active
> locale. So something like
>
> PostI18N.objects.filter(lang=get_language())
> 
> will filter out only the articles matching the current language. You can
> safely use that function, even though I said it was undocumented. That's
> because it will be documented inside the next 48 hours. I'm currently
> rewriting the i18n documentation and just made a note to include that (I
> hadn't realised until just now that we had left it out).
>
>   
>>  and how do I iterate through both of these models at the same time in
>> templates so that I can access the Date field from the related table
>> ("Post") to sort them, but display the main content fields from
>> "PostI18N".
>> 
>
> Sorting is generally best done in the view. Even better, sorting can be
> done by the database at selection time. Modifying the above queryset,
> you could write
>
> PostI18N.objects.filter(lang=get_language()).order_by('post__date')
> 
>
>   
>> I'm initially attempting to display this data using generic views
>> (django.views.generic.date_based.archive_index). Do you think these
>> generic views can handle something like this? If not, how would I
>> write an equivalent custom view?
>> 
>
> Generic views can handle anything you can create as a queryset. However,
> the above queryset actually depends on some information that is not
> available until the view is active (you can't compute it once). This is
> because the results of get_language() depend on the locale. So you would
> need to wrap things up like this:
>
> def my_view(request, ):
>qs = PostI18N... # <-- as above
>return archive_index(qs, )
> 
> That way, the get_language() call is executed each time in the right
> environment.
>
> Regards,
> Malcolm
>
>
>
> >
>
>   


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



Re: random quote help

2008-10-07 Thread Steve Holden

Bobby Roberts wrote:
> Hi.  I have a project with one template only.  I am trying to get a
> random quote from the database pushed up to the template so that a new
> quote is shown with each new page url or each page refresh.  Can
> someone point out in the docs where this is covered or help me
> understand the urls.py structure to do this?
>   
This surely doesn't have anything to do with your URLconf - the
randomness has to be inserted in your view, since (I am presuming) you
would like the same URL to show a different quote on separate loads.

I do the same thing with books on holdenweb.com (though in fact this is
done in a context manager, not in the view itself, since it is common to
all pages).

Is your problem the mechanics of *making* the random choice, or are you
uncertain how to get it into your output?

regards
 Steve


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



Organizing apps without using projects

2008-10-07 Thread Brent Hagany

My apologies if this has been brought up before on this group - my
searching did not turn up anything, but my search skills are
notoriously suspect.

I have been reorganizing my code so that it does not depend on the
project (mostly with success) after watching James Bennet's talk at
Djangocon about reusable apps.  I've chosen to follow the model James
talks about with respect to Ellington - that is, I have a bunch of
interdependent apps that are all under the umbrella of one python
module.  Right now, I actually have one umbrella "app", with a bunch
of proper apps underneath it, so that I only have to put the umbrella
module in INSTALLED_APPS, rather than each sub-app.  I'm not quite
sure if that's the best way to do this, but more on that in a bit.

The only things I don't have working again are my unit tests, and I'd
like to get some feedback on what would be the best way to get them to
work with this sort of setup.  The problem is that my tests and models
are currently in umbrella.app.tests/models, but the test runner
expects them to be in umbrella.tests/models.  Here are a few ways to
get this done, that I can see:

1. Move all my models and tests from umbrella.app to umbrella.  This
almost completely undoes the benefits of breaking the application into
small apps.

2. Rather than just putting umbrella in INSTALLED_APPS, put every
umbrella.app in.  This just seems silly to me, since these apps are
too interdependent to be very useful apart from each other.

3. Write a new test runner that looks in the correct places.  This
makes it harder than just "manage.py test" for other people to test
the app themselves.

If you've dealt with this kind of thing before, or have a good idea/
recommendation, please let me know.  I doubt that there is a
completely satisfactory solution (to me), but I'd like some opinions
on what sucks less.

Thanks,
Brent

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



Re: random quote help

2008-10-07 Thread Bobby Roberts

> Is your problem the mechanics of *making* the random choice, or are you
> uncertain how to get it into your output?

Hi Steve -

Yeah i know the randomization needs to be in the view and then pushed
back to the template.  How would I call the view on each page in the
website?


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



Re: Extend contrib.comments?

2008-10-07 Thread Eric Abrahamsen


On Oct 7, 2008, at 11:38 PM, fitzage wrote:

>
> I want to add one additional piece of data to the comment form.
> Basically a checkbox that says whether or not the commenter wants to
> be notified of followup comments.

I just did exactly this, and found that what works best is not just to  
add an input field to the form template, but to actually subclass the  
builtin CommentForm and add the field there. That way the field will  
be a part of the form no matter how and where you use it, and will  
remain in the 'cleaned data' dictionary when the form is validated.  
Subclass the builtin form, add the field, and then do:

from django.contrib import comments

def my_get_form():
 return MyCommentForm

comments.get_form = my_get_form

> I know how to add the checkbox. I just created a comments/form.html
> template and added the checkbox to it. I know that the data is getting
> passed correctly.
>
> Now how do I grab that on the backend without having to modify the
> comment app directly? There is probably a simple, django-standard way
> to do this, but I'm at a loss. I already have a function that emails
> admin users when a comment is posted, but I'm not sure I understand it
> well enough to piggy-back off of that, and I'm not even sure that I
> can.

Signals are beautiful! I made Commenter (email field) and  
CommentNotification (commenter and entry foreign keys) models, and did  
this:

def make_notification(sender, comment, request, **kwargs):
 notify = request.POST.get("notify", None)
 email = request.POST.get("email", None)
 if notify and email:
 commenter, created = Commenter.get_or_create(email=email)
 notification, created =  
CommentNotification.get_or_create(commenter=commenter,  
entry=comment.content_object)

def notify_commenters(sender, comment, request, **kwargs):
 notifications =  
CommentNotification 
.objects.select_related().filter(entry=comment.content_object)
 if notifications:
 for n in notifications:
 msg = render_to_string('comments/email.txt', 
{'comment':comment,'notification':n})
 send_mail("There's a new comment!",msg,"[EMAIL PROTECTED] 
",recipient_list=[n.commenter.email],fail_silently=True)

comment_was_posted.connect(make_notification)
comment_was_posted.connect(notify_commenters)

The email contains a link with a security hash which they can use to  
un-register themselves for that particular blog entry.

I only just wrote all this and haven't tested it yet, but the basic  
principle ought to be sound...

Hope that helps,
Eric

>
>
> >


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



random quote help

2008-10-07 Thread Bobby Roberts

Hi.  I have a project with one template only.  I am trying to get a
random quote from the database pushed up to the template so that a new
quote is shown with each new page url or each page refresh.  Can
someone point out in the docs where this is covered or help me
understand the urls.py structure to do this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



pre_delete, post_delete signals for contrib.contenttypes

2008-10-07 Thread Andrew Fong

Let's say you have model A with a foreign key link to model B -- that
is,  A depends on B. If you delete model B, then model A is removed as
well. You will also get two sets of deletion signals. One for A and
one for B.

When using a generic relation however, the signals for A are not sent
when you delete B. However, model A itself is still removed from the
database.

Any opinions about adding such a deletion signal for A?

-- Andrew



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



Problem generating permalink for date-based view

2008-10-07 Thread Brandon Taylor

Hi everyone,

I'm using the generic date-based views.

Here's a snippet of my "Entry" model for a blog:

#models.py
pub_date = models.DateTimeField(auto_now_add=True)

@models.permalink
def get_month_entries(self):
return ('archive_month', (), {
'year' : self.pub_date.strftime("%Y"),
'month' : self.pub_date.strftime("%b").lower()
})


Here are my URL patterns:

#urls.py
url(r'^blog/(?P\d{4})/(?P\w{3})/$', 'archive_month',
entry_info_dict, name='archive_month')


archive_month returns me a date_list object, which I'm iterating over
and displaying months:

{% for date in date_list %}

{{ date|date:"F" }}

{% endfor %}


But, when I view my template, only the year is in the link:

http://localhost/blog/2008/

instead of

http://localhost/blog/2008/oct/

Can someone see what I'm doing wrong?

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



Re: Conditions in templates

2008-10-07 Thread hasan_aljudy

You can't really do it that easily with the default django template
language,
bu check out Jinnja2,
http://jinja.pocoo.org/2/documentation/
it's an alternative template language/system that can be plugged into
django.

it offers what you need and more useful features that save you time
and make you more productive.
its syntax is very similar to django (infact it was inspired by
django)

On Oct 7, 2:43 pm, Kasper Grubbe <[EMAIL PROTECTED]> wrote:
> Hi again.
>
> In my application i need to know if a number in a list is bigger than
> 1000 or got 4 letters in it. I have to do this in my template.
>
> This is my code in the template:
> 
> {% for menuitem in availList %}
>       {% if menuitem|length > 3 %}
>             {{ menuitem }}
>       {% else %}
>             {{ menuitem }}
>       {% endif %}
> {% endfor %}
> 
>
> Is there any thing i can do to achieve this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Specify that syncdb not create a table for a Model

2008-10-07 Thread Malcolm Tredinnick


On Tue, 2008-10-07 at 17:59 -0700, Ed Anuff wrote:
> I reviewed this thread from March on whether it's possible to mark a
> Model so that syncdb doesn't create the table for specific Models and
> was wondering if there are any updates to this:
> 
> http://groups.google.com/group/django-users/browse_thread/thread/ba928abb39db2e31?tvc=2

[...]

>  Still not possible? 

Right this minute, it's "major" item number (counts quietly) 6 on my
list of bigg-ish things I'm working through. Behind a few SQL bugs and
some big docs that need to be written.

>  Something I can
> easily hack Model to do myself? 

Not really, since you'd actually need to modify the syncdb command.

>  On the roadmap?

Yes. Should certainly be in 1.1. Probably land in a few weeks.

Regards,
Malcolm



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



Re: generic.date_based.archive_year throws "invalid literal for int() with base 10: ''

2008-10-07 Thread Brandon Taylor

Oh for $hit's sake - how can I be so blind?!

Thanks Malcom,
Brandon

On Oct 7, 7:48 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-10-07 at 16:01 -0700, Brandon Taylor wrote:
> > Hi everyone,
>
> > Here is my code:
>
> > entry_info_dict = {
> >     'queryset' : Entry.live.all(),
> >     'date_field' : 'pub_date',
> >     'allow_future' : True
> > }
>
> > urlpatterns = patterns('django.views.generic.date_based',
> >     url(r'^blog/(?P)\d{4}/$', 'archive_year', entry_info_dict,
> > name='archive_year'),
> > )
>
> Your regular expression is incorrect. You aren't capturing anything in
> the "year" parentheses.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Specify that syncdb not create a table for a Model

2008-10-07 Thread Ed Anuff

I reviewed this thread from March on whether it's possible to mark a
Model so that syncdb doesn't create the table for specific Models and
was wondering if there are any updates to this:

http://groups.google.com/group/django-users/browse_thread/thread/ba928abb39db2e31?tvc=2

I'm integrating with a legacy database schema which uses the single-
table-inheritance pattern for storing several different classes in a
single table with a single column discriminator, and since Django
doesn't support that, thought next best thing would be to create a set
of Models which used the same table, which works, but I also want to
eventually use syncdb to create the database and want it to be able to
handle the situation correctly.  Still not possible?  Something I can
easily hack Model to do myself?  On the roadmap?

Ed

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



Re: generic.date_based.archive_year throws "invalid literal for int() with base 10: ''

2008-10-07 Thread Malcolm Tredinnick


On Tue, 2008-10-07 at 16:01 -0700, Brandon Taylor wrote:
> Hi everyone,
> 
> Here is my code:
> 
> entry_info_dict = {
> 'queryset' : Entry.live.all(),
> 'date_field' : 'pub_date',
> 'allow_future' : True
> }
> 
> urlpatterns = patterns('django.views.generic.date_based',
> url(r'^blog/(?P)\d{4}/$', 'archive_year', entry_info_dict,
> name='archive_year'),
> )

Your regular expression is incorrect. You aren't capturing anything in
the "year" parentheses.

Regards,
Malcolm


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



Re: i18n in templates and views

2008-10-07 Thread Malcolm Tredinnick


On Tue, 2008-10-07 at 18:23 -0400, J wrote:
> Hi everyone,
> 
> I'm working on a bilingual website in django for which the visitor has
> the option of choosing which language he/she prefers. All the
> interface, as well as the content, will be available in Spanish and
> English. The interface is set up to be handled by gettext and django's
> has excellent support for that.
> 
> I'm having a hard time right now with the bilingual "posts" system,
> which is for contributors to add articles in different categories.
> Each post will have two items for it, one in each language.
> 
> The way I've got it set up in the models is:
> 
> ##
> # The parent of all the posts,
> # only one item per post in here
> ##
> class Post(models.Model):
> referencetitle = models.CharField(max_length=30)
> date = models.DateTimeField('Date')
> 
> ##
> # language content for each post
> # there will be two items per post in here, one for each language
> ##
> class PostI18N(models.Model):
> post = models.ForeignKey(Post)
> slug = models.SlugField(
> 'Slug',
> help_text='Automatically built from the title.'
> )
> title = models.CharField('Title', max_length=30)
> body = models.TextField('Body Text')
> lang = models.CharField(max_length = 5, choices =
> settings.LANGUAGES)
> 
> 
> 
> How do it do this in views so that I only get the "PostI18N" items
> that are in the current language chosen by the users,

There's a currently undocumented function in django.utils.translation
called get_language() that you can use to return the currently active
locale. So something like

PostI18N.objects.filter(lang=get_language())

will filter out only the articles matching the current language. You can
safely use that function, even though I said it was undocumented. That's
because it will be documented inside the next 48 hours. I'm currently
rewriting the i18n documentation and just made a note to include that (I
hadn't realised until just now that we had left it out).

>  and how do I iterate through both of these models at the same time in
> templates so that I can access the Date field from the related table
> ("Post") to sort them, but display the main content fields from
> "PostI18N".

Sorting is generally best done in the view. Even better, sorting can be
done by the database at selection time. Modifying the above queryset,
you could write

PostI18N.objects.filter(lang=get_language()).order_by('post__date')


> 
> I'm initially attempting to display this data using generic views
> (django.views.generic.date_based.archive_index). Do you think these
> generic views can handle something like this? If not, how would I
> write an equivalent custom view?

Generic views can handle anything you can create as a queryset. However,
the above queryset actually depends on some information that is not
available until the view is active (you can't compute it once). This is
because the results of get_language() depend on the locale. So you would
need to wrap things up like this:

def my_view(request, ):
   qs = PostI18N... # <-- as above
   return archive_index(qs, )

That way, the get_language() call is executed each time in the right
environment.

Regards,
Malcolm



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



Re: Conditions in templates

2008-10-07 Thread Malcolm Tredinnick


On Tue, 2008-10-07 at 13:43 -0700, Kasper Grubbe wrote:
> Hi again.
> 
> In my application i need to know if a number in a list is bigger than
> 1000 or got 4 letters in it. I have to do this in my template.
> 
> This is my code in the template:
> 
> {% for menuitem in availList %}
>   {% if menuitem|length > 3 %}
> {{ menuitem }}
>   {% else %}
> {{ menuitem }}
>   {% endif %}
> {% endfor %}
> 
> 
> Is there any thing i can do to achieve this?

Write a template tag that does exactly that. Django ships with a
relatively minimal, but fairly complete set of tags, and then encourages
you to write your own (or use other people's) to do any extra stuff you
might like.

Regards,
Malcolm



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



Re: generic.date_based.archive_year throws "invalid literal for int() with base 10: ''

2008-10-07 Thread Steve Holden

Brandon Taylor wrote:
> My db record's pub_date field value is: 2008-09-17 16:39:52
>
> When I step through the debugger for archive year, and the following
> code is executed:
>
> lookup_kwargs = {'%s__year' % date_field: year}
>
> 'year' is being passed in from the keyword argument ?P from the
> URL, but once it hits this function, year = u''
>
> I'm using 1.0 Final, MySQL 5. Help!
>
>
>
> On Oct 7, 6:01 pm, Brandon Taylor <[EMAIL PROTECTED]> wrote:
>   
>> Hi everyone,
>>
>> Here is my code:
>>
>> entry_info_dict = {
>> 'queryset' : Entry.live.all(),
>> 'date_field' : 'pub_date',
>> 'allow_future' : True
>>
>> }
>>
>> urlpatterns = patterns('django.views.generic.date_based',
>> url(r'^blog/(?P)\d{4}/$', 'archive_year', entry_info_dict,
>> name='archive_year'),
>> )
>>
>> 
That pattern should be

r'^blog/(?P\d{4})/$

As it is you are passing the null string as your "year" view argument:

>>> int('')
Traceback (most recent call last):
  File "", line 1, in 
ValueError: invalid literal for int() with base 10: ''

regards
 Steve



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



Re: Access a model's original get_absolute_url

2008-10-07 Thread Malcolm Tredinnick


On Tue, 2008-10-07 at 14:49 +0300, Erik Allik wrote:
> Hi everybody,
> 
> I need a way to access a model's original get_absolute_url after the  
> ABSOLUTE_URL_OVERRIDES settings has taken effect. Currently I've  
> patched Django for this need so it will always alias the existing  
> get_absolute_url method as old_get_absolute_url when it overrides that  
> method, but patching stuff is ugly and poses deployment/reusability/ 
> upgradability issues, so I'm thinking maybe there's a hook or a signal  
> that I could use to achieve the same effect.
> 

No, you can't do that. The get_absolute_url method on the model is
entirely replaced. The former version is an ex-parrot, so to speak
(okay, I'm implicitly ruling out bytecode hacks to get at it, but
hopefully, so are you).

This does hint that you're using the wrong shovel to hammer in your
screws, however. You've said that you want to change that URL, always.
Hence it's in ABSOLUTE_URL_OVERRIDES. Later you are effectively saying
"no, just joking... I don't want it overridden all the time". If it's
only meant to be changed sometimes, the ABSOLUTE_URL_OVERRIDES is not
the right tool for the job.

What is the real problem you are trying to solve?

Malcolm



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



Re: Where do custom fields go?

2008-10-07 Thread Penguin

Ah okay, thanks Donn.

On Oct 8, 12:04 am, Donn <[EMAIL PROTECTED]> wrote:
> > I've been playing with custom fields, but I'm not sure where the
> > python script containing the custom field definition goes?
>
> Anywhere you can reach it with an import statement. I put mine alongside
> models.py etc. and call it forms.py
>
> \d
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: generic.date_based.archive_year throws "invalid literal for int() with base 10: ''

2008-10-07 Thread Brandon Taylor

My db record's pub_date field value is: 2008-09-17 16:39:52

When I step through the debugger for archive year, and the following
code is executed:

lookup_kwargs = {'%s__year' % date_field: year}

'year' is being passed in from the keyword argument ?P from the
URL, but once it hits this function, year = u''

I'm using 1.0 Final, MySQL 5. Help!



On Oct 7, 6:01 pm, Brandon Taylor <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> Here is my code:
>
> entry_info_dict = {
>     'queryset' : Entry.live.all(),
>     'date_field' : 'pub_date',
>     'allow_future' : True
>
> }
>
> urlpatterns = patterns('django.views.generic.date_based',
>     url(r'^blog/(?P)\d{4}/$', 'archive_year', entry_info_dict,
> name='archive_year'),
> )
>
> So, when I hit:http://localhost:8000/blog/2008/sep/
>
> I get: invalid literal for int() with base 10: ''
>
> I know these values are valid, as I have an Entry in the database and
> my URL param is populated form the DB. I have also visually verified
> that the values are correct. What can I possibly be doing wrong here?
>
> I'm using Aptana with PyDev, and have stepped through the debugger for
> the archive_year function, and I'm just not seeing what the problem
> is. Anyone else seeing something similar?
>
> TIA,
> Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Double encoded slash in path_info removed when using apache/wsgi

2008-10-07 Thread Merrick

I need urls that contain other urls within them i.e.

http://mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F%2F

I am using Apache 2.2.3-4, mod_wsgi 2.0-1 and have
"AllowEncodedSlashes On" within my virtualhost conf file, this setting
allows me to have encoded slashes in the path_info without having
apache return a fake 404.

My views.py includes:

def find(request, url):
import urllib
url = urllib.unquote_plus(url)
form = FindForm({'url': url,})
return render_to_response('find.html', { 'form': form, 'request':
request })


The template find.html includes a line {{ request.path_info }} to
print out the path_info.

Firefox shows the second encoded forward slash is removed when calling
this url:
http://mydomain.com/find/http%3A%2F%2Fwww.wired.com%2F%2F
 prints out:
/find/http:/www.wired.com/

The django test client prints out the second forward slash

>>> ./manage.py
>>> from django.test.client import Client
>>> c = Client()
>>> response = c.get('/bookmarklet/http:%2F%2Fwww.wired.com%2F%2F')
>>> response.content
'/find/http://www.wired.com//'

I did not include anything about my regular expression in urls.py up
until this point because it is not related to this problem from what I
can tell, but in case you are wondering I was trying to capture the
url after find/ - my regex looks like this r'^find/(?P(.*))$'

Thanks for looking at this,

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



generic.date_based.archive_year throws "invalid literal for int() with base 10: ''

2008-10-07 Thread Brandon Taylor

Hi everyone,

Here is my code:

entry_info_dict = {
'queryset' : Entry.live.all(),
'date_field' : 'pub_date',
'allow_future' : True
}

urlpatterns = patterns('django.views.generic.date_based',
url(r'^blog/(?P)\d{4}/$', 'archive_year', entry_info_dict,
name='archive_year'),
)

So, when I hit: http://localhost:8000/blog/2008/sep/

I get: invalid literal for int() with base 10: ''


I know these values are valid, as I have an Entry in the database and
my URL param is populated form the DB. I have also visually verified
that the values are correct. What can I possibly be doing wrong here?

I'm using Aptana with PyDev, and have stepped through the debugger for
the archive_year function, and I'm just not seeing what the problem
is. Anyone else seeing something similar?

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



i18n in templates and views

2008-10-07 Thread J
Hi everyone,

I'm working on a bilingual website in django for which the visitor has
the option of choosing which language he/she prefers. All the interface,
as well as the content, will be available in Spanish and English. The
interface is set up to be handled by gettext and django's has excellent
support for that.

I'm having a hard time right now with the bilingual "posts" system,
which is for contributors to add articles in different categories. Each
post will have two items for it, one in each language.

The way I've got it set up in the models is:

##
# The parent of all the posts,
# only one item per post in here
##
class Post(models.Model):
referencetitle = models.CharField(max_length=30)
date = models.DateTimeField('Date')

##
# language content for each post
# there will be two items per post in here, one for each language
##
class PostI18N(models.Model):
post = models.ForeignKey(Post)
slug = models.SlugField(
'Slug',
help_text='Automatically built from the title.'
)
title = models.CharField('Title', max_length=30)
body = models.TextField('Body Text')
lang = models.CharField(max_length = 5, choices = settings.LANGUAGES)



How do it do this in _views _so that I only get the "PostI18N" items
that are in the current language chosen by the users, and how do I
iterate through both of these models at the same time in templates so
that I can access the Date field from the related table ("Post") to sort
them, but display the main content fields from "PostI18N".

I'm initially attempting to display this data using generic views
(django.views.generic.date_based.archive_index). Do you think these
generic views can handle something like this? If not, how would I write
an equivalent custom view?

Thanks for your help with this,
J


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



Re: Can M2M be one-way?

2008-10-07 Thread Karen Tracey
On Tue, Oct 7, 2008 at 6:01 PM, Dylan Reinhardt <[EMAIL PROTECTED]>wrote:

>
> Is there any way to make Django ManyToManyField objects not be bi-
> directional?
>
> I have a Product object with a self-referencing M2M field.  I want
> each Product to maintain its *own* list of related products... I do
> not want Products affecting each other's lists.  When A points to B, I
> don't necessarily want B pointing to A.
>
> I can appreciate how bi-directionality is the right answer for most
> cases... but is there any way to suppress this behavior?
>
>
I think you want symmetrical=False:

http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyFields.symmetrical

Karen

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



Re: timeit module put my app into infinite loop

2008-10-07 Thread bruno desthuilliers

On 7 oct, 17:54, "K*K" <[EMAIL PROTECTED]> wrote:

Just a couple more (slightly OT) notes:

> I'm writing a program to test django's mysql performance,

"django's mysql performance" doesn't really makes sense. What you're
testing with your code is the combined perfs of
- Django's orm
- Python's MySQLdb connector
- your version of MySQL

(not to talk about your system etc...)

Ok, the distinction is a bit pedantic, but it might be better to make
things clear. If what you want to test is django's ORM itself, you
should also code doing the same operation using only the MySQLdb
connector, timeit *under similar conditions* (system load etc), and
compare both results to know what comes from the ORM itself.

> use timeit
> to profile.

Pedantic again, but what you're doing is  benchmarking - "profiling"
is something quite different.

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



Can M2M be one-way?

2008-10-07 Thread Dylan Reinhardt

Is there any way to make Django ManyToManyField objects not be bi-
directional?

I have a Product object with a self-referencing M2M field.  I want
each Product to maintain its *own* list of related products... I do
not want Products affecting each other's lists.  When A points to B, I
don't necessarily want B pointing to A.

I can appreciate how bi-directionality is the right answer for most
cases... but is there any way to suppress this behavior?

TIA,

Dylan

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



Re: timeit module put my app into infinite loop

2008-10-07 Thread bruno desthuilliers

On 7 oct, 17:54, "K*K" <[EMAIL PROTECTED]> wrote:
> Hi, all
>
> I'm writing a program to test django's mysql performance, use timeit
> to profile. But it make my app into infinite loop.

I'm probably a bit tired, but I don't see how the below snippet could
cause an infinite loop - unless you did something very wrong in the
parts of the code that are called but you didn't post.

> always write data
> into database.

Err... Wait... This is what asked for, didn't you ? (cf below...)

> 
> import timeit
>
> from django.shortcuts import render_to_response
> from testDjango.benchmark.models import Django
>
> loop_range = 10
>
> def benchmark(request):
> global loop_range



You don't need the global statement here since you're not rebinding
loop_range. FWIW, you could declare it as a local variable anyway


> insert_timer = timeit.Timer("benchmark_insert()", "from
> testDjango.bench import benchmark_insert")
> insert_timer.repeat(loop_range)
> insert_speed = insert_timer.timeit()

I suspect you misread the doc for timer.repeat and timer.timeit.
Timer.timeit will already repeat the given statement quite a few times
(100 by default). Timer.repeat will call Timer.timeit x times. So
with your above code, you will first call benchmark_insert() 10 *
100 times, discard the result, then call benchmark_insert()
100 more times.

If you meant to only call Timer.timeit once and make it call
benchmark_insert only 10 times, you want :

  insert_timer = timeit.Timer(
  "benchmark_insert()",
  "from testDjango.bench import benchmark_insert"
  )
  insert_speed = insert_timer.timeit(loop_range)


> def benchmark_insert():
> p1 = Django(foobar='Test foo',)
> p1.save()
> del p1

I think you meant p1.delete().  'del p1' unbind the name p1 in the
current namespace - which is pretty useless here FWIW -, but won't
remove anything from your database.

HTH

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



Re: custom field problem w/Django v1.0

2008-10-07 Thread Siemster

Not being a Python guru by any stretch of the imagination, I have no
idea if the following is a proper way to do it, but adding:
"
def __unicode__(self):
return u'MAC Address'
"
to the MacAddressField class definition does work. For my purposes. As
long as I'm o.k. with the label always being 'MAC Address' no matter
where I use it.

It would be nice to figure out the preferred way of implementing
custom fields. The documentation, while nice, seems to be incomplete
in this area... Google hasn't been very helpful in searching for
examples either.

Anybody out there know of one or more good examples of implementing
and using these beasts?

--Siemster


On Oct 3, 3:25 pm, Siemster <[EMAIL PROTECTED]> wrote:
> Greetings,
>
> I'm in the process of porting an application from Django v0.96 (using
> Python 2.3) to v1.0 (using Python 2.4). I had been using
> django.core.validators, but since that doesn't exist in v1.0 I'm
> trying to replace the functionality with a custom field.
>
> The code that I'm using is as follows:
> #
> # app_utils/__init.py__
> from django.db.models import CharField
>
> class MacAddressField(CharField):
> def __init__(self, *args, **kwargs):
> kwargs['max_length'] = 17
> super(MacAddressField, self).__init__(self, *args, **kwargs)
>
> def db_type(self):
> return 'varchar(17)'
>
> #
> # other_equipment/models.py
> from django.db import models
> from app_utils import MacAddressField
>
> class NetworkDevice(models.Model):
> mac_address = MacAddressField('MAC Address', primary_key=True)
> name = models.CharField(max_length=255)
> ip_address = CharField('IP Address', max_length=15, null=True,
> blank=True)
>
> def __unicode__(self):
> return u'%s' % (self.mac_address)
>
> #
> # other_equipment/admin.py
> from django.contrib import admin
> from other_equipment.models import NetworkDevice
>
> class NetworkDeviceAdmin(admin.ModelAdmin):
>  list_display = ('mac_address', 'name', 'ip_address',)
>  search_fields = ('mac_address', 'name', 'ip_address',)
>
> admin.site.register(NetworkDevice, NetworkDeviceAdmin)
>
> #
> The administrative interface for the model almost works... the problem
> that I'm currently working on is that instead of the seeing "MAC
> Address" as the mac_address label I see " object at 0x9995c2c>".
>
> Any clue as to what I'm doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Admin, Custom Views and the ChangeList object

2008-10-07 Thread Brandon Taylor

Thanks Karen!

On Oct 7, 4:43 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Oct 7, 2008 at 2:43 PM, Brandon Taylor <[EMAIL PROTECTED]>wrote:
>
>
>
>
>
> > Hi everyone,
>
> > On a recent project, I was tasked with adding a workflow around a
> > model, which required some customization in the admin. I found that
> > when I did and override of a view, I no longer had access to the "cl",
> > or ChangeList object containing all of the objects for the view.
>
> > Filters and other built-in functions in the admin templates depend on
> > this object, but I haven't been able to figure out how to return this
> > object in my own custom views.
>
> > Can anyone shed some light as to how to create and pass in the "cl"
> > object list for use within custom admin views?
>
> cl is set via a template tag.  You may be interested in this ticket:
>
> http://code.djangoproject.com/ticket/6396
>
> which addresses the fact that the current behavior makes customization
> difficult.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Admin, Custom Views and the ChangeList object

2008-10-07 Thread Karen Tracey
On Tue, Oct 7, 2008 at 2:43 PM, Brandon Taylor <[EMAIL PROTECTED]>wrote:

>
> Hi everyone,
>
> On a recent project, I was tasked with adding a workflow around a
> model, which required some customization in the admin. I found that
> when I did and override of a view, I no longer had access to the "cl",
> or ChangeList object containing all of the objects for the view.
>
> Filters and other built-in functions in the admin templates depend on
> this object, but I haven't been able to figure out how to return this
> object in my own custom views.
>
> Can anyone shed some light as to how to create and pass in the "cl"
> object list for use within custom admin views?
>
>
cl is set via a template tag.  You may be interested in this ticket:

http://code.djangoproject.com/ticket/6396

which addresses the fact that the current behavior makes customization
difficult.

Karen

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



Re: django-basic-blog

2008-10-07 Thread bruno desthuilliers



On 7 oct, 21:58, R C <[EMAIL PROTECTED]> wrote:
> I'm very, very new to django
>
> I tried installing the basic-blog application
> (http://code.google.com/p/django-basic-apps/source/browse/#svn/trunk/
> blog)
> When I run:
> python manage.py runserver
>
> I get an error (in red font):
> Error: No module named basic
>
> the blog folder is in: /home/myusername/local/basic
>
> my PYTHONPATH is:  /home/myusername/local/basic:

Remove the '/basic' part from your PYTHONPATH. The PYTHONPATH should
point to directories *containing* packages, not to the packages
themselves.


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



Re: auth.login problems in Django 1.0

2008-10-07 Thread Cold

I got exactly the same problem, with the nearly the same code.
I used pdb and check that login(request, user) is well called.
But in the next view, in my template i do a {% user.is_authenticated
%},
and it seams that the user is not logged in.
Someone have an idee ? bug or wrong session configuration ?

Regards

Vincent

On Oct 6, 8:09 pm, Robocop <[EMAIL PROTECTED]> wrote:
> Having looked through the archived posts, i found a similar problem
> that had found no 
> solution:http://groups.google.com/group/django-users/browse_thread/thread/bf05...
>
> It looks like django is not actually logging my user in, or not
> creating a session.  I have a very simple snippet for login
> functionality pretty much lifted directly from the docs:
>
> from django.contrib.auth import logout, login, authenticate
>
> def login(request):
>   news_list = New.objects.all().order_by('-date')
>   if request.method == 'POST':
> username = request.POST['username']
> password = request.POST['password']
> user = auth.authenticate(username=username, password=password)
> if user is not None:
>   if user.is_active:
> auth.login(request,user)
>   return render_to_response('main.html', locals())
> else:
>   return render_to_response('registration.html', locals())
>
> settings.py:
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.admin',
> 'intrinsic.site',
> )
>
> When i was running this project under .96 i never had this issue.
> It's as if the auth.login line is somehow failing silently.  I've
> tested and am absolutely sure that the code does everything it should
> but that one auth.login line.  So because of this i can't get at the
> {{user}} variable in my templates.  Any help, or suggestions for
> debugging attempts would be great.

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



django-basic-blog

2008-10-07 Thread R C

I'm very, very new to django

I tried installing the basic-blog application
(http://code.google.com/p/django-basic-apps/source/browse/#svn/trunk/
blog)

When I run:
python manage.py runserver

I get an error (in red font):
Error: No module named basic

the blog folder is in: /home/myusername/local/basic

my PYTHONPATH is:  /home/myusername/local/basic:

my settings.py INSTALLED_APPS looks like this:INSTALLED_APPS =
(
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.markup',
'projects.polls',
'basic.blog',
'django.contrib.admin',
)


I don't know what else to do.  Can someone please 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: re-direction after login successfully

2008-10-07 Thread Bob

The setting LOGIN_REDIRECT_URL will allow you to change the default.

On Sep 4, 7:07 pm, zissan <[EMAIL PROTECTED]> wrote:
> It's seemd that Django has set /accounts/profile as default page after
> login successfully.
> I wonder if we can re-direct it to a custom page?

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



Conditions in templates

2008-10-07 Thread Kasper Grubbe

Hi again.

In my application i need to know if a number in a list is bigger than
1000 or got 4 letters in it. I have to do this in my template.

This is my code in the template:

{% for menuitem in availList %}
  {% if menuitem|length > 3 %}
{{ menuitem }}
  {% else %}
{{ menuitem }}
  {% endif %}
{% endfor %}


Is there any thing i can do to achieve this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: re-direction after login successfully

2008-10-07 Thread Pablo Catalina
May be, you want this...

http://docs.djangoproject.com/en/dev/ref/settings/#setting-LOGIN_REDIRECT_URL



2008/10/7 KillaBee <[EMAIL PROTECTED]>

>
>
>
> On Sep 5, 5:57 am, "Genis Pujol Hamelink" <[EMAIL PROTECTED]>
> wrote:
> > You can create a view like:
> >
> > @login_required
> > def index(request):
> >
> > if request.user.is_authenticated():
> > return HttpResponseRedirect('/go/here/')
> >
> > else:
> > return render_to_response("go/loginpage")
> >
> > gr,
> >
> > G.
> >
> > 2008/9/5 Ken <[EMAIL PROTECTED]>
> >
> >
> >
> >
> >
> > > You have two options.
> >
> > > 1) You can write your own view.
> >
> > > 2) You can pass a GET parameter to the login view:
> >
> > > /accounts/login?next=/redirect/to/custom/path/
> >
> > > and put this in your form in the login template:
> >
> > > 
> >
> > > Cheers,
> > > Ken
> >
> > > On Sep 5, 12:07 am, zissan <[EMAIL PROTECTED]> wrote:
> > > > It's seemd that Django has set /accounts/profile as default page
> after
> > > > login successfully.
> > > > I wonder if we can re-direct it to a custom page?
> >
> > --
> > Genís
>
> I am having the same problem but when I put in
> 
> I still goes to account/profile
> I can got to localhost:port/timesheet but this redirect is not.  any
> idea what I am doing wrong?
> >
>


-- 
Pablo Catalina <[EMAIL PROTECTED]>

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



Re: Multiple ManyToMany relations with the same class

2008-10-07 Thread Ariel Mauricio Nunez Gomez
Por cierto, cuando ya este la base de datos llena de actuaciones nos invitas
a escuchar a los samberos.

Ariel.


On Tue, Oct 7, 2008 at 12:05 PM, Pablo Catalina <[EMAIL PROTECTED]>wrote:

> # python manage.py validate
> Error: One or more models did not validate:
> concerts.concert: Accessor for m2m field 'musicans' clashes with related
> m2m field 'person.concert_set'. Add a related_name argument to the
> definition for 'musicans'.
> concerts.concert: Accessor for m2m field 'coches' clashes with related m2m
> field 'person.concert_set'. Add a related_name argument to the definition
> for 'coches'.
>
> OK.
>
> The problems is with the order of the fields, I solve It:
>
> Now, the problem:
>
> models:
> from django.db import models
> from django.contrib.auth.models import User, UserManager
>
>
> class instrumentos(models.Model):
> nombre = models.CharField(max_length=10)
> numero = models.PositiveSmallIntegerField(blank=True, null=True)
> def __unicode__(self):
> return self.nombre
>
> class samberos(User):
> objects = UserManager()
> dni = models.CharField(max_length=10, blank=True, null=True)
> phone = models.CharField(max_length=9, blank=True, null=True)
> movil = models.CharField(max_length=9, blank=True, null=True)
>
> class contactos(models.Model):
> name = models.CharField(max_length=30)
> phone = models.CharField(max_length=9, blank=True, null=True)
> movil = models.CharField(max_length=9, blank=True, null=True)
> mail = models.CharField(max_length=30, blank=True, null=True)
> def __unicode__(self):
> return self.name
>
> class relaciones(models.Model):
> sambero = models.ForeignKey(samberos)
> instrumento =  models.ForeignKey(instrumentos)
> def __unicode__(self):
> return '%s => %s' % (self.sambero, self.instrumento)
>
> class actuaciones(models.Model):
> titulo = models.CharField(max_length=80)
> fecha = models.DateTimeField()
> descripcion = models.TextField()
> lugar = models.CharField(max_length=200)
> organizador = models.ManyToManyField(samberos)
> samberos = models.ManyToManyField(relaciones, blank=True, null=True)
> confirmada = models.BooleanField(default=False)
> contacto = models.ManyToManyField(contactos)
> coches = models.ManyToManyField(samberos, blank=True, null=True,
> related_name='actuaciones_coches')
> def __unicode__(self):
> return self.titulo
>
> And the solution is to change the order of the fields:
>
> class actuaciones(models.Model):
> titulo = models.CharField(max_length=80)
> fecha = models.DateTimeField()
> descripcion = models.TextField()
> lugar = models.CharField(max_length=200)
> organizador = models.ManyToManyField(samberos)
> coches = models.ManyToManyField(samberos, blank=True, null=True,
> related_name='actuaciones_coches')
> samberos = models.ManyToManyField(relaciones, blank=True, null=True)
> confirmada = models.BooleanField(default=False)
> contacto = models.ManyToManyField(contactos)
> def __unicode__(self):
> return self.titulo
>
>
> Thank you very much!!!
>
> 2008/10/7 Malcolm Tredinnick <[EMAIL PROTECTED]>
>
>
>>
>> On Mon, 2008-10-06 at 13:52 -0700, xkill wrote:
>> > Hello,
>> >
>> > I tried to add multiple manytomany fields to a class, that pointing to
>> > the same class.
>> >
>> > For example:
>> >
>> > class person(models.Model):
>> > name = models.CharField(max_length=30)
>> > phone = models.CharField(max_length=9, blank=True, null=True)
>> > def __unicode__(self):
>> > return self.name
>> >
>> > class concert(models.Model):
>> > title = models.CharField(max_length=80)
>> > musicans = models.ManyToManyField(person)
>> > coches = models.ManyToManyField(person, blank=True, null=True)
>> > def __unicode__(self):
>> > return self.title
>> >
>> >
>> > But it doesn't work, how can I do it?
>>
>> "It doesn't work" is not very specific. It could mean anything from "an
>> error was reported" to "it failed silently" all the way up to "my
>> computer burst into flames".
>>
>> So what actually happened?
>>
>> As James hinted at, I suspect you will actually see an error messages
>> when you run "manage.py validate" saying that you need to add a related
>> name to one of the ManyToManyFields (the validation will complain about
>> both fields, but you need to fix at least one of them).
>>
>> If that is the case, then the problem is that since the reverse relation
>> name for a ManyToManyField is, by default, created from the name of the
>> model it is contained in, both of those fields will end up with the same
>> default reverse name (used when you are filtering from a Person back to
>> a Concert). So you need to set the related_name attribute on one of the
>> fields (or on both of them).
>>
>> Regards,
>> Malcolm
>>
>>
>>
>>
>>
>
>
> --
> Pablo Catalina <[EMAIL PROTECTED]>
>
> >
>

--~--~-~--~~~---~--~~
You 

Date-based generic views and 404 errors

2008-10-07 Thread Brandon Taylor

Hi everyone,

I'm following along with the Blog example in the Practical Django
Projects book. Here are my URLs:

entry_info_dict = {
'queryset' : Entry.live.all(),
'date_field' : 'pub_date'
}

urlpatterns = patterns('django.views.generic.date_based',
url(r'^blog/$', 'archive_index', entry_info_dict, name='blog'),
url(r'^blog/(?P)\d{4}/$', 'archive_year', entry_info_dict,
name='archive_year'),
url(r'^blog/(?P)\d{4}/(?P\w{3})/$', 'archive_month',
entry_info_dict, name='archive_month'),
url(r'^blog/(?P)\d{4}/(?P)\w{3}/(?P)\d{2}/$',
'archive_day', entry_info_dict, name='archive_day'),
url(r'^blog/(?P\d{4})/(?P\w{3})/(?P\d{2})/(?
P[-\w]+)/$', 'object_detail', entry_info_dict,
name='entry_detail'),
)

I can view the archive index, and the entry detail, but archive_year,
archive_month and archive_day all return 404 error pages. Can someone
please point out what I'm doing wrong?

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



Re: html inserted into csv file

2008-10-07 Thread jonknee

On Oct 7, 2:44 pm, Bobby Roberts <[EMAIL PROTECTED]> wrote:

> This code drops all selected fields into a temporary csv file named
> "contact.csv" so that it can be downloaded.  However, the template
> HTML is being appended after the last record in the csv file.
>
> Is there any way to prevent this from happening?

This is covered in the official docs, the given example works
perfectly:

http://docs.djangoproject.com/en/dev/howto/outputting-csv/#howto-outputting-csv

And if that's really your SQL query you can easily get away with a
Queryset instead of doing it manually.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: seeking help in model design...

2008-10-07 Thread paul

hey david,

ah - thanks so much!  i made two mistakes:  using abstract - and
linking to self rather than to Node.  i'm guessing here - butu are two
models/tables created and linked together rather than a single 'uber'
table?

anyway, i'm back up and running on my fledgling project - thanks to
you!  :-)

-p

On Oct 7, 6:23 pm, David Hall <[EMAIL PROTECTED]> wrote:
> Hi Paul,
>
> So long as the common model is not abstract, it should work.  Also, the
> common model must be the one that contains the parent field, and it
> should link to "Node" and not "self".
>
> Using my first example, you should be able to traverse the tree using
> Node.parent and Node.children.  Traversing the tree using Job.parent,
> Job.children, Shot.parent or Shot.children will not work.
>
> I've implemented the first example in one of my own apps, and it does
> work!  :P
>
> David.
>
>
>
> paul wrote:
> > hi david,
>
> > many thanks for your help there. i initially tried the inheritance
> > method - buut found that my tree traversal broke when trying to
> > traverse a tree made of different types (ie, Node & Jobs).  maybe i
> > did something wrong?  ie, should i be able to make a tree from those
> > two types if derived from a common model.  or is each derived model
> > incompatible with each other?
>
> > cheers,
>
> > paul
>
> > On Oct 7, 11:16 am, David Hall <[EMAIL PROTECTED]> wrote:
> >> Hi Paul,
>
> >> You've got a couple of options for this.  The first uses inheritance:
>
> >> class Node(models.Model):
> >>      parent = models.ForeignKey("Node", blank=True, null=True,
> >>                      related_name="children")
>
> >> class Job(Node):
> >>      pass
>
> >> class Shot(Node):
> >>      pass
>
> >> The second uses generic foreign keys:
>
> >> class Job(models.Model):
> >>      parent_type = models.ForeignKey("contenttypes.ContentType")
> >>      parent_id = models.PositiveIntegerField(db_index=True)
> >>      parent = GenerticForeignKey("parent_type", "parent_id")
>
> >> class Shot(models.Model):
> >>      parent_type = models.ForeignKey("contenttypes.ContentType")
> >>      parent_id = models.PositiveIntegerField(db_index=True)
> >>      parent = GenerticForeignKey("parent_type", "parent_id")
>
> >> Personally, I'd go with the first, as it will integrate better with the
> >> Djano admin application.  To traverse the tree, use the Node model.
> >> Once you have got to your required location in the tree, use node.job or
> >> node.shot to get the rest of the information.
>
> >> David.
>
> >> paul wrote:
> >>> hi,
> >>> I'm designing my first django app and would appreciate any advice how
> >>> best to organise my models.
> >>> I have a hierarchal model called Node.  this allows me to create a
> >>> hierarchy of nodes - and perform hierarchal operatoins.  So far so
> >>> good.  each node can be of two 'types':
> >>> 1/ job
> >>> 2/ shot
> >>> I did originally try and make shot & job inherit the Node model.
> >>> However, they couldn't 'link' together (ie, using self as a
> >>> ForeignKey) - as they're of different types.  So i've made each of
> >>> these two node types into seperate models.  each Node should only be
> >>> linked to one type at a time.  From the manual/book - i belive that
> >>> GenericForeignKey is the way to go.  ie, insert a GenericForeignKey
> >>> field into the Node.  Does this sound like a good approach?
> >>> Many Thanks in Advance,
> >>> Paul
> >> --
> >>   David Hall
> >>   Technical Lead
> >>   Etianen.com
> >>   Tel: 07896 106290
>
> >>   Email   [EMAIL PROTECTED]
> >>   Web      www.etianen.com
> >> ---
> >>   Ask for help at [EMAIL PROTECTED]
> >>   Etianen.com is a small, professional web development agency that
> >>   specialises in fast-paced, creative development.
> >> - enlightened website development -
>
> --
>   David Hall
>   Technical Lead
>   Etianen.com
>   Tel: 07896 106290
>
>   Email   [EMAIL PROTECTED]
>   Web      www.etianen.com
> ---
>   Ask for help at [EMAIL PROTECTED]
>   Etianen.com is a small, professional web development agency that
>   specialises in fast-paced, creative development.
> - enlightened website development -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: re-direction after login successfully

2008-10-07 Thread KillaBee



On Sep 5, 5:57 am, "Genis Pujol Hamelink" <[EMAIL PROTECTED]>
wrote:
> You can create a view like:
>
> @login_required
> def index(request):
>
>     if request.user.is_authenticated():
>         return HttpResponseRedirect('/go/here/')
>
>     else:
>         return render_to_response("go/loginpage")
>
> gr,
>
> G.
>
> 2008/9/5 Ken <[EMAIL PROTECTED]>
>
>
>
>
>
> > You have two options.
>
> > 1) You can write your own view.
>
> > 2) You can pass a GET parameter to the login view:
>
> > /accounts/login?next=/redirect/to/custom/path/
>
> > and put this in your form in the login template:
>
> > 
>
> > Cheers,
> > Ken
>
> > On Sep 5, 12:07 am, zissan <[EMAIL PROTECTED]> wrote:
> > > It's seemd that Django has set /accounts/profile as default page after
> > > login successfully.
> > > I wonder if we can re-direct it to a custom page?
>
> --
> Genís

I am having the same problem but when I put in

I still goes to account/profile
I can got to localhost:port/timesheet but this redirect is not.  any
idea what I am doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Hosting Survey

2008-10-07 Thread Brandon Taylor

WebFaction definitely gets my vote.

Setting up a Django app with their control panel couldn't be easier,
and their customer service is excellent.

Brandon Taylor
bTaylor Design
www.btaylordesign.com

On Oct 6, 12:30 pm, Jeff <[EMAIL PROTECTED]> wrote:
> I am about to begin a new Django project and I am currently evaluating
> hosting options. I know there has been a number of discussions on this
> topic, and I have read most of them. However, seeing how quickly
> things change in the web development / hosting world, I wanted to get
> some opinions if the following summary still holds true.
>
> The most useful information I have found on Django hosting was 
> here:http://www.djangoproject.com/weblog/2008/jan/12/mt/
>
> From this, and other sources, I believe the best hosting options to
> be:
>
> 1. Web Faction - for those that want to get Django up and running as
> quickly and easily as possible, using their automated setup.
>
> OR
>
> 2. Slicehost - for those that want COMPLETE control of their hosting
> environment. Only drawback (for some) is that everything needs to be
> installed from scratch.
>
> In the case of Slicehost, I am also curious if the 256 slice is
> sufficient for most Django apps.
>
> I appreciate any thoughts or comments.
>
> Thanks!
>
> Jeff
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: adding date to template

2008-10-07 Thread KillaBee



On Oct 7, 1:49 pm, KillaBee <[EMAIL PROTECTED]>
wrote:
> On Oct 6, 4:44 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Mon, Oct 6, 2008 at 4:55 PM, KillaBee <
>
> > [EMAIL PROTECTED]> wrote:
> > > Thanks I have read the forms doc. and it helped a great deal.
> > > now I am get this error:'QueryDict' object has no attribute 'method'
> > > at line 12.
>
> > > view:
> > > from django.http import HttpResponse
> > > from intranet.timesheets.models import Poll
> > > from intranet.timesheets.models import Choice
> > > from django.shortcuts import render_to_response, get_object_or_404
> > > from django.core.urlresolvers import reverse
> > > from django.contrib.auth import views
> > > from django.contrib import databrowse
> > > from django.contrib import auth
> > > #from django.contrib.databrowse.plugins.calendars import
> > > CalendarPlugin
>
> > > def timesheet(request):
> > >    if request.method == 'POST': # If the form has been
> > > submitted..
> > >        form = timesheet(request.POST) # A form bound to the POST data
>
> > You've named both your view and your form 'timesheet'.  When your timesheet
> > view gets called, it tries to instantiate a form by calling 'timesheet' and
> > passing in request.POST (a QueryDict).  However, timesheet the view gets
> > called (again, recursively) with a QueryDict and promptly runs into trouble
> > when it tries to access the 'method' attribute of the argument it was
> > handed.  You need to give these things different names.
>
> > Karen
>
> I did give them different name, I know better.  It  solve my problem.

I have a few more problems, if some one can piont me in the right
direction:

1) I have a problem in the login template.  After I click submit the :

should send me some where but it send me to the default /accounts/
profile/


2) my form shows up now but it does not post the data to the MYSQL db,
and no error is given.

3)  how do I put a calendar in a view or template?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: adding date to template

2008-10-07 Thread KillaBee



On Oct 7, 1:49 pm, KillaBee <[EMAIL PROTECTED]>
wrote:
> On Oct 6, 4:44 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Mon, Oct 6, 2008 at 4:55 PM, KillaBee <
>
> > [EMAIL PROTECTED]> wrote:
> > > Thanks I have read the forms doc. and it helped a great deal.
> > > now I am get this error:'QueryDict' object has no attribute 'method'
> > > at line 12.
>
> > > view:
> > > from django.http import HttpResponse
> > > from intranet.timesheets.models import Poll
> > > from intranet.timesheets.models import Choice
> > > from django.shortcuts import render_to_response, get_object_or_404
> > > from django.core.urlresolvers import reverse
> > > from django.contrib.auth import views
> > > from django.contrib import databrowse
> > > from django.contrib import auth
> > > #from django.contrib.databrowse.plugins.calendars import
> > > CalendarPlugin
>
> > > def timesheet(request):
> > >    if request.method == 'POST': # If the form has been
> > > submitted..
> > >        form = timesheet(request.POST) # A form bound to the POST data
>
> > You've named both your view and your form 'timesheet'.  When your timesheet
> > view gets called, it tries to instantiate a form by calling 'timesheet' and
> > passing in request.POST (a QueryDict).  However, timesheet the view gets
> > called (again, recursively) with a QueryDict and promptly runs into trouble
> > when it tries to access the 'method' attribute of the argument it was
> > handed.  You need to give these things different names.
>
> > Karen
>
> I did give them different name, I know better.  It  solve my problem.

I have a few more problems, if some one can piont me in the right
direction:

1) I have a problem in the login template.  After I click submit the :

should send me some where but it send me to the default /accounts/
profile/


2) my form shows up now but it does not post the data to the MYSQL db,
and no error is given.

3)  how do I put a calendar in a view or template?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: adding date to template

2008-10-07 Thread KillaBee



On Oct 7, 1:49 pm, KillaBee <[EMAIL PROTECTED]>
wrote:
> On Oct 6, 4:44 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Mon, Oct 6, 2008 at 4:55 PM, KillaBee <
>
> > [EMAIL PROTECTED]> wrote:
> > > Thanks I have read the forms doc. and it helped a great deal.
> > > now I am get this error:'QueryDict' object has no attribute 'method'
> > > at line 12.
>
> > > view:
> > > from django.http import HttpResponse
> > > from intranet.timesheets.models import Poll
> > > from intranet.timesheets.models import Choice
> > > from django.shortcuts import render_to_response, get_object_or_404
> > > from django.core.urlresolvers import reverse
> > > from django.contrib.auth import views
> > > from django.contrib import databrowse
> > > from django.contrib import auth
> > > #from django.contrib.databrowse.plugins.calendars import
> > > CalendarPlugin
>
> > > def timesheet(request):
> > >    if request.method == 'POST': # If the form has been
> > > submitted..
> > >        form = timesheet(request.POST) # A form bound to the POST data
>
> > You've named both your view and your form 'timesheet'.  When your timesheet
> > view gets called, it tries to instantiate a form by calling 'timesheet' and
> > passing in request.POST (a QueryDict).  However, timesheet the view gets
> > called (again, recursively) with a QueryDict and promptly runs into trouble
> > when it tries to access the 'method' attribute of the argument it was
> > handed.  You need to give these things different names.
>
> > Karen
>
> I did give them different name, I know better.  It  solve my problem.

I have a few more problems, if some one can piont me in the right
direction:

1) I have a problem in the login template.  After I click submit the :

should send me some where but it send me to the default /accounts/
profile/


2) my form shows up now but it does not post the data to the MYSQL db,
and no error is given.

3)  how do I put a calendar in a view or template?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: adding date to template

2008-10-07 Thread KillaBee



On Oct 6, 4:44 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Oct 6, 2008 at 4:55 PM, KillaBee <
>
>
>
> [EMAIL PROTECTED]> wrote:
> > Thanks I have read the forms doc. and it helped a great deal.
> > now I am get this error:'QueryDict' object has no attribute 'method'
> > at line 12.
>
> > view:
> > from django.http import HttpResponse
> > from intranet.timesheets.models import Poll
> > from intranet.timesheets.models import Choice
> > from django.shortcuts import render_to_response, get_object_or_404
> > from django.core.urlresolvers import reverse
> > from django.contrib.auth import views
> > from django.contrib import databrowse
> > from django.contrib import auth
> > #from django.contrib.databrowse.plugins.calendars import
> > CalendarPlugin
>
> > def timesheet(request):
> >    if request.method == 'POST': # If the form has been
> > submitted..
> >        form = timesheet(request.POST) # A form bound to the POST data
>
> You've named both your view and your form 'timesheet'.  When your timesheet
> view gets called, it tries to instantiate a form by calling 'timesheet' and
> passing in request.POST (a QueryDict).  However, timesheet the view gets
> called (again, recursively) with a QueryDict and promptly runs into trouble
> when it tries to access the 'method' attribute of the argument it was
> handed.  You need to give these things different names.
>
> Karen

I did give them different name, I know better.  It  solve my problem.


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



Re: adding date to template

2008-10-07 Thread KillaBee



On Oct 6, 4:44 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Oct 6, 2008 at 4:55 PM, KillaBee <
>
>
>
> [EMAIL PROTECTED]> wrote:
> > Thanks I have read the forms doc. and it helped a great deal.
> > now I am get this error:'QueryDict' object has no attribute 'method'
> > at line 12.
>
> > view:
> > from django.http import HttpResponse
> > from intranet.timesheets.models import Poll
> > from intranet.timesheets.models import Choice
> > from django.shortcuts import render_to_response, get_object_or_404
> > from django.core.urlresolvers import reverse
> > from django.contrib.auth import views
> > from django.contrib import databrowse
> > from django.contrib import auth
> > #from django.contrib.databrowse.plugins.calendars import
> > CalendarPlugin
>
> > def timesheet(request):
> >    if request.method == 'POST': # If the form has been
> > submitted..
> >        form = timesheet(request.POST) # A form bound to the POST data
>
> You've named both your view and your form 'timesheet'.  When your timesheet
> view gets called, it tries to instantiate a form by calling 'timesheet' and
> passing in request.POST (a QueryDict).  However, timesheet the view gets
> called (again, recursively) with a QueryDict and promptly runs into trouble
> when it tries to access the 'method' attribute of the argument it was
> handed.  You need to give these things different names.
>
> Karen

I did give them different name, I know better.  It  solve my problem.


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



html inserted into csv file

2008-10-07 Thread Bobby Roberts

HI group.  I'm using the python csv writer to drop a csv file
available for download/opening when a button is clicked on my site.
The code is shown here

  myselchecks=selchecks
  sql="select * from inquiries where inquiry_id = (%s)"
%myselchecks

  ctx.request.write_header('Content-Type', 'text/csv')
  ctx.request.write_header('Content-Disposition','attachment;
filename=contacts.csv')
  ctx.request.write = ctx.request.write_content
  writer = csv.writer(ctx.request)
  c = ctx.request.db.cursor()
  c.execute(sql)

  writer.writerow([x[0] for x in c.description])
  writer.writerows(c.fetchall())


This code drops all selected fields into a temporary csv file named
"contact.csv" so that it can be downloaded.  However, the template
HTML is being appended after the last record in the csv file.

Is there any way to prevent this from happening?

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



Django Admin, Custom Views and the ChangeList object

2008-10-07 Thread Brandon Taylor

Hi everyone,

On a recent project, I was tasked with adding a workflow around a
model, which required some customization in the admin. I found that
when I did and override of a view, I no longer had access to the "cl",
or ChangeList object containing all of the objects for the view.

Filters and other built-in functions in the admin templates depend on
this object, but I haven't been able to figure out how to return this
object in my own custom views.

Can anyone shed some light as to how to create and pass in the "cl"
object list for use within custom admin views?

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



Re: Too many values to unpack

2008-10-07 Thread mthorley

Alright then, I found the answer to my own question. A patch for
"optgroups" was added to the ChoiceField at revision 7977. As it turns
out my custom widget breaks because it relies on the behavior of
ChoiceField before the patch. In order to fix the problem I'll have to
update my custom widget.

Thanks again to all
--
matthew

On Oct 7, 11:16 am, mthorley <[EMAIL PROTECTED]> wrote:
> Thanks that helps quite a bit. I see now, it expects each item/element
> in 'v' to be two-element tuple.
>
> Does any one know if there was a change made to the format of the
> choices argument for forms in django 1.0?
>
> --
> matthew
>
> On Oct 7, 10:37 am, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> > mthorley wrote:
> > > I just upgraded to django 1.0 and started getting this error. I was
> > > already using newforms and am quite surprised and dumbfounded by the
> > > errror. Generally this error would be caused by a missing comma in a
> > > tuple, but that appears to not be my case.
>
> > > I added some print statements (to django/forms/fields.py) and even
> > > over-wrote the variable in question to try and isolate the problem but
> > > have had no success.
>
> > > Below is a snip of the code in question, with my added debugging
> > > statements. Note that even when I override "v" with a tuple containing
> > > two string, I still get the error.
>
> > > That almost makes me think something is broken with my python install,
> > > however when I execute a similar statement from the python shell, it
> > > works fine, and when I run the server with a different installation of
> > > python I still get the error.
>
> > > Below the code snip is the output I get in my terminal when the below
> > > code runs. At the bottom of this post is a complete trace back of the
> > > error.
>
> > > I'm sure now that I am over looking something very obvious, and would
> > > be very appreciate to any one who can point it out to me.
>
> > > Thanks
> > > --
> > > matthew
>
> > > #  snip from django/forms/fields.py
> > > def valid_value(self, value):
> > >         "Check to see if the provided value is a valid choice"
> > >         for k, v in self.choices:
> > >             v = ('test', 'value') # for debugging
> > >             if type(v) in (tuple, list):
> > >                 # This is an optgroup, so look inside the group for
> > > options
> > >                 print v, type(v), 'len =', len(v), 'v[0] =', v[0],
> > > 'v[1] =', v[1] # added for debugging
> > >                 for k2, v2 in v:
> > >                     if value == smart_unicode(k2):
> > >                         return True
> > >             else:
> > >                 if value == smart_unicode(k):
> > >                     return True
> > >         return False
>
> > > # server output
> > > Django version 1.0-final-SVN-783, using settings 'sample.settings'
> > > Development server is running athttp://127.0.0.1:8000/
> > > Quit the server with CONTROL-C.
> > > ('test', 'value')  len = 2 v[0] = test v[1] = value
> > > [07/Oct/2008 09:40:59] "POST /free_personality_test/ HTTP/1.1" 500
> > > 86171
>
> > > # django traceback
> > > Environment:
>
> > > Request Method: POST
> > > Request URL:http://localhost:8000/free_personality_test/
> > > Django Version: 1.0-final-SVN-783
> > > Python Version: 2.5.2
> > > Installed Applications:
> > > ['django.contrib.admin',
> > >  'django.contrib.auth',
> > >  'django.contrib.comments',
> > >  'django.contrib.contenttypes',
> > >  'django.contrib.humanize',
> > >  'django.contrib.markup',
> > >  'django.contrib.sessions',
> > >  'django.contrib.sites',
> > >  'colorcode.profiler',
> > >  'colorcode.accounts',
> > >  'colorcode.email_campaigns',
> > >  'colorcode.coupons',
> > >  'colorcode.feedback',
> > >  'colorcode.registration',
> > >  'colorcode.accounts',
> > >  'colorcode.unregistered_users',
> > >  'colorcode']
> > > Installed Middleware:
> > > ('django.middleware.common.CommonMiddleware',
> > >  'django.contrib.sessions.middleware.SessionMiddleware',
> > >  'django.contrib.auth.middleware.AuthenticationMiddleware',
> > >  'djangologging.middleware.LoggingMiddleware',
> > >  'django.middleware.doc.XViewMiddleware',
> > >  'django.middleware.transaction.TransactionMiddleware',
> > >  'colorcode.profiler.middleware.PersonalityProfileMiddleware')
>
> > > Traceback:
> > > File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/core/
> > > handlers/base.py" in get_response
> > >   86.                 response = callback(request, *callback_args,
> > > **callback_kwargs)
> > > File "/Users/matthew/sandbox/cc-django-1.0-integration/site/colorcode/
> > > profiler/views.py" in personality_assessment
> > >   181.       strengthslims_form.is_valid() and \
> > > File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> > > forms/forms.py" in is_valid
> > >   120.         return self.is_bound and not bool(self.errors)
> > > File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> > > forms/forms.py" in _get_errors

Re: seeking help in model design...

2008-10-07 Thread David Hall

Hi Paul,

So long as the common model is not abstract, it should work.  Also, the 
common model must be the one that contains the parent field, and it 
should link to "Node" and not "self".

Using my first example, you should be able to traverse the tree using 
Node.parent and Node.children.  Traversing the tree using Job.parent, 
Job.children, Shot.parent or Shot.children will not work.

I've implemented the first example in one of my own apps, and it does 
work!  :P

David.

paul wrote:
> hi david,
> 
> many thanks for your help there. i initially tried the inheritance
> method - buut found that my tree traversal broke when trying to
> traverse a tree made of different types (ie, Node & Jobs).  maybe i
> did something wrong?  ie, should i be able to make a tree from those
> two types if derived from a common model.  or is each derived model
> incompatible with each other?
> 
> cheers,
> 
> paul
> 
> 
> On Oct 7, 11:16 am, David Hall <[EMAIL PROTECTED]> wrote:
>> Hi Paul,
>>
>> You've got a couple of options for this.  The first uses inheritance:
>>
>> class Node(models.Model):
>>  parent = models.ForeignKey("Node", blank=True, null=True,
>>  related_name="children")
>>
>> class Job(Node):
>>  pass
>>
>> class Shot(Node):
>>  pass
>>
>> The second uses generic foreign keys:
>>
>> class Job(models.Model):
>>  parent_type = models.ForeignKey("contenttypes.ContentType")
>>  parent_id = models.PositiveIntegerField(db_index=True)
>>  parent = GenerticForeignKey("parent_type", "parent_id")
>>
>> class Shot(models.Model):
>>  parent_type = models.ForeignKey("contenttypes.ContentType")
>>  parent_id = models.PositiveIntegerField(db_index=True)
>>  parent = GenerticForeignKey("parent_type", "parent_id")
>>
>> Personally, I'd go with the first, as it will integrate better with the
>> Djano admin application.  To traverse the tree, use the Node model.
>> Once you have got to your required location in the tree, use node.job or
>> node.shot to get the rest of the information.
>>
>> David.
>>
>>
>>
>> paul wrote:
>>> hi,
>>> I'm designing my first django app and would appreciate any advice how
>>> best to organise my models.
>>> I have a hierarchal model called Node.  this allows me to create a
>>> hierarchy of nodes - and perform hierarchal operatoins.  So far so
>>> good.  each node can be of two 'types':
>>> 1/ job
>>> 2/ shot
>>> I did originally try and make shot & job inherit the Node model.
>>> However, they couldn't 'link' together (ie, using self as a
>>> ForeignKey) - as they're of different types.  So i've made each of
>>> these two node types into seperate models.  each Node should only be
>>> linked to one type at a time.  From the manual/book - i belive that
>>> GenericForeignKey is the way to go.  ie, insert a GenericForeignKey
>>> field into the Node.  Does this sound like a good approach?
>>> Many Thanks in Advance,
>>> Paul
>> --
>>   David Hall
>>   Technical Lead
>>   Etianen.com
>>   Tel: 07896 106290
>>
>>   Email[EMAIL PROTECTED]
>>   Web  www.etianen.com
>> ---
>>   Ask for help at [EMAIL PROTECTED]
>>   Etianen.com is a small, professional web development agency that
>>   specialises in fast-paced, creative development.
>> - enlightened website development -
> > 

-- 
  David Hall
  Technical Lead
  Etianen.com
  Tel: 07896 106290

  Email[EMAIL PROTECTED]
  Web  www.etianen.com
---
  Ask for help at [EMAIL PROTECTED]
  Etianen.com is a small, professional web development agency that
  specialises in fast-paced, creative development.
- enlightened website development -

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



Re: Django Hosting Survey

2008-10-07 Thread James Matthews
I use dreamhost and am very happy. I have found there services (uptime and
performance) to workout quite well and i love there tech support team.

On Tue, Oct 7, 2008 at 7:55 AM, Benjamin Buch <[EMAIL PROTECTED]> wrote:

>
>
> Am 07.10.2008 um 15:49 schrieb Gour:
>
> > Benjamin> I can recommend djangohosting (http://djangohosting.ch), at
> > Benjamin> least if you're looking for a host in europe...
>
> > Heh, nice to hear...I'm also considering to take it...
> >
> > Is it OK for production site as well?
>
> I'm only hosting personal stuff there, so not much traffic...
> As Jarek said, perhaps it's better to go with dedicated hosting if you
> plan to have loads of traffic.
>
> But you can always ask the folks at djangohosting what they think of
> it directly, they are quite nice and answer quickly.
>
> benjamin
>
>
>
> >
>


-- 
http://www.goldwatches.com/

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



Re: Too many values to unpack

2008-10-07 Thread mthorley

Thanks that helps quite a bit. I see now, it expects each item/element
in 'v' to be two-element tuple.

Does any one know if there was a change made to the format of the
choices argument for forms in django 1.0?

--
matthew

On Oct 7, 10:37 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> mthorley wrote:
> > I just upgraded to django 1.0 and started getting this error. I was
> > already using newforms and am quite surprised and dumbfounded by the
> > errror. Generally this error would be caused by a missing comma in a
> > tuple, but that appears to not be my case.
>
> > I added some print statements (to django/forms/fields.py) and even
> > over-wrote the variable in question to try and isolate the problem but
> > have had no success.
>
> > Below is a snip of the code in question, with my added debugging
> > statements. Note that even when I override "v" with a tuple containing
> > two string, I still get the error.
>
> > That almost makes me think something is broken with my python install,
> > however when I execute a similar statement from the python shell, it
> > works fine, and when I run the server with a different installation of
> > python I still get the error.
>
> > Below the code snip is the output I get in my terminal when the below
> > code runs. At the bottom of this post is a complete trace back of the
> > error.
>
> > I'm sure now that I am over looking something very obvious, and would
> > be very appreciate to any one who can point it out to me.
>
> > Thanks
> > --
> > matthew
>
> > #  snip from django/forms/fields.py
> > def valid_value(self, value):
> >         "Check to see if the provided value is a valid choice"
> >         for k, v in self.choices:
> >             v = ('test', 'value') # for debugging
> >             if type(v) in (tuple, list):
> >                 # This is an optgroup, so look inside the group for
> > options
> >                 print v, type(v), 'len =', len(v), 'v[0] =', v[0],
> > 'v[1] =', v[1] # added for debugging
> >                 for k2, v2 in v:
> >                     if value == smart_unicode(k2):
> >                         return True
> >             else:
> >                 if value == smart_unicode(k):
> >                     return True
> >         return False
>
> > # server output
> > Django version 1.0-final-SVN-783, using settings 'sample.settings'
> > Development server is running athttp://127.0.0.1:8000/
> > Quit the server with CONTROL-C.
> > ('test', 'value')  len = 2 v[0] = test v[1] = value
> > [07/Oct/2008 09:40:59] "POST /free_personality_test/ HTTP/1.1" 500
> > 86171
>
> > # django traceback
> > Environment:
>
> > Request Method: POST
> > Request URL:http://localhost:8000/free_personality_test/
> > Django Version: 1.0-final-SVN-783
> > Python Version: 2.5.2
> > Installed Applications:
> > ['django.contrib.admin',
> >  'django.contrib.auth',
> >  'django.contrib.comments',
> >  'django.contrib.contenttypes',
> >  'django.contrib.humanize',
> >  'django.contrib.markup',
> >  'django.contrib.sessions',
> >  'django.contrib.sites',
> >  'colorcode.profiler',
> >  'colorcode.accounts',
> >  'colorcode.email_campaigns',
> >  'colorcode.coupons',
> >  'colorcode.feedback',
> >  'colorcode.registration',
> >  'colorcode.accounts',
> >  'colorcode.unregistered_users',
> >  'colorcode']
> > Installed Middleware:
> > ('django.middleware.common.CommonMiddleware',
> >  'django.contrib.sessions.middleware.SessionMiddleware',
> >  'django.contrib.auth.middleware.AuthenticationMiddleware',
> >  'djangologging.middleware.LoggingMiddleware',
> >  'django.middleware.doc.XViewMiddleware',
> >  'django.middleware.transaction.TransactionMiddleware',
> >  'colorcode.profiler.middleware.PersonalityProfileMiddleware')
>
> > Traceback:
> > File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/core/
> > handlers/base.py" in get_response
> >   86.                 response = callback(request, *callback_args,
> > **callback_kwargs)
> > File "/Users/matthew/sandbox/cc-django-1.0-integration/site/colorcode/
> > profiler/views.py" in personality_assessment
> >   181.       strengthslims_form.is_valid() and \
> > File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> > forms/forms.py" in is_valid
> >   120.         return self.is_bound and not bool(self.errors)
> > File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> > forms/forms.py" in _get_errors
> >   111.             self.full_clean()
> > File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> > forms/forms.py" in full_clean
> >   224.                     value = field.clean(value)
> > File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> > forms/fields.py" in clean
> >   648.         if not self.valid_value(value):
> > File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> > forms/fields.py" in valid_value
> >   658.                 for k2, v2 in v:
>
> > Exception Type: ValueError at /free_personality_test/
> > Exception Value: 

Re: setting a pre-selected value for the ChoiceField

2008-10-07 Thread Ugandhar Reddy

I had similar requirement i.e showing a pre-selected value in the
ChoiceField after looking into the ChoiceField django code its become
clear to me that the value of the text to be assigned to initial.

With this change country field in the Form object looks like:

country =  forms.ChoiceField(required=True, choices=arr,
label="Country", initial="TT")

Considering "TT" is the value associated with "Trindbad" text in the
"arr" list of tuples.

This might help you or others who might face this.

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



Re: Multiple ManyToMany relations with the same class

2008-10-07 Thread Pablo Catalina
# python manage.py validate
Error: One or more models did not validate:
concerts.concert: Accessor for m2m field 'musicans' clashes with related m2m
field 'person.concert_set'. Add a related_name argument to the definition
for 'musicans'.
concerts.concert: Accessor for m2m field 'coches' clashes with related m2m
field 'person.concert_set'. Add a related_name argument to the definition
for 'coches'.

OK.

The problems is with the order of the fields, I solve It:

Now, the problem:

models:
from django.db import models
from django.contrib.auth.models import User, UserManager


class instrumentos(models.Model):
nombre = models.CharField(max_length=10)
numero = models.PositiveSmallIntegerField(blank=True, null=True)
def __unicode__(self):
return self.nombre

class samberos(User):
objects = UserManager()
dni = models.CharField(max_length=10, blank=True, null=True)
phone = models.CharField(max_length=9, blank=True, null=True)
movil = models.CharField(max_length=9, blank=True, null=True)

class contactos(models.Model):
name = models.CharField(max_length=30)
phone = models.CharField(max_length=9, blank=True, null=True)
movil = models.CharField(max_length=9, blank=True, null=True)
mail = models.CharField(max_length=30, blank=True, null=True)
def __unicode__(self):
return self.name

class relaciones(models.Model):
sambero = models.ForeignKey(samberos)
instrumento =  models.ForeignKey(instrumentos)
def __unicode__(self):
return '%s => %s' % (self.sambero, self.instrumento)

class actuaciones(models.Model):
titulo = models.CharField(max_length=80)
fecha = models.DateTimeField()
descripcion = models.TextField()
lugar = models.CharField(max_length=200)
organizador = models.ManyToManyField(samberos)
samberos = models.ManyToManyField(relaciones, blank=True, null=True)
confirmada = models.BooleanField(default=False)
contacto = models.ManyToManyField(contactos)
coches = models.ManyToManyField(samberos, blank=True, null=True,
related_name='actuaciones_coches')
def __unicode__(self):
return self.titulo

And the solution is to change the order of the fields:

class actuaciones(models.Model):
titulo = models.CharField(max_length=80)
fecha = models.DateTimeField()
descripcion = models.TextField()
lugar = models.CharField(max_length=200)
organizador = models.ManyToManyField(samberos)
coches = models.ManyToManyField(samberos, blank=True, null=True,
related_name='actuaciones_coches')
samberos = models.ManyToManyField(relaciones, blank=True, null=True)
confirmada = models.BooleanField(default=False)
contacto = models.ManyToManyField(contactos)
def __unicode__(self):
return self.titulo


Thank you very much!!!

2008/10/7 Malcolm Tredinnick <[EMAIL PROTECTED]>

>
>
> On Mon, 2008-10-06 at 13:52 -0700, xkill wrote:
> > Hello,
> >
> > I tried to add multiple manytomany fields to a class, that pointing to
> > the same class.
> >
> > For example:
> >
> > class person(models.Model):
> > name = models.CharField(max_length=30)
> > phone = models.CharField(max_length=9, blank=True, null=True)
> > def __unicode__(self):
> > return self.name
> >
> > class concert(models.Model):
> > title = models.CharField(max_length=80)
> > musicans = models.ManyToManyField(person)
> > coches = models.ManyToManyField(person, blank=True, null=True)
> > def __unicode__(self):
> > return self.title
> >
> >
> > But it doesn't work, how can I do it?
>
> "It doesn't work" is not very specific. It could mean anything from "an
> error was reported" to "it failed silently" all the way up to "my
> computer burst into flames".
>
> So what actually happened?
>
> As James hinted at, I suspect you will actually see an error messages
> when you run "manage.py validate" saying that you need to add a related
> name to one of the ManyToManyFields (the validation will complain about
> both fields, but you need to fix at least one of them).
>
> If that is the case, then the problem is that since the reverse relation
> name for a ManyToManyField is, by default, created from the name of the
> model it is contained in, both of those fields will end up with the same
> default reverse name (used when you are filtering from a Person back to
> a Concert). So you need to set the related_name attribute on one of the
> fields (or on both of them).
>
> Regards,
> Malcolm
>
>
>
> >
>


-- 
Pablo Catalina <[EMAIL PROTECTED]>

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



Implementing "Friends application" using many-to-many relationship on self

2008-10-07 Thread NEX

Hi everybody,
I was trying to add friend network feature to my site. But I have to
use User model from django.contrib.auth .
I tried extending User model and added a many-to-many field in the
extended model. But then I was unable to retrieve all the
connections(friends) using the "_set" feature.
Please suggest some way I can implement the same.
Thanx

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



Re: Too many values to unpack

2008-10-07 Thread Steve Holden

mthorley wrote:

> I just upgraded to django 1.0 and started getting this error. I was
> already using newforms and am quite surprised and dumbfounded by the
> errror. Generally this error would be caused by a missing comma in a
> tuple, but that appears to not be my case.
> 
> I added some print statements (to django/forms/fields.py) and even
> over-wrote the variable in question to try and isolate the problem but
> have had no success.
> 
> Below is a snip of the code in question, with my added debugging
> statements. Note that even when I override "v" with a tuple containing
> two string, I still get the error.
> 
> That almost makes me think something is broken with my python install,
> however when I execute a similar statement from the python shell, it
> works fine, and when I run the server with a different installation of
> python I still get the error.
> 
> Below the code snip is the output I get in my terminal when the below
> code runs. At the bottom of this post is a complete trace back of the
> error.
> 
> I'm sure now that I am over looking something very obvious, and would
> be very appreciate to any one who can point it out to me.
> 
> Thanks
> --
> matthew
> 
> #  snip from django/forms/fields.py
> def valid_value(self, value):
> "Check to see if the provided value is a valid choice"
> for k, v in self.choices:
> v = ('test', 'value') # for debugging
> if type(v) in (tuple, list):
> # This is an optgroup, so look inside the group for
> options
> print v, type(v), 'len =', len(v), 'v[0] =', v[0],
> 'v[1] =', v[1] # added for debugging
> for k2, v2 in v:
> if value == smart_unicode(k2):
> return True
> else:
> if value == smart_unicode(k):
> return True
> return False
> 
> # server output
> Django version 1.0-final-SVN-783, using settings 'sample.settings'
> Development server is running at http://127.0.0.1:8000/
> Quit the server with CONTROL-C.
> ('test', 'value')  len = 2 v[0] = test v[1] = value
> [07/Oct/2008 09:40:59] "POST /free_personality_test/ HTTP/1.1" 500
> 86171
> 
> # django traceback
> Environment:
> 
> Request Method: POST
> Request URL: http://localhost:8000/free_personality_test/
> Django Version: 1.0-final-SVN-783
> Python Version: 2.5.2
> Installed Applications:
> ['django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.comments',
>  'django.contrib.contenttypes',
>  'django.contrib.humanize',
>  'django.contrib.markup',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'colorcode.profiler',
>  'colorcode.accounts',
>  'colorcode.email_campaigns',
>  'colorcode.coupons',
>  'colorcode.feedback',
>  'colorcode.registration',
>  'colorcode.accounts',
>  'colorcode.unregistered_users',
>  'colorcode']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'djangologging.middleware.LoggingMiddleware',
>  'django.middleware.doc.XViewMiddleware',
>  'django.middleware.transaction.TransactionMiddleware',
>  'colorcode.profiler.middleware.PersonalityProfileMiddleware')
> 
> Traceback:
> File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/core/
> handlers/base.py" in get_response
>   86. response = callback(request, *callback_args,
> **callback_kwargs)
> File "/Users/matthew/sandbox/cc-django-1.0-integration/site/colorcode/
> profiler/views.py" in personality_assessment
>   181.   strengthslims_form.is_valid() and \
> File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> forms/forms.py" in is_valid
>   120. return self.is_bound and not bool(self.errors)
> File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> forms/forms.py" in _get_errors
>   111. self.full_clean()
> File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> forms/forms.py" in full_clean
>   224. value = field.clean(value)
> File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> forms/fields.py" in clean
>   648. if not self.valid_value(value):
> File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
> forms/fields.py" in valid_value
>   658. for k2, v2 in v:
> 
> Exception Type: ValueError at /free_personality_test/
> Exception Value: too many values to unpack

The issue here is that the for statement expects a *sequence* of
two-element tuples to iterate over and, for whatever reason, it's only
getting a single tuple. Hence the error message.

I hope this gives you a start on finding out what's actually wrong ...

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

--~--~-~--~~~---~--~~
You received 

Re: seeking help in model design...

2008-10-07 Thread paul

hi david,

many thanks for your help there. i initially tried the inheritance
method - buut found that my tree traversal broke when trying to
traverse a tree made of different types (ie, Node & Jobs).  maybe i
did something wrong?  ie, should i be able to make a tree from those
two types if derived from a common model.  or is each derived model
incompatible with each other?

cheers,

paul


On Oct 7, 11:16 am, David Hall <[EMAIL PROTECTED]> wrote:
> Hi Paul,
>
> You've got a couple of options for this.  The first uses inheritance:
>
> class Node(models.Model):
>      parent = models.ForeignKey("Node", blank=True, null=True,
>                      related_name="children")
>
> class Job(Node):
>      pass
>
> class Shot(Node):
>      pass
>
> The second uses generic foreign keys:
>
> class Job(models.Model):
>      parent_type = models.ForeignKey("contenttypes.ContentType")
>      parent_id = models.PositiveIntegerField(db_index=True)
>      parent = GenerticForeignKey("parent_type", "parent_id")
>
> class Shot(models.Model):
>      parent_type = models.ForeignKey("contenttypes.ContentType")
>      parent_id = models.PositiveIntegerField(db_index=True)
>      parent = GenerticForeignKey("parent_type", "parent_id")
>
> Personally, I'd go with the first, as it will integrate better with the
> Djano admin application.  To traverse the tree, use the Node model.
> Once you have got to your required location in the tree, use node.job or
> node.shot to get the rest of the information.
>
> David.
>
>
>
> paul wrote:
> > hi,
>
> > I'm designing my first django app and would appreciate any advice how
> > best to organise my models.
>
> > I have a hierarchal model called Node.  this allows me to create a
> > hierarchy of nodes - and perform hierarchal operatoins.  So far so
> > good.  each node can be of two 'types':
> > 1/ job
> > 2/ shot
>
> > I did originally try and make shot & job inherit the Node model.
> > However, they couldn't 'link' together (ie, using self as a
> > ForeignKey) - as they're of different types.  So i've made each of
> > these two node types into seperate models.  each Node should only be
> > linked to one type at a time.  From the manual/book - i belive that
> > GenericForeignKey is the way to go.  ie, insert a GenericForeignKey
> > field into the Node.  Does this sound like a good approach?
>
> > Many Thanks in Advance,
>
> > Paul
>
> --
>   David Hall
>   Technical Lead
>   Etianen.com
>   Tel: 07896 106290
>
>   Email   [EMAIL PROTECTED]
>   Web      www.etianen.com
> ---
>   Ask for help at [EMAIL PROTECTED]
>   Etianen.com is a small, professional web development agency that
>   specialises in fast-paced, creative development.
> - enlightened website development -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



timeit module put my app into infinite loop

2008-10-07 Thread K*K

Hi, all

I'm writing a program to test django's mysql performance, use timeit
to profile. But it make my app into infinite loop. always write data
into database.

How can I resolve it ?

The source code like below:


import timeit

from django.shortcuts import render_to_response
from testDjango.benchmark.models import Django

loop_range = 10

def benchmark(request):
global loop_range

insert_timer = timeit.Timer("benchmark_insert()", "from
testDjango.bench import benchmark_insert")
insert_timer.repeat(loop_range)
insert_speed = insert_timer.timeit()

return render_to_response('benchmark.html', locals())

def benchmark_insert():
p1 = Django(foobar='Test foo',)
p1.save()
del p1


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



Too many values to unpack

2008-10-07 Thread mthorley

I just upgraded to django 1.0 and started getting this error. I was
already using newforms and am quite surprised and dumbfounded by the
errror. Generally this error would be caused by a missing comma in a
tuple, but that appears to not be my case.

I added some print statements (to django/forms/fields.py) and even
over-wrote the variable in question to try and isolate the problem but
have had no success.

Below is a snip of the code in question, with my added debugging
statements. Note that even when I override "v" with a tuple containing
two string, I still get the error.

That almost makes me think something is broken with my python install,
however when I execute a similar statement from the python shell, it
works fine, and when I run the server with a different installation of
python I still get the error.

Below the code snip is the output I get in my terminal when the below
code runs. At the bottom of this post is a complete trace back of the
error.

I'm sure now that I am over looking something very obvious, and would
be very appreciate to any one who can point it out to me.

Thanks
--
matthew

#  snip from django/forms/fields.py
def valid_value(self, value):
"Check to see if the provided value is a valid choice"
for k, v in self.choices:
v = ('test', 'value') # for debugging
if type(v) in (tuple, list):
# This is an optgroup, so look inside the group for
options
print v, type(v), 'len =', len(v), 'v[0] =', v[0],
'v[1] =', v[1] # added for debugging
for k2, v2 in v:
if value == smart_unicode(k2):
return True
else:
if value == smart_unicode(k):
return True
return False

# server output
Django version 1.0-final-SVN-783, using settings 'sample.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
('test', 'value')  len = 2 v[0] = test v[1] = value
[07/Oct/2008 09:40:59] "POST /free_personality_test/ HTTP/1.1" 500
86171

# django traceback
Environment:

Request Method: POST
Request URL: http://localhost:8000/free_personality_test/
Django Version: 1.0-final-SVN-783
Python Version: 2.5.2
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.comments',
 'django.contrib.contenttypes',
 'django.contrib.humanize',
 'django.contrib.markup',
 'django.contrib.sessions',
 'django.contrib.sites',
 'colorcode.profiler',
 'colorcode.accounts',
 'colorcode.email_campaigns',
 'colorcode.coupons',
 'colorcode.feedback',
 'colorcode.registration',
 'colorcode.accounts',
 'colorcode.unregistered_users',
 'colorcode']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'djangologging.middleware.LoggingMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'django.middleware.transaction.TransactionMiddleware',
 'colorcode.profiler.middleware.PersonalityProfileMiddleware')

Traceback:
File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/core/
handlers/base.py" in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/Users/matthew/sandbox/cc-django-1.0-integration/site/colorcode/
profiler/views.py" in personality_assessment
  181.   strengthslims_form.is_valid() and \
File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
forms/forms.py" in is_valid
  120. return self.is_bound and not bool(self.errors)
File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
forms/forms.py" in _get_errors
  111. self.full_clean()
File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
forms/forms.py" in full_clean
  224. value = field.clean(value)
File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
forms/fields.py" in clean
  648. if not self.valid_value(value):
File "/Users/matthew/sandbox/cc-django-1.0-integration/lib/django/
forms/fields.py" in valid_value
  658. for k2, v2 in v:

Exception Type: ValueError at /free_personality_test/
Exception Value: too many values to unpack
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Hosting Survey

2008-10-07 Thread Benjamin Buch


Am 07.10.2008 um 15:49 schrieb Gour:

> Benjamin> I can recommend djangohosting (http://djangohosting.ch), at
> Benjamin> least if you're looking for a host in europe...

> Heh, nice to hear...I'm also considering to take it...
>
> Is it OK for production site as well?

I'm only hosting personal stuff there, so not much traffic...
As Jarek said, perhaps it's better to go with dedicated hosting if you  
plan to have loads of traffic.

But you can always ask the folks at djangohosting what they think of  
it directly, they are quite nice and answer quickly.

benjamin



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



simple bookkeeping package

2008-10-07 Thread copelco

Hello!

Just thought I'd ping the list to announce a simple Django bookkeeping
package we've been working on here at Caktus.  minibooks helps you
manage invoicing, receipts, bank and credit card statement
reconciliation, project reports, etc.  The project is is free and open
source!  It is still in a very early stage (we add to it as need be),
but we've been using it as our company portal for a few months now.

Check it out!
https://secure.caktusgroup.com/projects/minibooks

  colin

--
Colin Copeland
Caktus Consulting Group, LLC
P.O. Box 1454
Carrboro, NC 27510
(919) 951-0052
http://www.caktusgroup.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Extend contrib.comments?

2008-10-07 Thread fitzage

I want to add one additional piece of data to the comment form.
Basically a checkbox that says whether or not the commenter wants to
be notified of followup comments.

I know how to add the checkbox. I just created a comments/form.html
template and added the checkbox to it. I know that the data is getting
passed correctly.

Now how do I grab that on the backend without having to modify the
comment app directly? There is probably a simple, django-standard way
to do this, but I'm at a loss. I already have a function that emails
admin users when a comment is posted, but I'm not sure I understand it
well enough to piggy-back off of that, and I'm not even sure that I
can.

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



Django book Capitulo 7 -spanish-

2008-10-07 Thread flomanadj

El capítulo séptimo de este libro Django Book, tiene algunos errores, y falta 
de explicaciones. Agrego los cambios que realice para poder evitar los errores 
de ejecución:

http://flomana.spaces.live.com/blog/cns!3550E4D9E2BD3A98!1333.entry


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



Re: Pyjamas-Desktop and Pyjamas

2008-10-07 Thread Finder

Wow, this is kindof of an exciting combo. Thanks!

On Sep 9, 7:12 pm, bedros <[EMAIL PROTECTED]> wrote:
> thanks, this looks very promising, I'll try it out
>
> On Sep 6, 1:51 pm, lkcl <[EMAIL PROTECTED]> wrote:
>
> > > words, the code that _was_ handed to the pyjamas compiler is instead
> > > handed to the python compiler.
>
> >  correction: python _interpreter_ :)  pyjamas-desktop ends up doing
> > "import pywebkitgtk", which pulls in webkit, which, given that it's a
> > Browser Engine, ends up with *identically* displayed content on the
> > desktop as you get through the equivalent AJAX.
>
> >  a bit faster, as well, because webkit is _blindingly_ quick.

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



Re: Django Admin - Does not see templates, images or templates.

2008-10-07 Thread Karen Tracey
On Tue, Oct 7, 2008 at 10:50 AM, NoviceSortOf <[EMAIL PROTECTED]> wrote:

>
>
> Yes I restarted, but I also noticed in urls.py
>
> 2 distinct suggested admin url patterns...
>
> (r'^admin/', include('django.contrib.admin.urls')),
> # (r'^admin/(.*)', admin.site.root),
>
> Commenting out the second entry seems to correct
> the admin_urls problem.
>
> Why does the documentation suggest
>  (r'^admin/(.*)', admin.site.root)?
>

What version of Django are you running?  These two patterns are from
different Django versions.  The first, with the include of
'django.contrib.admin.urls' was the old one -- that file does not exist in
Django 1.0.  The 2nd pattern, referring to 'admin.site.root', is what should
be used for Django 1.0.

If you are actually running 1.0 the old pattern would have produced a "No
module named urls" error since django/contrib/admin/urls.py no longer
exists.  So I am confused as to how commenting out the 2nd version, which is
the one that is correct for 1.0, would have fixed that problem.

Karen

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



Re: Django Admin - Does not see templates, images or templates.

2008-10-07 Thread NoviceSortOf


Yes I restarted, but I also noticed in urls.py

2 distinct suggested admin url patterns...

(r'^admin/', include('django.contrib.admin.urls')),
# (r'^admin/(.*)', admin.site.root),

Commenting out the second entry seems to correct
the admin_urls problem.

Why does the documentation suggest
 (r'^admin/(.*)', admin.site.root)?





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



Re: Django + tiny_mce

2008-10-07 Thread Brian Jones

I fixed it. Once I knew that the APPEND_SLASH was kicking in *because*
the url couldn't be found, I just moved the relevant line in my
urlconf to be the first one in my 'urlpatterns' tuple, and from there
I believe everything in the example in the book "just worked". It is
unbelievably annoying that I had to spend so many hours to get it to
work, but I thank you for your clue!

brian

On Tue, Oct 7, 2008 at 10:00 AM, Brian K. Jones <[EMAIL PROTECTED]> wrote:
>
> Sorry for the mix up. The log messages I pasted in are from yet
> another test config, but they're the same return codes I get, and the
> same addslash behavior... I'll see what I can do to figure out why the
> url wouldn't be matching. Thanks.
>
> On Oct 7, 9:30 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>> On Tue, Oct 7, 2008 at 9:07 AM, Brian K. Jones <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>>
>>
>> > This scenario has been brought up before, but I'm having a problem
>> > that hasn't yet been reported. I was unable to reply to the whole list
>> > in the google groups interface - only "Reply to author" was available.
>> > Here's the thread for reference:
>>
>> >http://groups.google.com/group/django-users/browse_thread/thread/c1f1...
>>
>> > In short, I'm going through the Practical Django Projects book, trying
>> > to get the tiny_mce configuration on pages 24 and 25 to work, and I'm
>> > having zero luck. I'm using Django 1.0, and the development server, on
>> > a mac, running Leopard.
>>
>> > It looks like I have the urls.py and change_form.html set up properly,
>> > but the problem is that whether I try to load the admin page, or I try
>> > to access tiny_mce.js directly in my browser from the django
>> > development server, the dev server is redirecting me (302) to the same
>> > path I ask for, except with a "/" at the end. So I get this in my
>> > log:
>>
>> > [07/Oct/2008 08:48:31] "GET /tiny_mce.js HTTP/1.1" 302 0
>> > [07/Oct/2008 08:48:31] "GET /tiny_mce.js/ HTTP/1.1" 404 1708
>>
>> > Of course, that's no good, but I have no idea where the magical
>> > setting is to change that.
>>
>> You probably don't want to change that.  It's the APPEND_SLASH setting that
>> is doing this and the fact that it is coming into play means there's a
>> problem elsewhere: namely the incoming url for tiny_mce.js is not being
>> matched by anything in your urlconf.  This one in particular is missing the
>> tiny_mce/ prefix that your static server urlpattern is expecting.  Is this
>> one coming in from your manual testing or from an actual page request?  The
>> change_form template fragment you show does have the /tiny_mce/ prefix so
>> I'm puzzled how it would be missing from that page request.
>>
>> I don't have time to comb through all of what you provided, but the problem
>> you want to solve is making the initial request coming in match something
>> that will be served by your static server configuration, not turning off
>> APPEND_SLASH.  Solve the first problem and you won't see the 2nd behavior.
>>
>> Karen
>>
>> > I've tried removing/replacing trailing
>> > slashes all over the place, to no avail, so I imagine this is
>> > something in the settings.py file that's hurting me. Here are my
>> > files:
>>
>> > urls.py:
>> > 
>> > from django.conf.urls.defaults import *
>>
>> > # Uncomment the next two lines to enable the admin:
>> > from django.contrib import admin
>> > admin.autodiscover()
>>
>> > urlpatterns = patterns('',
>> ># Example:
>> ># (r'^cms/', include('cms.foo.urls')),
>>
>> ># Uncomment the admin/doc line below and add
>> > 'django.contrib.admindocs'
>> ># to INSTALLED_APPS to enable admin documentation:
>> > (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>
>> ># Uncomment the next line to enable the admin:
>> > (r'^admin/(.*)', admin.site.root),
>> > (r'', include('django.contrib.flatpages.urls')),
>> > (r'^tiny_mce/(?P.*)$', 'django.views.static.serve',
>> > {'document_root':'/Users/jonesy/django/tinymce/jscripts'}),
>> > )
>> > ==
>>
>> > change_form.html (just the relevant section)
>> > ==
>> > {% extends "admin/base_site.html" %}
>> > {% load i18n admin_modify adminmedia %}
>>
>> > {% block extrahead %}{{ block.super }}
>> > 
>> > 
>> > 
>> > tinyMCE.init({
>> >   mode: "textareas",
>> >   theme: "simple"
>> > });
>> > 
>>
>> > {{ media }}
>> > {% endblock %}
>> > ==
>>
>> > settings.py
>> > ==
>> > # Django settings for cms project.
>>
>> > DEBUG = True
>> > TEMPLATE_DEBUG = DEBUG
>>
>> > ADMINS = (
>> ># ('Your Name', '[EMAIL PROTECTED]'),
>> > )
>>
>> > MANAGERS = ADMINS
>>
>> > DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
>> > 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>> > DATABASE_NAME = 'cms' # Or path to database file if using
>> > sqlite3.
>> > DATABASE_USER = 'jonesy'   

Re: Storage of files in database

2008-10-07 Thread john


On Oct 7, 2008, at 8:29 AM, Mariana Romão wrote:

> Hi,
> I'm new in the group and in the use of Dajngo too.
> I'm developing an application that needs storage files ".py" in  
> database (and maybe other types of files). I thought Django did this  
> "automatically" when I define the field in the model as FileField,  
> but I realized that what does is put in database a column as a  
> varchar.
>
> What I need do for that the database storage the file? Create other  
> table or other column manually?

If all you're doing is serving those files, don't put them in the  
database. There are more efficient ways to do that, even if you  
require authentication or other special handling.

If you're doing something more interesting with them, then two  
approaches spring to mind. You could look into writing a custom  
Storage implementation to save them into the database (see 
http://docs.djangoproject.com/en/dev/ref/files/storage/) 
, or you could just add a FileField to your form instead of your  
model, and in the form's save method, read the file contents into a  
TextField on your model.


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



Re: dynamic associations?

2008-10-07 Thread Alex G

I had not, actually, but it seems like it provides for exactly what
I'm trying to do.  I will look into it further, thank you.

On Oct 6, 6:25 pm, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 6 oct, 23:53, Alex G <[EMAIL PROTECTED]> wrote:> Dear django-users,
>
> > Does anyone know of a way to dynamically create an object related to a
> > model whose name is not known until runtime?  Essentially, I have a
> > situation wherein I need to create this associated object, but seem to
> > have no way of getting at it.
>
> Not sure whether this is relevant, but did you look at the contenttype
> framework in contribs ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Hosting Survey

2008-10-07 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-10-07, o godz. 15:49, przez Gour:

>> "Benjamin" == Benjamin Buch <[EMAIL PROTECTED]> writes:
>
> Benjamin> I can recommend djangohosting (http://djangohosting.ch), at
> Benjamin> least if you're looking for a host in europe...  It doesn't
> Benjamin> seem like you do, but I thought I should mention it  
> anyway...
>
> Benjamin> It's great for personal stuff, didn't do something big there
> Benjamin> (60MB RAM, 1GB storage, 4€ per month, easy setup...)
>
> Heh, nice to hear...I'm also considering to take it...
>
> Is it OK for production site as well?


I wouldn't go into production with shared hosting if you expect at  
least moderate popularity. You'd end up paying more than dedicated  
hosting would cost you (eg. at hetzner.de).

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R, Redefine
[EMAIL PROTECTED]


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



Re: Can this be solved without hardcoded SQL?

2008-10-07 Thread Adi Jörg Sieker

Hi,

Kasper Grubbe wrote:
> Hi guys.
>
> I have a date in my database. And i want to list all years and months
> in that, without duplicates. For an example i want to print out (only
> if they exists in the database):
>
> 2008:
> January
> August
> December
>
> 2007:
> September
> December
>
> I can get the data out without duplicates with this SQL query:
> SELECT DATE_FORMAT(my_date_field, '%Y %m') AS year_month FROM mytable
> GROUP BY year_month
>
> This will give me a couple of rows which i will work on in python to
> get it to work for my solution. Is there an easier way? And can i get
> rid of the SQL and use "pure" django models?
>
>
Have a look at: 
http://docs.djangoproject.com/en/dev/ref/models/querysets/#dates-field-kind-order-asc

adi

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



Re: Django + tiny_mce

2008-10-07 Thread Brian K. Jones

Sorry for the mix up. The log messages I pasted in are from yet
another test config, but they're the same return codes I get, and the
same addslash behavior... I'll see what I can do to figure out why the
url wouldn't be matching. Thanks.

On Oct 7, 9:30 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Oct 7, 2008 at 9:07 AM, Brian K. Jones <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > This scenario has been brought up before, but I'm having a problem
> > that hasn't yet been reported. I was unable to reply to the whole list
> > in the google groups interface - only "Reply to author" was available.
> > Here's the thread for reference:
>
> >http://groups.google.com/group/django-users/browse_thread/thread/c1f1...
>
> > In short, I'm going through the Practical Django Projects book, trying
> > to get the tiny_mce configuration on pages 24 and 25 to work, and I'm
> > having zero luck. I'm using Django 1.0, and the development server, on
> > a mac, running Leopard.
>
> > It looks like I have the urls.py and change_form.html set up properly,
> > but the problem is that whether I try to load the admin page, or I try
> > to access tiny_mce.js directly in my browser from the django
> > development server, the dev server is redirecting me (302) to the same
> > path I ask for, except with a "/" at the end. So I get this in my
> > log:
>
> > [07/Oct/2008 08:48:31] "GET /tiny_mce.js HTTP/1.1" 302 0
> > [07/Oct/2008 08:48:31] "GET /tiny_mce.js/ HTTP/1.1" 404 1708
>
> > Of course, that's no good, but I have no idea where the magical
> > setting is to change that.
>
> You probably don't want to change that.  It's the APPEND_SLASH setting that
> is doing this and the fact that it is coming into play means there's a
> problem elsewhere: namely the incoming url for tiny_mce.js is not being
> matched by anything in your urlconf.  This one in particular is missing the
> tiny_mce/ prefix that your static server urlpattern is expecting.  Is this
> one coming in from your manual testing or from an actual page request?  The
> change_form template fragment you show does have the /tiny_mce/ prefix so
> I'm puzzled how it would be missing from that page request.
>
> I don't have time to comb through all of what you provided, but the problem
> you want to solve is making the initial request coming in match something
> that will be served by your static server configuration, not turning off
> APPEND_SLASH.  Solve the first problem and you won't see the 2nd behavior.
>
> Karen
>
> > I've tried removing/replacing trailing
> > slashes all over the place, to no avail, so I imagine this is
> > something in the settings.py file that's hurting me. Here are my
> > files:
>
> > urls.py:
> > 
> > from django.conf.urls.defaults import *
>
> > # Uncomment the next two lines to enable the admin:
> > from django.contrib import admin
> > admin.autodiscover()
>
> > urlpatterns = patterns('',
> >    # Example:
> >    # (r'^cms/', include('cms.foo.urls')),
>
> >    # Uncomment the admin/doc line below and add
> > 'django.contrib.admindocs'
> >    # to INSTALLED_APPS to enable admin documentation:
> >     (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> >    # Uncomment the next line to enable the admin:
> >     (r'^admin/(.*)', admin.site.root),
> >     (r'', include('django.contrib.flatpages.urls')),
> >     (r'^tiny_mce/(?P.*)$', 'django.views.static.serve',
> > {'document_root':'/Users/jonesy/django/tinymce/jscripts'}),
> > )
> > ==
>
> > change_form.html (just the relevant section)
> > ==
> > {% extends "admin/base_site.html" %}
> > {% load i18n admin_modify adminmedia %}
>
> > {% block extrahead %}{{ block.super }}
> > 
> > 
> > 
> > tinyMCE.init({
> >   mode: "textareas",
> >   theme: "simple"
> > });
> > 
>
> > {{ media }}
> > {% endblock %}
> > ==
>
> > settings.py
> > ==
> > # Django settings for cms project.
>
> > DEBUG = True
> > TEMPLATE_DEBUG = DEBUG
>
> > ADMINS = (
> >    # ('Your Name', '[EMAIL PROTECTED]'),
> > )
>
> > MANAGERS = ADMINS
>
> > DATABASE_ENGINE = 'mysql'           # 'postgresql_psycopg2',
> > 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> > DATABASE_NAME = 'cms'             # Or path to database file if using
> > sqlite3.
> > DATABASE_USER = 'jonesy'             # Not used with sqlite3.
> > DATABASE_PASSWORD = 'whatever'         # Not used with sqlite3.
> > DATABASE_HOST = 'localhost'             # Set to empty string for
> > localhost. Not used with sqlite3.
> > DATABASE_PORT = ''             # Set to empty string for default. Not
> > used with sqlite3.
>
> > # Local time zone for this installation. Choices can be found here:
> > #http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
> > # although not all choices may be available on all operating systems.
> > # If running in a Windows environment this must be set to the same as
> > your

Re: dynamic associations?

2008-10-07 Thread Alex G

Ah, it works for me too, except in the case of relations.

Essentially, it all comes down to one line of code; given an instance
model, a method as a string, and a secondary instance of a model,
something like:

getattr(model_instance, attr_name).add(model_to_add)

So, something like:

>>> from project.models import MyModel
>>> my_model = MyModel(attr1 = 'value')
>>> my_model.attr1   # works fine, of course
'value'
>>> getattr(my_model, 'attr1') # also works, no surprises yet
'value'
>>> getattr(my_model, 'some_relation_or_fk') # but...
Traceback (most recent call last):
  File "", line 1, in 
  File "/Library/Python/2.5/site-packages/django/db/models/fields/
related.py", line 235, in __get__
raise self.field.rel.to.DoesNotExist
DoesNotExist

So I can't assign it to a variable (in order to set it)...  Any ideas?

-Alex.

On Oct 6, 7:38 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Tue, Oct 7, 2008 at 5:53 AM, Alex G <[EMAIL PROTECTED]> wrote:
>
> > Dear django-users,
>
> > Does anyone know of a way to dynamically create an object related to a
> > model whose name is not known until runtime?  Essentially, I have a
> > situation wherein I need to create this associated object, but seem to
> > have no way of getting at it.
>
> > I am trying to do it by way of getattr(self, attr_name), but it would
> > seem that the nature of relationships dictates that the attribute
> > designated by attr_name is in fact a method masquerading as an
> > attribute by way of property, so any attempt to retrieve it runs the
> > method, which causes:
>
> > Traceback (most recent call last):
> >  File "", line 1, in 
> >  File "/Library/Python/2.5/site-packages/django/db/models/fields/
> > related.py", line 235, in __get__
> >    raise self.field.rel.to.DoesNotExist
> > django.contrib.auth.models.DoesNotExist
>
> > The problem is, of course, that I can't assign an attribute sans the
> > ability to specify which attribute I'm after...  Does anyone have any
> > suggestions?
>
> I'd suggest you post more of your code :-)
>
> The error trace by itself doesn't really help - it just tells us that
> you're getting a DoesNotExist exception. The getattr()/setattr()
> approach of dynamically modifying attributes works (I use it all the
> time), so if it's not working for you, there is something else going
> on. However, we can't really tell what that is without some sample
> code.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Hosting Survey

2008-10-07 Thread Gour
> "Benjamin" == Benjamin Buch <[EMAIL PROTECTED]> writes:

Benjamin> I can recommend djangohosting (http://djangohosting.ch), at
Benjamin> least if you're looking for a host in europe...  It doesn't
Benjamin> seem like you do, but I thought I should mention it anyway...

Benjamin> It's great for personal stuff, didn't do something big there
Benjamin> (60MB RAM, 1GB storage, 4€ per month, easy setup...)

Heh, nice to hear...I'm also considering to take it...

Is it OK for production site as well?


Sincerely,
Gour

-- 

Gour  | Zagreb, Croatia  | GPG key: C6E7162D



pgpwAMa6lDwgq.pgp
Description: PGP signature


Re: Django Hosting Survey

2008-10-07 Thread Masklinn


On 6 Oct 2008, at 19:30 , Jeff wrote:
> I am about to begin a new Django project and I am currently evaluating
> hosting options. I know there has been a number of discussions on this
> topic, and I have read most of them. However, seeing how quickly
> things change in the web development / hosting world, I wanted to get
> some opinions if the following summary still holds true.


I'd suggest checking http://djangofriendly.com/hosts/



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



Re: Django + tiny_mce

2008-10-07 Thread Karen Tracey
On Tue, Oct 7, 2008 at 9:07 AM, Brian K. Jones <[EMAIL PROTECTED]> wrote:

>
> This scenario has been brought up before, but I'm having a problem
> that hasn't yet been reported. I was unable to reply to the whole list
> in the google groups interface - only "Reply to author" was available.
> Here's the thread for reference:
>
> http://groups.google.com/group/django-users/browse_thread/thread/c1f111291e1e45f1/ce9f9f28da72388a?lnk=gst=development+server+slash+404#
>
> In short, I'm going through the Practical Django Projects book, trying
> to get the tiny_mce configuration on pages 24 and 25 to work, and I'm
> having zero luck. I'm using Django 1.0, and the development server, on
> a mac, running Leopard.
>
> It looks like I have the urls.py and change_form.html set up properly,
> but the problem is that whether I try to load the admin page, or I try
> to access tiny_mce.js directly in my browser from the django
> development server, the dev server is redirecting me (302) to the same
> path I ask for, except with a "/" at the end. So I get this in my
> log:
>
> [07/Oct/2008 08:48:31] "GET /tiny_mce.js HTTP/1.1" 302 0
> [07/Oct/2008 08:48:31] "GET /tiny_mce.js/ HTTP/1.1" 404 1708
>
> Of course, that's no good, but I have no idea where the magical
> setting is to change that.


You probably don't want to change that.  It's the APPEND_SLASH setting that
is doing this and the fact that it is coming into play means there's a
problem elsewhere: namely the incoming url for tiny_mce.js is not being
matched by anything in your urlconf.  This one in particular is missing the
tiny_mce/ prefix that your static server urlpattern is expecting.  Is this
one coming in from your manual testing or from an actual page request?  The
change_form template fragment you show does have the /tiny_mce/ prefix so
I'm puzzled how it would be missing from that page request.

I don't have time to comb through all of what you provided, but the problem
you want to solve is making the initial request coming in match something
that will be served by your static server configuration, not turning off
APPEND_SLASH.  Solve the first problem and you won't see the 2nd behavior.

Karen


> I've tried removing/replacing trailing
> slashes all over the place, to no avail, so I imagine this is
> something in the settings.py file that's hurting me. Here are my
> files:
>
> urls.py:
> 
> from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
># Example:
># (r'^cms/', include('cms.foo.urls')),
>
># Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
># to INSTALLED_APPS to enable admin documentation:
> (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
># Uncomment the next line to enable the admin:
> (r'^admin/(.*)', admin.site.root),
> (r'', include('django.contrib.flatpages.urls')),
> (r'^tiny_mce/(?P.*)$', 'django.views.static.serve',
> {'document_root':'/Users/jonesy/django/tinymce/jscripts'}),
> )
> ==
>
> change_form.html (just the relevant section)
> ==
> {% extends "admin/base_site.html" %}
> {% load i18n admin_modify adminmedia %}
>
> {% block extrahead %}{{ block.super }}
> 
> 
> 
> tinyMCE.init({
>   mode: "textareas",
>   theme: "simple"
> });
> 
>
> {{ media }}
> {% endblock %}
> ==
>
> settings.py
> ==
> # Django settings for cms project.
>
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
>
> ADMINS = (
># ('Your Name', '[EMAIL PROTECTED]'),
> )
>
> MANAGERS = ADMINS
>
> DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
> 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
> DATABASE_NAME = 'cms' # Or path to database file if using
> sqlite3.
> DATABASE_USER = 'jonesy' # Not used with sqlite3.
> DATABASE_PASSWORD = 'whatever' # Not used with sqlite3.
> DATABASE_HOST = 'localhost' # Set to empty string for
> localhost. Not used with sqlite3.
> DATABASE_PORT = '' # Set to empty string for default. Not
> used with sqlite3.
>
> # Local time zone for this installation. Choices can be found here:
> # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
> # although not all choices may be available on all operating systems.
> # If running in a Windows environment this must be set to the same as
> your
> # system time zone.
> TIME_ZONE = 'America/New_York'
>
> # Language code for this installation. All choices can be found here:
> # http://www.i18nguy.com/unicode/language-identifiers.html
> LANGUAGE_CODE = 'en-us'
>
> SITE_ID = 1
>
> # If you set this to False, Django will make some optimizations so as
> not
> # to load the internationalization machinery.
> USE_I18N = True
>
> # Absolute path to the directory that holds media.
> # 

Django + tiny_mce

2008-10-07 Thread Brian K. Jones

This scenario has been brought up before, but I'm having a problem
that hasn't yet been reported. I was unable to reply to the whole list
in the google groups interface - only "Reply to author" was available.
Here's the thread for reference:
http://groups.google.com/group/django-users/browse_thread/thread/c1f111291e1e45f1/ce9f9f28da72388a?lnk=gst=development+server+slash+404#

In short, I'm going through the Practical Django Projects book, trying
to get the tiny_mce configuration on pages 24 and 25 to work, and I'm
having zero luck. I'm using Django 1.0, and the development server, on
a mac, running Leopard.

It looks like I have the urls.py and change_form.html set up properly,
but the problem is that whether I try to load the admin page, or I try
to access tiny_mce.js directly in my browser from the django
development server, the dev server is redirecting me (302) to the same
path I ask for, except with a "/" at the end. So I get this in my
log:

[07/Oct/2008 08:48:31] "GET /tiny_mce.js HTTP/1.1" 302 0
[07/Oct/2008 08:48:31] "GET /tiny_mce.js/ HTTP/1.1" 404 1708

Of course, that's no good, but I have no idea where the magical
setting is to change that. I've tried removing/replacing trailing
slashes all over the place, to no avail, so I imagine this is
something in the settings.py file that's hurting me. Here are my
files:

urls.py:

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^cms/', include('cms.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
 (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
 (r'^admin/(.*)', admin.site.root),
 (r'', include('django.contrib.flatpages.urls')),
 (r'^tiny_mce/(?P.*)$', 'django.views.static.serve',
{'document_root':'/Users/jonesy/django/tinymce/jscripts'}),
)
==

change_form.html (just the relevant section)
==
{% extends "admin/base_site.html" %}
{% load i18n admin_modify adminmedia %}

{% block extrahead %}{{ block.super }}



tinyMCE.init({
   mode: "textareas",
   theme: "simple"
});


{{ media }}
{% endblock %}
==

settings.py
==
# Django settings for cms project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', '[EMAIL PROTECTED]'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'cms' # Or path to database file if using
sqlite3.
DATABASE_USER = 'jonesy' # Not used with sqlite3.
DATABASE_PASSWORD = 'whatever' # Not used with sqlite3.
DATABASE_HOST = 'localhost' # Set to empty string for
localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'America/New_York'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com;, "http://example.com/media/;
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/;, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = '=f++nfum([EMAIL PROTECTED])n+mk8lh^%ad3%=898p)41-4$vwg13'

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'cms.urls'

TEMPLATE_DIRS = ('/Users/jonesy/django/cms/templates',
# 

Re: Generating widget based on class type for a Custom Form

2008-10-07 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-10-07, o godz. 14:36, przez Ulises:

>
>> and for other controls, I need to generate
>>   
>
> How about using widget.attrs?
>
> http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.Widget.attrs


AFAIK, this adds attributes to widget output. Using these attributes  
in surrounding element, you'd end up with:



-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R, Redefine
[EMAIL PROTECTED]


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



Re: Where do custom fields go?

2008-10-07 Thread Donn

> I've been playing with custom fields, but I'm not sure where the
> python script containing the custom field definition goes? 
Anywhere you can reach it with an import statement. I put mine alongside 
models.py etc. and call it forms.py


\d

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



Where do custom fields go?

2008-10-07 Thread Penguin

Hi Guys,

I've been playing with custom fields, but I'm not sure where the
python script containing the custom field definition goes? In the
project directory? In a new application? I have searched high and low,
but no docs seem to cover this.
Any help would be appreciated.

Regards,
Xiao

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



Re: Django Admin - Does not see templates, images or templates.

2008-10-07 Thread Karen Tracey
On Tue, Oct 7, 2008 at 6:17 AM, NoviceSortOf <[EMAIL PROTECTED]> wrote:

> Thanks the link did the trick.
>
> The admin page though still loads rough, sometimes
> taking 3 screen refreshes to get past a
> "No module named urls" error - then it finally loads.
>

Did you restart Apache after making the changes? The "sometimes it loads OK
and sometimes it doesn't" problem usually means you've got some Apache
processes running old code and some running new.

Karen

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



Re: Django Hosting Survey

2008-10-07 Thread Benjamin Buch


Am 06.10.2008 um 19:30 schrieb Jeff:

> I am about to begin a new Django project and I am currently evaluating
> hosting options.

I can recommend djangohosting (http://djangohosting.ch), at least if  
you're looking for a host in europe...
It doesn't seem like you do, but I thought I should mention it anyway...

It's great for personal stuff, didn't do something big there (60MB  
RAM, 1GB storage, 4€ per month, easy setup...)

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



Re: Generating widget based on class type for a Custom Form

2008-10-07 Thread Leon Yeh | New Avenue.net

Hi, I also need to switch the  and  tags, so attrs would 
not help.

For example for select widget I need to generate
  

and for other controls, I need to generate
  


Thanks
Leon Yeh




Ulises wrote:
>> and for other controls, I need to generate
>>   
> 
> How about using widget.attrs?
> 
> http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.Widget.attrs
> 
> Best,
> 
> U
> 
> > 

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



Re: Generating widget based on class type for a Custom Form

2008-10-07 Thread Ulises

> and for other controls, I need to generate
>   

How about using widget.attrs?

http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.Widget.attrs

Best,

U

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



Re: Generating widget based on class type for a Custom Form

2008-10-07 Thread Leon Yeh | New Avenue.net

Hi Ronny, terima kasih... :-)

I am trying to generate different output for css styling purpose.

For example for select widget I need to generate
  

and for other controls, I need to generate
  

I don't know how field.as_widget would help.

Leon Yeh
New Avenue Systems Inc.
Office: (626)254-1757 x880
[EMAIL PROTECTED]
Imagination Delivered. www.newavenue.net




Ronny Haryanto wrote:
> On Tue, Oct 7, 2008 at 7:09 AM, Leon Yeh | New Avenue.net
> <[EMAIL PROTECTED]> wrote:
>> I need to generate a different output based if it is a select input type
>> or it is a text field.
>>
>> This code does not work. I am trying to do something like this:
>>
>> {% for field in form %}
>> {% ifequal field.field.widget django.forms.widgets.Select  %}
>>   {{ field.label_tag }} {{ field.errors }} {{ field }}
>> {% else %}
>>   It is not select field
>> {% endifequal %}
>> {% endfor %}
>>
>>
>> I am having hard time to do the ifequal statement. It does not get the
>> correct comparison. It always return true. Any idea how to fix this ?
> 
> Leon,
> 
> Any reason why {{ field.as_widget }} wouldn't work in your case?
> 
> Ronny
> 
> > 

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



Storage of files in database

2008-10-07 Thread Mariana Romão
Hi,
I'm new in the group and in the use of Dajngo too.
I'm developing an application that needs storage files ".py" in database
(and maybe other types of files). I thought Django did this "automatically"
when I define the field in the model as FileField, but I realized that what
does is put in database a column as a varchar.

What I need do for that the database storage the file? Create other table or
other column manually?

(I'm sorry for a bad english).
Thanks.
Mariana Romão

-- 

Grad. Ciência da Computação - UFCG
 Aluna do PET - Computação

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



Re: Django Hosting Survey

2008-10-07 Thread Anders Bergh

On Mon, Oct 6, 2008 at 7:30 PM, Jeff <[EMAIL PROTECTED]> wrote:
> 2. Slicehost - for those that want COMPLETE control of their hosting
> environment. Only drawback (for some) is that everything needs to be
> installed from scratch.

I have two vps's from Linode, they're a lot like Slicehost but you get
more bang for the buck. For example, for $20 you get 256 at Slicehost,
but Linode gives you 320 MB. They also give you 2 GB more space. They
both have similar hardware (quad core servers, 64-bit). The "slices"
are 32-bit, but you can go with 64-bit if you want to. That's one of
the reasons why I switched.

http://www.linode.com/

-- 
Anders Bergh

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



Access a model's original get_absolute_url

2008-10-07 Thread Erik Allik

Hi everybody,

I need a way to access a model's original get_absolute_url after the  
ABSOLUTE_URL_OVERRIDES settings has taken effect. Currently I've  
patched Django for this need so it will always alias the existing  
get_absolute_url method as old_get_absolute_url when it overrides that  
method, but patching stuff is ugly and poses deployment/reusability/ 
upgradability issues, so I'm thinking maybe there's a hook or a signal  
that I could use to achieve the same effect.

Any hints will be appreciated!

Erik

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



Re: pdf file generated problem

2008-10-07 Thread Thomas Guettler

Hi.

 what is "attach"? It is StringIO object. And these objects don't have
a name attribute.

try this:

mail.attach('mypdfname.pdf', attach.get_value(), 'application/pdf')


 HTH,
  Thomas

laspal schrieb:
> ok I can use cStringIO for it but my real problem is how to attach
> file in emailmessage??
>
> response = HttpResponse(mimetype='application/pdf')
> response['Content-Disposition'] = 'attachment;
> filename=report1.pdf'
> buffer = StringIO()
> p = canvas.Canvas(buffer)
> pdf = buffer.getvalue()
> buffer.close()
> response.write(pdf)
> -
> attach = pdf
> mail = EmailMessage(subject, message, sender,[send_to])
> mail.attach(attach.name, attach.read(), attach.content_type)
> mail.send()
>
> this will give me error saying object has no attribute 'name'.
>
>   


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


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



Re: Django Admin - Does not see templates, images or templates.

2008-10-07 Thread NoviceSortOf


Thanks the link did the trick.

The admin page though still loads rough, sometimes
taking 3 screen refreshes to get past a
"No module named urls" error - then it finally loads.






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



Re: seeking help in model design...

2008-10-07 Thread David Hall

Hi Paul,

You've got a couple of options for this.  The first uses inheritance:

class Node(models.Model):
 parent = models.ForeignKey("Node", blank=True, null=True,
 related_name="children")

class Job(Node):
 pass

class Shot(Node):
 pass

The second uses generic foreign keys:

class Job(models.Model):
 parent_type = models.ForeignKey("contenttypes.ContentType")
 parent_id = models.PositiveIntegerField(db_index=True)
 parent = GenerticForeignKey("parent_type", "parent_id")

class Shot(models.Model):
 parent_type = models.ForeignKey("contenttypes.ContentType")
 parent_id = models.PositiveIntegerField(db_index=True)
 parent = GenerticForeignKey("parent_type", "parent_id")

Personally, I'd go with the first, as it will integrate better with the 
Djano admin application.  To traverse the tree, use the Node model. 
Once you have got to your required location in the tree, use node.job or 
node.shot to get the rest of the information.

David.

paul wrote:
> hi,
> 
> I'm designing my first django app and would appreciate any advice how
> best to organise my models.
> 
> I have a hierarchal model called Node.  this allows me to create a
> hierarchy of nodes - and perform hierarchal operatoins.  So far so
> good.  each node can be of two 'types':
> 1/ job
> 2/ shot
> 
> I did originally try and make shot & job inherit the Node model.
> However, they couldn't 'link' together (ie, using self as a
> ForeignKey) - as they're of different types.  So i've made each of
> these two node types into seperate models.  each Node should only be
> linked to one type at a time.  From the manual/book - i belive that
> GenericForeignKey is the way to go.  ie, insert a GenericForeignKey
> field into the Node.  Does this sound like a good approach?
> 
> Many Thanks in Advance,
> 
> Paul
> > 

-- 
  David Hall
  Technical Lead
  Etianen.com
  Tel: 07896 106290

  Email[EMAIL PROTECTED]
  Web  www.etianen.com
---
  Ask for help at [EMAIL PROTECTED]
  Etianen.com is a small, professional web development agency that
  specialises in fast-paced, creative development.
- enlightened website development -

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



Django GridContainers at Media Temple

2008-10-07 Thread Kegan

Wonder if anyone have had experience with the new Media Template
Django GridContainer?

http://mediatemple.net/webhosting/gs/django.html

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



Re: ANN: Updated Django Cheat Sheet

2008-10-07 Thread Andrew Durdin

Issue 4 is out with a correction to the arguments for DecimalField in
the Form Fields section.
Thanks to Doug Van Horn for pointing out the error.

Download it from http://www.mercurytide.co.uk/whitepapers/django-cheat-sheet/

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



Filter horizontal question

2008-10-07 Thread Donn

Hi,
After spending many (many) days on my own CRUD system I am *really* seeing the 
beauty of the Django Admin system! 

A few quick questions -- regarding Many to many field and filter_horizontal : 
1. Assuming I have thousands of records, call them books, does that interface 
provide paging?
2. If so, can one control the number of records before paging cuts-in?
3. If not, how could I go about paging them myself?

Hope someone can help,
\d

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



Re: pdf file generated problem

2008-10-07 Thread laspal

ok I can use cStringIO for it but my real problem is how to attach
file in emailmessage??

response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment;
filename=report1.pdf'
buffer = StringIO()
p = canvas.Canvas(buffer)
pdf = buffer.getvalue()
buffer.close()
response.write(pdf)
-
attach = pdf
mail = EmailMessage(subject, message, sender,[send_to])
mail.attach(attach.name, attach.read(), attach.content_type)
mail.send()

this will give me error saying object has no attribute 'name'.

Thanks.

On Oct 7, 12:34 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> Hi Iaspal,
>
> here is what I think:
>  - Why do you use try:...except? You don't see the real traceback.
>If you want to add debugging information (eg. logging.error('...'))
> you could do it like this:
> try:
>
> except:
> logging.error('...')
> raise # reraise exception
>
>  - Why do you use HttpResponse for the canvas? You could use cStringIO or
>   a tempfile.
>
>  - Please post the traceback, if you ask for help. It shows where the
> root of the problem is.
>
>   Thomas
>
> laspal schrieb:
>
>
>
> > Hi,
> > I am trying to generate pdf file and send the generated file by mail
> > to the user.
> > But I am getting value error as I am not sure how to attach file.
>
> > here is my view function:
>
> > def companies_report(request, companyid):
> > _user = request.user
> > sender = _user.email
> > company = Company.objects.get(id= companyid)
> > response = HttpResponse(mimetype='application/pdf')
> > response['Content-Disposition'] = 'attachment;
> > filename=report1.pdf'
>
> > p = canvas.Canvas(response)
> > p.drawString(100, 100, "Hello world.")
>
> > p.showPage()
> > p.save()
> > try:
> > subject = "Company Report"
> > message = "Company report"
> > send_to = _user.email
> > attach = response
> > mail = EmailMessage(subject, message, sender,[send_to])
> > mail.attach(attach.name, attach.read(), attach.content_type)
> > mail.send()
> > except Exception, e:
> > raise ValueError, e
> > request.user.message_set.create(message="Mail sent successfully.")
> > return HttpResponseRedirect('../')
>
> > The problem here is if I say attach = response then I am getting error
> > 'HttpResponse' object has no attribute 'name'
> > So my question is how to attach the generated file in EmailMessage.
>
> > Thanks.
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Intensive Computations

2008-10-07 Thread bruno desthuilliers



puzzler a écrit :
> > I don't know much about your background so please forgive me if I give
> > you obvious advises, but perhaps you'd be better *first* coding the
> > solution to your problem - eventually looking for help on
> > comp.lang.python. Then you'll have real facts, not estimations.
> > Specially if yourcomputationhappens to be memory-hungry, since the
> > best way to put a server on it's knees is to make it go swapping. So
> > in your case, you may want to look for space optimisation instead of
> > time optimisation.
>
> Well, yes, but I'm trying to decide what language to use to program
> this computation.  Since my web framework is written entirely in
> Django, there's a bit of an advantage to using Python, just in terms
> of seamlessly calling the function from Django (but do I use separate
> threads, separate process, or do I not even need to worry about
> that?).  But I can probably get a hundred-fold speedup by using a
> statically-typed, compiled language.  But then I am forced to use a
> separate os process to call the program (more heavyweight than
> threads?), and need to find a language with an API to manipulate the
> database, worry about privileges, etc.

First point : if your computation happens to be that "intensive", you
don't want to call it 'in process'. It just won't scale. So you do
have to use separate processes - possibly on different machines.

Second point : if you computation only depends on it's inputs (which
you said was the case), then you just don't have to worry about
database access - this will still be handled by your Django app. All
you need is a way to invoke the computation process with appropriate
params, and a way to know when it's done and get the result back. All
this  - inter process communication - is far from rocket science, and
has long been solved in quite a lot of ways.

Third point : all this is based on "wet finger" estimate. So it's just
worth nothing. Experience proved that we developpers can be very bad
at this kind of guessing games. IOW, until you have facts, you just
don't know.

So, to make a long story short, don't bother about this for now, and
start writing code. Start in Python, benchmark, profile, and then
you'll at least have a clue as what the real constraints are and what
the appropriate strategy might be.

> That's why I'm asking now, ahead of programming, for more info about
> how hard it is to incorporate an intensive computation into the Django
> framework.

Stop worrying about django, it's has nothing to do with it. And don't
worry about how Python can communicate with either another process
(whatever langage has been used to implement the program) or a C-coded
library or whatever.

>  It could very well affect my choice of language.

Python is good for prototyping, and it's the main language used in
your app. So start with Python. Once you'll have something up and
running, you'll have hard facts wrt/ time-space problem, and it will
*then* be time considering alternate solutions.  IOW : don't worry
about Django, don't worry about how Django, don't worrry about Python,
and *write this damn code*. I repeat : until you do have working code,
everrything else is just blah blah, waste of time and premature
optimization.

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



Re: SQL: Migration How To?

2008-10-07 Thread Thomas Guettler

Benjamin Buch schrieb:
> Is there somewhere a place in the documentation where SQL migration  
> strategies are explained a little?
>   
[cut]

I do it like this:
# Before changes to models.py
./manage.py sqlall myapp > orig.sql
# Modify models.py
./manage.py sqlall myapp > new.sql

diff orig.sql new.sql

Now you need to now a little SQL to write the correct "ALTER TABLE ..." 
statements.
But must of the time it is not that difficult.

HTH,
  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


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



Re: pdf file generated problem

2008-10-07 Thread Thomas Guettler

Hi Iaspal,

here is what I think:
 - Why do you use try:...except? You don't see the real traceback.
   If you want to add debugging information (eg. logging.error('...'))
you could do it like this:
try:

except:
logging.error('...')
raise # reraise exception

 - Why do you use HttpResponse for the canvas? You could use cStringIO or
  a tempfile.

 - Please post the traceback, if you ask for help. It shows where the 
root of the problem is.

  Thomas

laspal schrieb:
> Hi,
> I am trying to generate pdf file and send the generated file by mail
> to the user.
> But I am getting value error as I am not sure how to attach file.
>
> here is my view function:
>
> def companies_report(request, companyid):
> _user = request.user
> sender = _user.email
> company = Company.objects.get(id= companyid)
> response = HttpResponse(mimetype='application/pdf')
> response['Content-Disposition'] = 'attachment;
> filename=report1.pdf'
>
> p = canvas.Canvas(response)
> p.drawString(100, 100, "Hello world.")
>
> p.showPage()
> p.save()
> try:
> subject = "Company Report"
> message = "Company report"
> send_to = _user.email
> attach = response
> mail = EmailMessage(subject, message, sender,[send_to])
> mail.attach(attach.name, attach.read(), attach.content_type)
> mail.send()
> except Exception, e:
> raise ValueError, e
> request.user.message_set.create(message="Mail sent successfully.")
> return HttpResponseRedirect('../')
>
> The problem here is if I say attach = response then I am getting error
> 'HttpResponse' object has no attribute 'name'
> So my question is how to attach the generated file in EmailMessage.
>
> Thanks.
>   


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


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



  1   2   >