admin_media_prefix in page source is wrong

2011-07-15 Thread Bram Deprettere

I'm having the following situation;
django project named inventory
Made a folder static for media-files. Inside static-folder I made a link 
to ../../lib/python2.7/site-packages/django/contrib/admin/static/admin 
for the admin-media files.


When I go to http://inventory/admin, the static/admin files are not 
loaded - so the page is shown without formatting.


When I check the page source, it shows 
admin_media_prefix="http://inventory/admin/"; instead of

http://inventory/static/admin/ as set in settings.py.

I'm using django 1.4 in a virtual env, nginx as frontend. When I go to 
http://inventory/static/admin it shows the css,... so that is configured 
correctly.




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



AW: admin_media_prefix in page source is wrong

2011-07-15 Thread Szabo, Patrick (LNG-VIE)
I'm sorry maybe this is a dumb question but what do you mean when you say

" Inside static-folder I made a link 
to ../../lib/python2.7/site-packages/django/contrib/admin/static/admin 
for the admin-media files."

?!


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 


-Ursprüngliche Nachricht-

Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von Bram Deprettere
Gesendet: Freitag, 15. Juli 2011 09:11
An: django-users@googlegroups.com
Betreff: admin_media_prefix in page source is wrong

I'm having the following situation;
django project named inventory
Made a folder static for media-files. Inside static-folder I made a link 
to ../../lib/python2.7/site-packages/django/contrib/admin/static/admin 
for the admin-media files.

When I go to http://inventory/admin, the static/admin files are not 
loaded - so the page is shown without formatting.

When I check the page source, it shows 
admin_media_prefix="http://inventory/admin/"; instead of
http://inventory/static/admin/ as set in settings.py.

I'm using django 1.4 in a virtual env, nginx as frontend. When I go to 
http://inventory/static/admin it shows the css,... so that is configured 
correctly.



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



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



Django: forms and custom templates

2011-07-15 Thread samuele.mattiuzzo
basic problem: i need to create real customized templates for my
django forms. That's it. I'm used to style the forms based on django's
output. This time is different, the html/css template is already done
(months before i was hired) and i cannot modify it, so i need django
to output exactly that html code.

I've read a lot throu django docs, and i found a lot, but i have to
admit, i couldn't put bits and pieces togheter, with order, to do what
i need to do.

Now, with CheckboxSelectMultiple the html output is this:


   
   ...


What i actually need to do is create something like
CustomCheckboxSelectMultiple to output exactly this template:


...
...


And so on for other types of form widgets. It's the only way i can
think of to create my forms with that particular layout they gave me.

I'm actually stuck on this, i cannot seem to be able to put everything
togheter to start coding my forms.
How can i manage this? If you have any example too, it will be great!
Otherwise, just point me towards the right direction please... sadly,
looking in the docs, as i said before, didn't actually help me

Thanks all 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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



AW: Django: forms and custom templates

2011-07-15 Thread Szabo, Patrick (LNG-VIE)
I'm not sure if i understood your problem a 100 percent so i'll just write what 
i think you want ^^

>From what i understand i think you can use the code that has already been 
>written. Of course you might want to edit it a little bit for it to comply 
>with the other templates. 

If you want to work with the data from the forms, you'll have to pass the forms 
data (whatever is inputet or selected) to a view (per urls.py) and then do what 
you need to do with the data there. 



. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 


-Ursprüngliche Nachricht-

Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von samuele.mattiuzzo
Gesendet: Freitag, 15. Juli 2011 09:43
An: Django users
Betreff: Django: forms and custom templates

basic problem: i need to create real customized templates for my
django forms. That's it. I'm used to style the forms based on django's
output. This time is different, the html/css template is already done
(months before i was hired) and i cannot modify it, so i need django
to output exactly that html code.

I've read a lot throu django docs, and i found a lot, but i have to
admit, i couldn't put bits and pieces togheter, with order, to do what
i need to do.

Now, with CheckboxSelectMultiple the html output is this:


   
   ...


What i actually need to do is create something like
CustomCheckboxSelectMultiple to output exactly this template:


...
...


And so on for other types of form widgets. It's the only way i can
think of to create my forms with that particular layout they gave me.

I'm actually stuck on this, i cannot seem to be able to put everything
togheter to start coding my forms.
How can i manage this? If you have any example too, it will be great!
Otherwise, just point me towards the right direction please... sadly,
looking in the docs, as i said before, didn't actually help me

Thanks all 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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



group by and retrieve to template date from foreinKey

2011-07-15 Thread Suprnaturall
Hi dear django users :)

I m facing a stupid problem.
Here is my models.py :

class Video(models.Model):
(...)
category = models.ForeignKey('Category')
   (...)

class Category(models.Model):
name = models.CharField(max_length=250)

I'm trying in a tags to make a group by on the category field and
retrieve in the template the name of the first vid and its category
name.

Here it s my teamplate.py :

@register.inclusion_tag('appFront/home_tag.html')
def home_vods():
videos =
Video.objects.values('category').annotate(dcount=Count('category'))
return {'videos': videos}

And here it s the template.html


{% for video in videos %}
{{ video.title }}{{ video.title }}|
{{ video.category.name }}
{% endfor %}


I retrieve the correct number of row (in my case 3) but it s seems
that the query set is empty because it may invoque this query " SELECT
category FROM video group by category ", so i retrieve the correct
amount of row but the only field populate is category, on the other
hand i don t retrieve in my .html the date video.category.name, i got
nothing oO

Do you have any clue ? What is the correct way to make a group by and
then retrieve all the data in the table ?

Thx for your help :)

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



Re: something about django mysql database long connection

2011-07-15 Thread Kejun He
hi,
I found a method to make a persistent connection to database.

from django.core import signals
from django.db import close_connection
signals.request_finished.disconnect(close_connection)   <==

I have tested, it work normally!

regards,
he



On Fri, Jul 15, 2011 at 9:44 AM, Kejun He  wrote:

> Hi,
> I will look the DBUtils imformation first.
>
> Thank you very much
>
> regards,
> he
>
>
> On Thu, Jul 14, 2011 at 11:58 AM, Jian Chang wrote:
>
>> Try DBUtils
>> http://www.webwareforpython.org/DBUtils/Docs/UsersGuide.html
>>
>> 2011/7/13 Kejun He 
>>
>>> hi,
>>> I am sorry. My English is very bad.
>>>
>>> Yes, i want to make persistent databases connection on each session.
>>>
>>>
>>> and yesterday i try to modify the  code on
>>> "site-packages\django\db\__init__.py"
>>>
>>> 
>>> def close_connection(**kwargs):
>>> for conn in connections.all():
>>> conn.close()
>>> #signals.request_finished.connect(close_connection) <---
>>>
>>> 
>>>
>>> could it work?
>>>
>>> regards,
>>> he
>>>
>>>
>>>
>>>
>>> On Mon, Jul 11, 2011 at 7:31 PM, Cal Leeming [Simplicity Media Ltd] <
>>> cal.leem...@simplicitymedialtd.co.uk> wrote:
>>>


 On Mon, Jul 11, 2011 at 4:49 AM, oops  wrote:

> hi,
> Now, i am doing a django project, and use models to do all operation
> about data in mysql db.
>
> and i think that it would connect to database whenever  do some
> operation like 'XXX.objects.all()' , may be it would cast much of
> resource on database connection. So i need a connection never being
> desconnected.
>

 At as best guess (as the question is somewhat broken), are you asking
 how to make persistent connections which are guaranteed to never time out 
 in
 a single session?

 Could you clarify a little more on your question please?

 Cal


>
> Does django has this function?  And how to do for it??
>
> thank you
> rgs,
> he
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
  --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To post to this group, send email to django-users@googlegroups.com.
 To unsubscribe from this group, send email to
 django-users+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/django-users?hl=en.

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

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



Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread Venkatraman S
concise reply : I would strongly suggest you to have a look at
django-taggit.
OTOH, use django-debug-toolbar to diagnose the sql that is being fired.

-V

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



Re: creating a simple mailbox

2011-07-15 Thread bh.hoseini
yes i've recently done that (to make project easier i'm covering
"inbox" part first), what should i do next?
that's very kind of you, thanks

On Jul 14, 1:35 pm, ikatanda  wrote:
> have you created your views and added the url to point to the app
> mailbox page?
>
> On Jul 14, 7:36 am, bahare hoseini  wrote:
>
>
>
> > hi there,
> > as my first project i'm going to create a simple mail box to recieve or
> > delete Emails,
> > i made my models in my application, could you please tell me the next steps?
>
> > thanks.- Hide quoted text -
>
> - Show quoted text -

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



AW: creating a simple mailbox

2011-07-15 Thread Szabo, Patrick (LNG-VIE)
Maybe one of those is something for you
http://djangopackages.com/grids/g/email/ 



. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 


-Ursprüngliche Nachricht-

Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von bh.hoseini
Gesendet: Freitag, 15. Juli 2011 11:04
An: Django users
Betreff: Re: creating a simple mailbox

yes i've recently done that (to make project easier i'm covering
"inbox" part first), what should i do next?
that's very kind of you, thanks

On Jul 14, 1:35 pm, ikatanda  wrote:
> have you created your views and added the url to point to the app
> mailbox page?
>
> On Jul 14, 7:36 am, bahare hoseini  wrote:
>
>
>
> > hi there,
> > as my first project i'm going to create a simple mail box to recieve or
> > delete Emails,
> > i made my models in my application, could you please tell me the next steps?
>
> > thanks.- Hide quoted text -
>
> - Show quoted text -

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



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



Aw: Django: forms and custom templates

2011-07-15 Thread Juergen Schackmann
I am also not sure, what exactly you are looking for, but what about this:
https://docs.djangoproject.com/en/1.3/topics/forms/#customizing-the-form-template
so you will have complete control of your html code??? 

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



Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Paul Walsh
I am pretty new to Django - new enough to be developing my first Django app 
on 1.3. So, I am basing all my work on class-based generic views, and have 
never used the older generic view functions.

A problem I have is the lack of examples and documentation on the new 
class-based generic views.

My current problem is that I am trying to build some forms based on models. 
I am not using Django Forms (ModelForm), but rather CreateView. CreateView 
gets me almost there, but I can't find any documentation on (1) how to 
exclude fields, and (2) how to fix a value for a field.

My class is like so:

class CreateCampaignView(CreateView):
model = Campaign
template_name = "forms/create.html"

I tried exclude from ModelForms, like this:

class CreateCampaignView(UserAccountCreateView):
model = Campaign
template_name = "forms/create.html"
exclude = ('user', 'name', 'content_inlined')

and that doesn't work. Is there another way to exclude fields using 
CreateView?

and, one of my excluded fields, "user", also needs to get the value of 
self.request.user

I tried again here to apply the docs from ModelForms here for CreateView, 
but it doesn't work.


Some might suggest I use Django Forms - it is a reasonable suggestion of 
course. But, being new, I don't have any "view legacy" and I just like the 
idea of working with class-based generic views where possible.

thanks.


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



Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Kenneth Gonsalves
On Fri, 2011-07-15 at 02:18 -0700, Paul Walsh wrote:
> I am pretty new to Django - new enough to be developing my first
> Django app 
> on 1.3. So, I am basing all my work on class-based generic views, and
> have 
> never used the older generic view functions. 

caveat - I have never used generic views, class based or otherwise, but
I was under the impression that if one wants customised forms or views,
generic is not the way to go.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Venkatraman S
Class based views reduce the amount of code written, but i am yet to get a
grasp of it(need more experimentation).
Somehow, i prefer plain 'old' way of methods in views.py which respond to
different urls - it gives me better control and is easily to maintain.

-V

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



Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Michał Sawicz
Dnia 2011-07-15, pią o godzinie 16:07 +0530, Kenneth Gonsalves pisze:
> caveat - I have never used generic views, class based or otherwise,
> but
> I was under the impression that if one wants customised forms or
> views,
> generic is not the way to go. 

Why not? The model edit views use the ModelFormMixin, which has a
get_form_class that can be overriden [1] to taste. You can simply get
the form from super().get_form_class and put it through
modelform_factory [2] again to only get the form for the fields you
want.

The classy generic views are really flexible like that. Sadly docs
aren't that great, so reading the code is probably best to get the hang
of it.

[1]
https://code.djangoproject.com/browser/django/trunk/django/views/generic/edit.py#L66
[2]
https://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L370

Cheers
-- 
Michał (Saviq) Sawicz 


signature.asc
Description: This is a digitally signed message part


insert an inline to a ModelAdmin at runtime

2011-07-15 Thread Marc Aymerich
Hi,
I created a method that generates an InlineFormset at runtime and inserts it
to a given ModelAdmin.

It works perfectly when I call my method directly on admin.py
#admin.py
admin.site.register(MyModel, MyModelAdmin)
insert_generic_plugin_inlines(MyOtherModelAdmin)

but it doesn't work when this method is called for example on a post_save
signal. Actually, in this scenario, the Inlineformset is created and
inserted to MyOtherModelAdmin.inlines, but admin interface never show it.

This is how my method performs the inline insert:
admin.site.unregister(model)
ix = len(model_admin.inlines)
model_admin.inlines.insert(ix+1, inline)
admin.site.register(model, model_admin)

Why the admin interface displays the inline formset when the method is
called during an admin.py import but not when it's called later? Any idea?
Thanks!
-- 
Marc

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



Re: Django: forms and custom templates

2011-07-15 Thread samuele.mattiuzzo
Actually, i figured it out.
Nope, what i wanted to achieve is just to have django forms spawn my
custom html instead of the default one.

I just have to subclass the main class (ex CheckboxSelectMultiple) and
override the render method,
then in my custom form, i add formfield_override

On 15 Lug, 09:56, "Szabo, Patrick \(LNG-VIE\)"
 wrote:
> I'm not sure if i understood your problem a 100 percent so i'll just write 
> what i think you want ^^
>
> From what i understand i think you can use the code that has already been 
> written. Of course you might want to edit it a little bit for it to comply 
> with the other templates.
>
> If you want to work with the data from the forms, you'll have to pass the 
> forms data (whatever is inputet or selected) to a view (per urls.py) and then 
> do what you need to do with the data there.
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> Patrick Szabo
>  XSLT Developer
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> mailto:patrick.sz...@lexisnexis.at
> Tel.: 00431 534521573
> Fax: +43 (1) 534 52 - 146
>
> -Ursprüngliche Nachricht-
>
> Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
> Auftrag von samuele.mattiuzzo
> Gesendet: Freitag, 15. Juli 2011 09:43
> An: Django users
> Betreff: Django: forms and custom templates
>
> basic problem: i need to create real customized templates for my
> django forms. That's it. I'm used to style the forms based on django's
> output. This time is different, the html/css template is already done
> (months before i was hired) and i cannot modify it, so i need django
> to output exactly that html code.
>
> I've read a lot throu django docs, and i found a lot, but i have to
> admit, i couldn't put bits and pieces togheter, with order, to do what
> i need to do.
>
> Now, with CheckboxSelectMultiple the html output is this:
>
>     
>        
>        ...
>     
>
> What i actually need to do is create something like
> CustomCheckboxSelectMultiple to output exactly this template:
>
>     
>          id="..." />...
>     ...
>     
>
> And so on for other types of form widgets. It's the only way i can
> think of to create my forms with that particular layout they gave me.
>
> I'm actually stuck on this, i cannot seem to be able to put everything
> togheter to start coding my forms.
> How can i manage this? If you have any example too, it will be great!
> Otherwise, just point me towards the right direction please... sadly,
> looking in the docs, as i said before, didn't actually help me
>
> Thanks all 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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django: forms and custom templates

2011-07-15 Thread samuele.mattiuzzo
I figured out i have to override the default form classes of django

i have to create a
CustomCheckboxSelectMultiple(CheckboxSelectMultiple) class and
override the "render" method, making it generate the html i want for
my particular cases

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



Re: getting django working with apache and mod_wsgi on a brand new mac with xcode 4

2011-07-15 Thread Cal Leeming [Simplicity Media Ltd]
I'm sorry but I don't understand your question.

Which resources are you saying are out of date??

Cal

On Thu, Jul 14, 2011 at 11:22 PM, Derick Felsman <
derick.fels...@cbsinteractive.com> wrote:

> Hi,
>
> I'm brand new to django and have been having trouble setting it up
> with apache and mod_wsgi on my new mac with xcode 4 installed.  All
> the resources i've been able to find are either outdated or don't work
> with an xcode 4 installation.  Does anyone know how to do this or know
> where i would be able to get training to do this?  Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread bruno desthuilliers
On Jul 15, 10:13 am, Suprnaturall  wrote:
> Hi dear django users :)
>
> I m facing a stupid problem.
> Here is my models.py :
>
> class Video(models.Model):
>     (...)
>     category = models.ForeignKey('Category')
>    (...)
>
> class Category(models.Model):
>     name = models.CharField(max_length=250)
>
> I'm trying in a tags to make a group by on the category field and
> retrieve in the template the name of the first vid and its category
> name.
>
> Here it s my teamplate.py :
>
> @register.inclusion_tag('appFront/home_tag.html')
> def home_vods():
>         videos =
> Video.objects.values('category').annotate(dcount=Count('category'))
>         return {'videos': videos}


Queryset.values(*fieldnames) returns a list of fieldname:value dicts
(instead of model instances), possibly restricted to specified
fieldnames.

https://docs.djangoproject.com/en/1.3/ref/models/querysets/#values



> Do you have any clue ? What is the correct way to make a group by and
> then retrieve all the data in the table ?

I don't see the point of a group_by here. Would you care to explain
more exactly what you are trying to achieve (I mean, the desired
output - not what you think is the solution).


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



Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread nicolas HERSOG
Of course, and thanks for your help :)

This is the rows of my first table Video :
id | name | category_id | date
1 | vids1 | 1 | dd-jj-
2 | vids2 | 1 | dd-jj-
3 | vids3 | 1 | dd-jj-
4 | vids4 | 2 | dd-jj-
5 | vids5 | 2 | dd-jj-
6 | vids6 | 3 | dd-jj-

and here the rows of the category table :
id | name
1 | SF
2 | drama
3 | news

I want to retrieve the latest vod by categories, so that s why i thought
about the group_by category. So with a group_by i should retrieve :
1 | vids1 | 1
4 | vids4 | 2
6 | vids6 | 3
Am i wrong ?

On Fri, Jul 15, 2011 at 2:43 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On Jul 15, 10:13 am, Suprnaturall  wrote:
> > Hi dear django users :)
> >
> > I m facing a stupid problem.
> > Here is my models.py :
> >
> > class Video(models.Model):
> > (...)
> > category = models.ForeignKey('Category')
> >(...)
> >
> > class Category(models.Model):
> > name = models.CharField(max_length=250)
> >
> > I'm trying in a tags to make a group by on the category field and
> > retrieve in the template the name of the first vid and its category
> > name.
> >
> > Here it s my teamplate.py :
> >
> > @register.inclusion_tag('appFront/home_tag.html')
> > def home_vods():
> > videos =
> > Video.objects.values('category').annotate(dcount=Count('category'))
> > return {'videos': videos}
>
>
> Queryset.values(*fieldnames) returns a list of fieldname:value dicts
> (instead of model instances), possibly restricted to specified
> fieldnames.
>
> https://docs.djangoproject.com/en/1.3/ref/models/querysets/#values
>
>
>
> > Do you have any clue ? What is the correct way to make a group by and
> > then retrieve all the data in the table ?
>
> I don't see the point of a group_by here. Would you care to explain
> more exactly what you are trying to achieve (I mean, the desired
> output - not what you think is the solution).
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Andre Terra
Paul,

Your form logic will go on your Form (or ModelForm) definition, not on the
view. As the docs [1] say, CreateView is a combination of ModelFormMixin and
ProcessFormView. Please read the docs on those two mixins to understand what
methods your CampaignCreate class can override, but do move the form logic
(i.e. field excluding, validation, etc) to a custom form.

Try something like (the following code hasn't been tested):

# views.py
class CampaignCreate(CreateView):
template_name = "forms/create.html"
form_class = CampaignForm


# forms.py
class CampaingForm(forms.ModelForm)
class Meta:
model = Campaign
exclude = ('user', 'name', 'content_inlined')


Hope that helps!


Cheers,
André


[1]
https://docs.djangoproject.com/en/dev/ref/class-based-views/#django.views.generic.edit.CreateView



On Fri, Jul 15, 2011 at 6:18 AM, Paul Walsh  wrote:

> I am pretty new to Django - new enough to be developing my first Django app
> on 1.3. So, I am basing all my work on class-based generic views, and have
> never used the older generic view functions.
>
> A problem I have is the lack of examples and documentation on the new
> class-based generic views.
>
> My current problem is that I am trying to build some forms based on models.
> I am not using Django Forms (ModelForm), but rather CreateView. CreateView
> gets me almost there, but I can't find any documentation on (1) how to
> exclude fields, and (2) how to fix a value for a field.
>
> My class is like so:
>
> class CreateCampaignView(CreateView):
> model = Campaign
> template_name = "forms/create.html"
>
> I tried exclude from ModelForms, like this:
>
> class CreateCampaignView(UserAccountCreateView):
> model = Campaign
>  template_name = "forms/create.html"
> exclude = ('user', 'name', 'content_inlined')
>
> and that doesn't work. Is there another way to exclude fields using
> CreateView?
>
> and, one of my excluded fields, "user", also needs to get the value of
> self.request.user
>
> I tried again here to apply the docs from ModelForms here for CreateView,
> but it doesn't work.
>
>
> Some might suggest I use Django Forms - it is a reasonable suggestion of
> course. But, being new, I don't have any "view legacy" and I just like the
> idea of working with class-based generic views where possible.
>
> thanks.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/g4ADYoJAbE0J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Andre Terra
On Fri, Jul 15, 2011 at 7:37 AM, Kenneth Gonsalves
wrote:

>
> caveat - I have never used generic views, class based or otherwise, but
> I was under the impression that if one wants customised forms or views,
> generic is not the way to go.
>
>
These views are classes and they exist precisely so that the code can stay
DRY through specific classes (e.g. MyModelCreateView) that subclass more
generic classes (e.g. MyBaseCreateView) all the way up to the tools django
provides (e.g. CreateView).


Cheers,
André

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



Re: insert an inline to a ModelAdmin at runtime

2011-07-15 Thread Marc Aymerich
On Fri, Jul 15, 2011 at 1:35 PM, Marc Aymerich  wrote:

> Hi,
> I created a method that generates an InlineFormset at runtime and inserts
> it to a given ModelAdmin.
>
> It works perfectly when I call my method directly on admin.py
> #admin.py
> admin.site.register(MyModel, MyModelAdmin)
> insert_generic_plugin_inlines(MyOtherModelAdmin)
>
> but it doesn't work when this method is called for example on a post_save
> signal. Actually, in this scenario, the Inlineformset is created and
> inserted to MyOtherModelAdmin.inlines, but admin interface never show it.
>
> This is how my method performs the inline insert:
> admin.site.unregister(model)
> ix = len(model_admin.inlines)
> model_admin.inlines.insert(ix+1, inline)
> admin.site.register(model, model_admin)
>
> Why the admin interface displays the inline formset when the method is
> called during an admin.py import but not when it's called later? Any idea?
>


I think it's something related to that admin.site.unregister(model)
and admin.site.register(model, model_admin) doesn't truly swap the
ModelAdmin site, because I get two different MyModelAdmin objects if I query
the admin.site._registry[model] compared to print "self" on the
ModelAdmin.add_view()

# on my method
print admin.site._registry[model]


#on ModelAdmin.add_view()
print self


what I have to do to truly change the modeladmin at runtime ?

-- 
Marc

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



FTP prefic in URL field

2011-07-15 Thread ggavy

Hi all,
I'm using a URLField in a model and form. However the form
validation for this does not accept 'ftp://' type prefixes. What are
my options here? Do I need to write a custom field or is it possible
to modify the 'validate' method on the field itself so that it
includes the default URL requirements and the ftp prefix. My limited
knowledge in this stuff tells me that this latter one is not possible?
Any advice?

Thanks

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



Re: FTP prefic in URL field

2011-07-15 Thread Tim Shaffer
It looks like the URLValidator should in fact accept ftp:

https://github.com/django/django/blob/master/django/core/validators.py#L46

What's the specific error you're getting?

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



Re: Django: forms and custom templates

2011-07-15 Thread Javier Guerra Giraldez
On Fri, Jul 15, 2011 at 6:41 AM, samuele.mattiuzzo  wrote:
> Nope, what i wanted to achieve is just to have django forms spawn my
> custom html instead of the default one.

note that you can simply not use the form rendering, simply use your
HTML (in a template, or even on a static page) and you can still use
the form object for parsing/validating the POSTed data.

-- 
Javier

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



Re: getting django working with apache and mod_wsgi on a brand new mac with xcode 4

2011-07-15 Thread Javier Guerra Giraldez
On Thu, Jul 14, 2011 at 5:22 PM, Derick Felsman
 wrote:
> Hi,
>
> I'm brand new to django and have been having trouble setting it up
> with apache and mod_wsgi on my new mac with xcode 4 installed.  All
> the resources i've been able to find are either outdated or don't work
> with an xcode 4 installation.  Does anyone know how to do this or know
> where i would be able to get training to do this?  Thanks.

what exactly has Xcode to do with Django/Apache/mod_wsgi?


-- 
Javier

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



Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread bruno desthuilliers
On Jul 15, 2:53 pm, nicolas HERSOG  wrote:
> Of course, and thanks for your help :)
>
> This is the rows of my first table Video :
> id | name | category_id | date
> 1 | vids1 | 1 | dd-jj-
> 2 | vids2 | 1 | dd-jj-
> 3 | vids3 | 1 | dd-jj-
> 4 | vids4 | 2 | dd-jj-
> 5 | vids5 | 2 | dd-jj-
> 6 | vids6 | 3 | dd-jj-
>
> and here the rows of the category table :
> id | name
> 1 | SF
> 2 | drama
> 3 | news
>
> I want to retrieve the latest vod by categories, so that s why i thought
> about the group_by category. So with a group_by i should retrieve :
> 1 | vids1 | 1
> 4 | vids4 | 2
> 6 | vids6 | 3
> Am i wrong ?
>

Err... Actually, yes you are.

It might *seems* to work if the "latest" (assuming 'by date') video
for each category happens to be the one with the lowest id (which FWIW
is highly unlikely for very obvious reasons), ie:

mysql> select * from video;
++---++-+
| id | name  | date_added | category_id |
++---++-+
|  1 | vids1 | 2011-07-15 |   1 |
|  2 | vids2 | 2011-07-14 |   1 |
|  3 | vids3 | 2011-07-13 |   1 |
|  4 | vids4 | 2011-07-15 |   2 |
|  5 | vids5 | 2011-07-14 |   2 |
|  6 | vids6 | 2011-07-15 |   3 |
++---++-+

mysql> select * from video group by category_id;
++---++-+
| id | name  | date_added | category_id |
++---++-+
|  1 | vids1 | 2011-07-15 |   1 |
|  4 | vids4 | 2011-07-15 |   2 |
|  6 | vids6 | 2011-07-15 |   3 |
++---++-+

But as soon as you add a "new" video it will break:

mysql> insert into video(name, category_id, date_added)
values("vids7", 1, "2011-07-16");
Query OK, 1 row affected (0.00 sec)

mysql> select * from video group by category_id;
++---++-+
| id | name  | date_added | category_id |
++---++-+
|  1 | vids1 | 2011-07-15 |   1 |
|  4 | vids4 | 2011-07-15 |   2 |
|  6 | vids6 | 2011-07-15 |   3 |
++---++-+

=> expected "vids7" to be the "latest" for category_id 1

What you want (getting the "latest/highest/whatever by some other
value") in "one" query requires something a bit more involved -
usually a corelated subquery, ie:

mysql> select v1.* from video v1 where v1.date_added = (select
max(date_added) from video v2 where v2.category_id=v1.category_id);
++---++-+
| id | name  | date_added | category_id |
++---++-+
|  4 | vids4 | 2011-07-15 |   2 |
|  6 | vids6 | 2011-07-15 |   3 |
|  7 | vids7 | 2011-07-16 |   1 |
++---++-+
3 rows in set (0.00 sec)


Such a query can be a bit tricky to express using Django's ORM (which
is meant to help with the most common queries, not to replace SQL),
and FWIW subqueries can be somewhat inefficient, depending on your SQL
backend, indexes, dataset and whatnot.

To make a long story short: unless you have a lot of categories (which
is, once again, very unlikely in this context), you could just start
with a simpler approach, like

categories =  Category.objects.order_by("-video__date_added")
videos = []
for category in categories:
try:
 
videos.append(category.video_set.latest("date_added").select_related('Category))
except Video.DoesNotExist:
# no video for this category
pass
return dict(videos=videos)

It's clearly suboptimal, but it's simple and should just work, and
with this code encapsulated in your templatetag (or as a function or
method in your models, then called from your templatetag), you can
safely try and optimize this later if and when it becomes a bottleneck
(or if and when you find time to try and benchmark various
implementations to find out which is the fastest for your backend and
dataset).

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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: FTP prefic in URL field

2011-07-15 Thread ggavy

Hi Tim,
I'm getting the 'Enter a valid URL.' error returned. I am however
using Django 1.1, and thought that was the issue (I'm not sure where
to look for the validator.py in this older version, but I think Iread
somewhere that ftp wasn't in the regex at that version). Migrating to
1.2 isn't practical at the moment.

G


On Jul 15, 2:52 pm, Tim Shaffer  wrote:
> It looks like the URLValidator should in fact accept ftp:
>
> https://github.com/django/django/blob/master/django/core/validators.p...
>
> What's the specific error you're getting?

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



Re: FTP prefic in URL field

2011-07-15 Thread Tim Shaffer
Yeah, it doesn't look like 1.1 allowed for ftp protocol:

https://github.com/django/django/blob/1.1.X/django/forms/fields.py#L545

Best bet might be to create your own URLField class and overwrite the 
__init__ method to use your own regular expression. Kind of a pain. It's a 
little easier in future versions because you can just overwrite the 
validator instead of the whole field.

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



Re: getting django working with apache and mod_wsgi on a brand new mac with xcode 4

2011-07-15 Thread i...@webbricks.co.uk
you need xcode to compile stuff like PIL, which most django projects
need.

then im stuck, for me the dev server is good enough for development on
a mac.

OP, why not use the dev server and leave apache where its best, in
production on a linux server. (IMO?)

On Jul 15, 2:54 pm, Javier Guerra Giraldez  wrote:
> On Thu, Jul 14, 2011 at 5:22 PM, Derick Felsman
>
>  wrote:
> > Hi,
>
> > I'm brand new to django and have been having trouble setting it up
> > with apache and mod_wsgi on my new mac with xcode 4 installed.  All
> > the resources i've been able to find are either outdated or don't work
> > with an xcode 4 installation.  Does anyone know how to do this or know
> > where i would be able to get training to do this?  Thanks.
>
> what exactly has Xcode to do with Django/Apache/mod_wsgi?
>
> --
> Javier

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



How to configure pgAdminIII

2011-07-15 Thread How to configure pgAdminIII
Hi Django users,

I recently installed Django, but yet to know how to configure the
pgAdminIII probably which supports DB for Django apps.
http://postimage.org/image/13ynpagx0/

This the link which shows I'm stuck with. Can anyone guide me what I
should do with the form. And anyone tell me how to use it or Works
with Django if it is postgresql which I was looking for.


Thanks and regards
Rohit

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



Re: How to configure pgAdminIII

2011-07-15 Thread Bill Freeman
The information that you need to fill in this form is the same
information that you used to
configure the DB connection in setings.py.  The "name" is arbitrary,
something you can
use to identify which DB you want to administer when pgAdmin knows
about several.
5432 is the default PostgreSQL port, unless you've configured
something else (which
would then also have had to be sepcified in settings).  And if you try
it and it doesn't
work, pgAdmin will let you try again.

On Fri, Jul 15, 2011 at 11:22 AM, How to configure pgAdminIII
 wrote:
> Hi Django users,
>
> I recently installed Django, but yet to know how to configure the
> pgAdminIII probably which supports DB for Django apps.
> http://postimage.org/image/13ynpagx0/
>
> This the link which shows I'm stuck with. Can anyone guide me what I
> should do with the form. And anyone tell me how to use it or Works
> with Django if it is postgresql which I was looking for.
>
>
> Thanks and regards
> Rohit
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: getting django working with apache and mod_wsgi on a brand new mac with xcode 4

2011-07-15 Thread Derick Felsman
Well i can install apache and django just fine, but if I download the
wsgi source and use the make command on the makefile generated from
the configure script i ended up getting an error.  upon some research
i discovered that xcode 4 removed support for the ppc architecture so
you have to manually edit the makefile.  after that it will install
just fine.

So now that i have everything installed i can start apache just fine
but i seem to be having trouble getting django to talk to apache and
vice versa.  any advice on that part?

On Jul 15, 6:54 am, Javier Guerra Giraldez  wrote:
> On Thu, Jul 14, 2011 at 5:22 PM, Derick Felsman
>
>  wrote:
> > Hi,
>
> > I'm brand new to django and have been having trouble setting it up
> > with apache and mod_wsgi on my new mac with xcode 4 installed.  All
> > the resources i've been able to find are either outdated or don't work
> > with an xcode 4 installation.  Does anyone know how to do this or know
> > where i would be able to get training to do this?  Thanks.
>
> what exactly has Xcode to do with Django/Apache/mod_wsgi?
>
> --
> Javier

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



Re: getting django working with apache and mod_wsgi on a brand new mac with xcode 4

2011-07-15 Thread Daniel Roseman
On Friday, July 15, 2011 4:38:08 PM UTC+1, Derick Felsman wrote:
>
> Well i can install apache and django just fine, but if I download the 
> wsgi source and use the make command on the makefile generated from 
> the configure script i ended up getting an error.  upon some research 
> i discovered that xcode 4 removed support for the ppc architecture so 
> you have to manually edit the makefile.  after that it will install 
> just fine. 
>
> So now that i have everything installed i can start apache just fine 
> but i seem to be having trouble getting django to talk to apache and 
> vice versa.  any advice on that part? 
>

Why are you trying to do any of this when you're "brand new" to Django? Use 
the built-in development server first (runserver). When you've got some idea 
of how it all fits together, that's the time to start looking into Apache 
and WSGI.
--
DR.

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



Re: How to configure pgAdminIII

2011-07-15 Thread Simon Riggs
On Fri, Jul 15, 2011 at 4:22 PM, How to configure pgAdminIII
 wrote:

> I recently installed Django, but yet to know how to configure the
> pgAdminIII probably which supports DB for Django apps.
> http://postimage.org/image/13ynpagx0/
>
> This the link which shows I'm stuck with. Can anyone guide me what I
> should do with the form. And anyone tell me how to use it or Works
> with Django if it is postgresql which I was looking for.

That's standard PostgreSQL connection info. The defaults are all
filled in for you, so you just need to give the Server a name to
differentiate it easily in pgAdmin and then supply user/password
details for the database. Whoever installed the database server should
know that.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

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



auto_now, auto_now add -- good or bad?

2011-07-15 Thread Shawn Milochik
A discussion broke out in our office today about using these features,
because there are blog posts[1] bashing them and a comment by JKM
saying they should go away[2].

It seems that all of the arguments against are based on the fact that
there were bugs in the past (links in the comments of the blog post
above). However, the "go away" comment is five years old and they're
still there, and the bug tickets have been patched.

It's easy enough to do what these features do in a more explicit way.

Considering these facts, I'm wondering what the consensus is in the community:

A. They're still there because they're too annoying to deprecate
or just not important enough to spend time on.

B. They're useful shortcuts and their use is preferable to manual
replacements.


[1] http://www.b-list.org/weblog/2006/nov/02/django-tips-auto-populated-fields/
[2] https://code.djangoproject.com/ticket/1056

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



Re: auto_now, auto_now add -- good or bad?

2011-07-15 Thread Andre Terra
Shawn,


Chalk one up for option A.

I never, ever, ever, use them and they can get dropped for all I care,
considering how easy they are to implement "manually".

They are also my go-to example for teaching new users how to modify their
model's save method and I believe the shortcuts only add "magic" without
bringing in real benefits. One could even argue that their existence creates
an extra, unnecessary step in the learning curve for beginners. Bottom line,
it's more often a nuisance than it is a shortcut.


Cheers,
André



On Fri, Jul 15, 2011 at 1:22 PM, Shawn Milochik  wrote:

> A discussion broke out in our office today about using these features,
> because there are blog posts[1] bashing them and a comment by JKM
> saying they should go away[2].
>
> It seems that all of the arguments against are based on the fact that
> there were bugs in the past (links in the comments of the blog post
> above). However, the "go away" comment is five years old and they're
> still there, and the bug tickets have been patched.
>
> It's easy enough to do what these features do in a more explicit way.
>
> Considering these facts, I'm wondering what the consensus is in the
> community:
>
>A. They're still there because they're too annoying to deprecate
> or just not important enough to spend time on.
>
>B. They're useful shortcuts and their use is preferable to manual
> replacements.
>
>
> [1]
> http://www.b-list.org/weblog/2006/nov/02/django-tips-auto-populated-fields/
> [2] https://code.djangoproject.com/ticket/1056
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: auto_now, auto_now add -- good or bad?

2011-07-15 Thread John DeRosa
On Jul 15, 2011, at 9:22 AM, Shawn Milochik wrote:

> Considering these facts, I'm wondering what the consensus is in the community:
> 
>A. They're still there because they're too annoying to deprecate
> or just not important enough to spend time on.
> 
>B. They're useful shortcuts and their use is preferable to manual
> replacements.
> 
> 
> [1] 
> http://www.b-list.org/weblog/2006/nov/02/django-tips-auto-populated-fields/
> [2] https://code.djangoproject.com/ticket/1056
> 

I use them. So, B. I'm not crazy about their names, however.

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



Re: auto_now, auto_now add -- good or bad?

2011-07-15 Thread bruno desthuilliers
On 15 juil, 18:22, Shawn Milochik  wrote:
> A discussion broke out in our office today about using these features,
> because there are blog posts[1] bashing them and a comment by JKM
> saying they should go away[2].
>
> It seems that all of the arguments against are based on the fact that
> there were bugs in the past (links in the comments of the blog post
> above). However, the "go away" comment is five years old and they're
> still there, and the bug tickets have been patched.


Indeed.

> It's easy enough to do what these features do in a more explicit way.

Yeah, quite a lot of things are "easy to do in more explicit way" in
Python (if by explicit you mean low-level). Who needs a class
statement ? Just call type() with the relevant args, that's way more
explicit... ;)

> Considering these facts, I'm wondering what the consensus is in the community:
>
>     A. They're still there because they're too annoying to deprecate
> or just not important enough to spend time on.
>
>     B. They're useful shortcuts and their use is preferable to manual
> replacements.

As far as I'm concerned, a named argument in a field definition  is
"more explicit" than some ad-hoc code in a model's save method.

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



Re: auto_now, auto_now add -- good or bad?

2011-07-15 Thread Bill Freeman
On Fri, Jul 15, 2011 at 12:44 PM, Andre Terra  wrote:
> Shawn,
>
>
> Chalk one up for option A.
>
> I never, ever, ever, use them and they can get dropped for all I care,
> considering how easy they are to implement "manually".
>
> They are also my go-to example for teaching new users how to modify their
> model's save method and I believe the shortcuts only add "magic" without
> bringing in real benefits. One could even argue that their existence creates
> an extra, unnecessary step in the learning curve for beginners. Bottom line,
> it's more often a nuisance than it is a shortcut.
>
>
> Cheers,
> André

I'll give a weak vote for C: They can be, and presumabley have been, made to
work correctly, in a peer reviewed setting, by folks with significant
experience,
so having the less experienced noob implement his own is a little like saying
that you should implement your own encryption scheme instead of using an
available implementation - you have a good chance at getting it wrong.

Bugs happen, and they get noticed and fixed.  The prior existence of a bug is
not a good justification to avoid the feature, it's a justification
for the effort of
staying up to date on patches.

Bill

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



Re: auto_now, auto_now add -- good or bad?

2011-07-15 Thread Andre Terra
> I'll give a weak vote for C: They can be, and presumabley have been, made
> to
> work correctly, in a peer reviewed setting, by folks with significant
> experience,
> so having the less experienced noob implement his own is a little like
> saying
> that you should implement your own encryption scheme instead of using an
> available implementation - you have a good chance at getting it wrong.
>

That analogy is quite a stretch. There's an enormous difference between
implementing an encryption scheme and writing 4 lines of python code.

Besides, getting a save() override wrong is probably a *good* thing for a
newcomer.



Cheers,
André

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



custom method in models.py

2011-07-15 Thread Suprnaturall
Hi,

I'm wondering if like in play or symfony you can develop special
method for each class/table in the models.py and use them in your
template.
I'm trying few things but it didn't work.

For exemple this is my models.py :
class Category(models.Model):
name = models.CharField(max_length=250)

def get_short_name():
return name[0,20]

And here my html :
Desc : {{ category.get_short_name }} 

But it don t work, i'v got nothing in the screen.

What the correct way to do stuff like this, i m supposed to make a
custom tag in order to truncuate the name field ?

Thx

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



Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread nicolas HERSOG
Oh sorry, I knew that my sql query was naive, but my question was really
about how to use group by and retrieve data throug my template :/

I'm really sorry for waste your time with stupid sql.

Nevertheless a great thank you for your help.
I'm going to do like you say and in few times, try to change this with a sql
view which is safer (but i heard it's hard to use sql view in the django
ORM)

Thank for your help Bruno :)


On Fri, Jul 15, 2011 at 3:57 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On Jul 15, 2:53 pm, nicolas HERSOG  wrote:
> > Of course, and thanks for your help :)
> >
> > This is the rows of my first table Video :
> > id | name | category_id | date
> > 1 | vids1 | 1 | dd-jj-
> > 2 | vids2 | 1 | dd-jj-
> > 3 | vids3 | 1 | dd-jj-
> > 4 | vids4 | 2 | dd-jj-
> > 5 | vids5 | 2 | dd-jj-
> > 6 | vids6 | 3 | dd-jj-
> >
> > and here the rows of the category table :
> > id | name
> > 1 | SF
> > 2 | drama
> > 3 | news
> >
> > I want to retrieve the latest vod by categories, so that s why i thought
> > about the group_by category. So with a group_by i should retrieve :
> > 1 | vids1 | 1
> > 4 | vids4 | 2
> > 6 | vids6 | 3
> > Am i wrong ?
> >
>
> Err... Actually, yes you are.
>
> It might *seems* to work if the "latest" (assuming 'by date') video
> for each category happens to be the one with the lowest id (which FWIW
> is highly unlikely for very obvious reasons), ie:
>
> mysql> select * from video;
> ++---++-+
> | id | name  | date_added | category_id |
> ++---++-+
> |  1 | vids1 | 2011-07-15 |   1 |
> |  2 | vids2 | 2011-07-14 |   1 |
> |  3 | vids3 | 2011-07-13 |   1 |
> |  4 | vids4 | 2011-07-15 |   2 |
> |  5 | vids5 | 2011-07-14 |   2 |
> |  6 | vids6 | 2011-07-15 |   3 |
> ++---++-+
>
> mysql> select * from video group by category_id;
> ++---++-+
> | id | name  | date_added | category_id |
> ++---++-+
> |  1 | vids1 | 2011-07-15 |   1 |
> |  4 | vids4 | 2011-07-15 |   2 |
> |  6 | vids6 | 2011-07-15 |   3 |
> ++---++-+
>
> But as soon as you add a "new" video it will break:
>
> mysql> insert into video(name, category_id, date_added)
> values("vids7", 1, "2011-07-16");
> Query OK, 1 row affected (0.00 sec)
>
> mysql> select * from video group by category_id;
> ++---++-+
> | id | name  | date_added | category_id |
> ++---++-+
> |  1 | vids1 | 2011-07-15 |   1 |
> |  4 | vids4 | 2011-07-15 |   2 |
> |  6 | vids6 | 2011-07-15 |   3 |
> ++---++-+
>
> => expected "vids7" to be the "latest" for category_id 1
>
> What you want (getting the "latest/highest/whatever by some other
> value") in "one" query requires something a bit more involved -
> usually a corelated subquery, ie:
>
> mysql> select v1.* from video v1 where v1.date_added = (select
> max(date_added) from video v2 where v2.category_id=v1.category_id);
> ++---++-+
> | id | name  | date_added | category_id |
> ++---++-+
> |  4 | vids4 | 2011-07-15 |   2 |
> |  6 | vids6 | 2011-07-15 |   3 |
> |  7 | vids7 | 2011-07-16 |   1 |
> ++---++-+
> 3 rows in set (0.00 sec)
>
>
> Such a query can be a bit tricky to express using Django's ORM (which
> is meant to help with the most common queries, not to replace SQL),
> and FWIW subqueries can be somewhat inefficient, depending on your SQL
> backend, indexes, dataset and whatnot.
>
> To make a long story short: unless you have a lot of categories (which
> is, once again, very unlikely in this context), you could just start
> with a simpler approach, like
>
> categories =  Category.objects.order_by("-video__date_added")
> videos = []
> for category in categories:
>try:
>
>
> videos.append(category.video_set.latest("date_added").select_related('Category))
>except Video.DoesNotExist:
># no video for this category
>pass
> return dict(videos=videos)
>
> It's clearly suboptimal, but it's simple and should just work, and
> with this code encapsulated in your templatetag (or as a function or
> method in your models, then called from your templatetag), you can
> safely try and optimize this later if and when it becomes a bottleneck
> (or if and when you find time to try and benchmark various
> implementations to find out which is the fastest for your backend and
> dataset).
>
> 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
> django-users+unsubscr...@googlegroups.com.
> 

filter cache output

2011-07-15 Thread Rob
I have setup caching with memcached for my site. This works well
except from this part of my view. My idea was to store all menu items
in the cache, and apply a filter later on to decide if they belong to
the left or top menu.


menu = cache.get(menu_cache_key)
if menu:
menu_left = menu.filter(menu_left = True)
menu_top = menu.filter(menu_top = True)

I thought that apply the .filter() on the menu would not cause a query
on the database, but it does. So the menu is retrieved from the cache,
and after that the menu items are retrieved from the database (which
makes the caching useless). I found out about this because changes in
the menu are applied immediately on the webpage.

Is this normal behaviour, and should I make multiple entries into the
cache for the left- and topmenu, or is there a way to get this
working?

Rob

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



Re: filter cache output

2011-07-15 Thread Nan

Querysets are evaluated lazily.[1][2]  You may have better success
using template fragment caching[3] to cache the menu output.

[1] https://docs.djangoproject.com/en/dev/topics/db/queries/#querysets-are-lazy
[3] 
https://docs.djangoproject.com/en/dev/ref/models/querysets/#when-querysets-are-evaluated
[3] 
https://docs.djangoproject.com/en/dev/topics/cache/?from=olddocs#template-fragment-caching


On Jul 15, 2:26 pm, Rob  wrote:
> I have setup caching with memcached for my site. This works well
> except from this part of my view. My idea was to store all menu items
> in the cache, and apply a filter later on to decide if they belong to
> the left or top menu.
>
>         menu = cache.get(menu_cache_key)
>         if menu:
>                 menu_left = menu.filter(menu_left = True)
>                 menu_top = menu.filter(menu_top = True)
>
> I thought that apply the .filter() on the menu would not cause a query
> on the database, but it does. So the menu is retrieved from the cache,
> and after that the menu items are retrieved from the database (which
> makes the caching useless). I found out about this because changes in
> the menu are applied immediately on the webpage.
>
> Is this normal behaviour, and should I make multiple entries into the
> cache for the left- and topmenu, or is there a way to get this
> working?
>
> Rob

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



Re: Add attributes (css-class) to formfield

2011-07-15 Thread Andreas Pfrengle
Tom,

it's really so easy, thank you!
Seems now I've learned the hard way how forms and fields are
working ;-)

Andreas

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



Re: filter cache output

2011-07-15 Thread Rob
On Jul 15, 8:34 pm, Nan  wrote:
> Querysets are evaluated lazily.[1][2]  You may have better success
> using template fragment caching[3] to cache the menu output.
>

Thanks for the reply.

I read the part about the "lazy" querysets and therefore I suspected
the database not to be hit. This also doesn't count for querysets from
a cache. Perhaps I should turn of caching for the menu (are only a few
items)

Unfortunately template caching is no option for me, because the menu
items depend on a session.

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



Re: custom method in models.py

2011-07-15 Thread Shawn Milochik

On 07/15/2011 02:14 PM, Suprnaturall wrote:

  def get_short_name():
return name[0,20]


Try this:
def get_short_name(self):

return self.name[0:20]



You need 'self' in two places, and I assume you want a string of the 
first 20 characters rather than a list of the first and 21st.



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



Re: filter cache output

2011-07-15 Thread Nan

Well, you can use one of the methods from [2] to force the queryset to
evaluate before caching it.  But you'll still run a new query in order
to filter, unless you aftually filter the data in your Python code.

On Jul 15, 2:46 pm, Rob  wrote:
> On Jul 15, 8:34 pm, Nan  wrote:
>
> > Querysets are evaluated lazily.[1][2]  You may have better success
> > using template fragment caching[3] to cache the menu output.
>
> Thanks for the reply.
>
> I read the part about the "lazy" querysets and therefore I suspected
> the database not to be hit. This also doesn't count for querysets from
> a cache. Perhaps I should turn of caching for the menu (are only a few
> items)
>
> Unfortunately template caching is no option for me, because the menu
> items depend on a session.

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



Re: custom method in models.py

2011-07-15 Thread nicolas HERSOG
Oh crap i m feel ashame...

Thanx for your help !

On Fri, Jul 15, 2011 at 8:46 PM, Shawn Milochik  wrote:

> On 07/15/2011 02:14 PM, Suprnaturall wrote:
>
>>  def get_short_name():
>>return name[0,20]
>>
>
> Try this:
> def get_short_name(self):
>
>return self.name[0:20]
>
>
>
> You need 'self' in two places, and I assume you want a string of the first
> 20 characters rather than a list of the first and 21st.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>

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



Setting up Django with fastCGI on centos with apache

2011-07-15 Thread Rick Beacham
I'm having alot of trouble with setting up django with fastCGI. I was
able to use the default test server made with django no problem.  But
I'm having trouble setting it up with httpd and fastCGI in scientific
linux(centos)..   Here is the error message after running this
command  ./manage.py runfcgi daemonize=false host=127.0.0.1
port=8000  .





Traceback (most recent call last):
  File "./manage.py", line 14, in 
execute_manager(settings)
  File "/opt/python2.7/lib/python2.7/site-packages/django/core/
management/__init__.py", line 438, in execute_manager
utility.execute()
  File "/opt/python2.7/lib/python2.7/site-packages/django/core/
management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/python2.7/lib/python2.7/site-packages/django/core/
management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/opt/python2.7/lib/python2.7/site-packages/django/core/
management/base.py", line 220, in execute
output = self.handle(*args, **options)
  File "/opt/python2.7/lib/python2.7/site-packages/django/core/
management/commands/runfcgi.py", line 16, in handle
runfastcgi(args)
  File "/opt/python2.7/lib/python2.7/site-packages/django/core/servers/
fastcgi.py", line 180, in runfastcgi
WSGIServer(WSGIHandler(), **wsgi_opts).run()
  File "build/bdist.linux-x86_64/egg/flup/server/fcgi_fork.py", line
131, in run
  File "build/bdist.linux-x86_64/egg/flup/server/fcgi_base.py", line
1018, in _setupSocket
  File "/opt/python2.7/lib/python2.7/socket.py", line 222, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use

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



Re: Setting up Django with fastCGI on centos with apache

2011-07-15 Thread ionic drive
Hello Rick,

Address already in use, tells you that on 127.0.0.1 specific port 8000
already a process is running. I guess you have your Apache already
running their, right!?

you have to listen with your Apache to the proper port where fastcgi is
serving the data for Apache. I think you have to re-read the tutorial
you are working on.

Good luck!
Ionic
Electronics Platform
http://develissimo.com


On Fri, 2011-07-15 at 12:06 -0700, Rick Beacham wrote:
> I'm having alot of trouble with setting up django with fastCGI. I was
> able to use the default test server made with django no problem.  But
> I'm having trouble setting it up with httpd and fastCGI in scientific
> linux(centos)..   Here is the error message after running this
> command  ./manage.py runfcgi daemonize=false host=127.0.0.1
> port=8000  .
> 
> 
> 
> 
> 
> Traceback (most recent call last):
>   File "./manage.py", line 14, in 
> execute_manager(settings)
>   File "/opt/python2.7/lib/python2.7/site-packages/django/core/
> management/__init__.py", line 438, in execute_manager
> utility.execute()
>   File "/opt/python2.7/lib/python2.7/site-packages/django/core/
> management/__init__.py", line 379, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/opt/python2.7/lib/python2.7/site-packages/django/core/
> management/base.py", line 191, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "/opt/python2.7/lib/python2.7/site-packages/django/core/
> management/base.py", line 220, in execute
> output = self.handle(*args, **options)
>   File "/opt/python2.7/lib/python2.7/site-packages/django/core/
> management/commands/runfcgi.py", line 16, in handle
> runfastcgi(args)
>   File "/opt/python2.7/lib/python2.7/site-packages/django/core/servers/
> fastcgi.py", line 180, in runfastcgi
> WSGIServer(WSGIHandler(), **wsgi_opts).run()
>   File "build/bdist.linux-x86_64/egg/flup/server/fcgi_fork.py", line
> 131, in run
>   File "build/bdist.linux-x86_64/egg/flup/server/fcgi_base.py", line
> 1018, in _setupSocket
>   File "/opt/python2.7/lib/python2.7/socket.py", line 222, in meth
> return getattr(self._sock,name)(*args)
> socket.error: [Errno 98] Address already in use
> 


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



installing django

2011-07-15 Thread Charles
I have a windows account on Hostgator.com and would like to install and 
django. Hostagator is a little lacking in documentations, so does anyone 
have any idea of how to get things going?


Charles

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



Re: filter cache output

2011-07-15 Thread Rob
On Jul 15, 8:57 pm, Nan  wrote:
> Well, you can use one of the methods from [2] to force the queryset to
> evaluate before caching it.  But you'll still run a new query in order
> to filter, unless you aftually filter the data in your Python code.

Very clear, thanks!

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



Re: installing django

2011-07-15 Thread Andre Terra
Do you have a strong reason for running windows on your host?
Developing/deploying django on linux is about a billion times easier.


Cheers,
André

On Fri, Jul 15, 2011 at 5:35 PM, Charles  wrote:

> I have a windows account on Hostgator.com and would like to install and
> django. Hostagator is a little lacking in documentations, so does anyone
> have any idea of how to get things going?
>
> Charles
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>

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



Re: custom method in models.py

2011-07-15 Thread bruno desthuilliers
On 15 juil, 20:14, Suprnaturall  wrote:
> Hi,
>
> I'm wondering if like in play or symfony you can develop special
> method for each class/table in the models.py and use them in your
> template.

Of course. A model is "just" a Python class (well, with some "magic"
but...).

> I'm trying few things but it didn't work.
>
> For exemple this is my models.py :
> class Category(models.Model):
>     name = models.CharField(max_length=250)
>
>     def get_short_name():
>                 return name[0,20]
>
> And here my html :
> Desc : {{ category.get_short_name }} 
>
> But it don t work, i'v got nothing in the screen.

Set DEBUG and DEBUG_TEMPLATE to True in your settings.py. You should
get a nice traceback.

>
> What the correct way to do stuff like this, i m supposed to make a
> custom tag in order to truncuate the name field ?

Of course not. But you'd better take some time learning Python if you
hope to do anything with Django.

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



Re: installing django

2011-07-15 Thread Javier Guerra Giraldez
On Fri, Jul 15, 2011 at 3:40 PM, Andre Terra  wrote:
> Do you have a strong reason for running windows on your host?
> Developing/deploying django on linux is about a billion times easier.

could be wrong; but i think the hard part is not because of the OS,
but because of IIS, which doesn't support any standard webapp
protocol.

if you use another webserver, things should be almost as easy as on
*nix, except for being somewhat more limited (no nginx, no uWSGI), but
i think at least Apache and FastCGI or mod_wsgi work as intended

-- 
Javier

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



django.core.urlresolvers.reverse capturing group before include behavior

2011-07-15 Thread Squeesh
I have run into an issue using reverse() to lookup named urls with
capturing groups before an include().

Code:

mysite/urls.py
from django.conf.urls.defaults import *

urlpatterns = patterns('',
url(r'^$',  'views.index',
name='root'),
url(r'^(?P\w+)/test/',   include('test.urls',
namespace='test')),
)
end mysite/urls.py


mysite/test/urls.py
from django.conf.urls.defaults import *

urlpatterns = patterns('',
url(r'^$',  'test.views.index',
name='index'),
)
end mysite/test/urls.py


mysite/views.py
from django.core.urlresolvers import reverse
from django.http import HttpResponse

def index(request):
# Works: returns '/(?P\w+)/test/'
test_url = reverse('test:index')

# NoReverseMatch: Reverse for 'index' with arguments '('slug',)'
#and keyword arguments '{}' not found.
test_url = reverse('test:index', args=['slug'])

# NoReverseMatch: Reverse for 'index' with arguments '()'
#and keyword arguments '{'some_slug': 'slug'}' not found.
test_url = reverse('test:index', kwargs={'some_slug': 'slug'})

# Desired output is '/slug/test/'

return HttpResponse("""
root index
Test
""".format(test_url=test_url))
end mysite/views.py


mysite/test/views.py
from django.http import HttpResponse

def index(request, some_slug):
return HttpResponse('test index: %s' % some_slug)
end mysite/test/views.py


reverse('test:index') will only resolve if you don't pass it any
arguments. And then the result is the original regex... The desired
behavior is for it to either accept args or kwargs of 'slug' and
return '/slug/test/'.

Is there a setting that I am missing to allow for this behavior? Is
this a known bug?

Any information would be greatly appreciated.


Derek

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



blog breack after 10 post x__x

2011-07-15 Thread Kase
realy i dont know how to expres this..

i need this
(is a blog app)

1) post
2)post
3)post
...
10)post
page 1,2,3,4,5,6,7,8.last

when clic 2  list of post are
11)post
12)post

20)post

django  have somthing to do this in the easiest

my code is the (obius)

{%for x in post%}
{{x.title}}
{{x.post}}
by:{{x.user.username}} about  {(x.time|timesince)} ago
{%endfor%}

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



Re: blog breack after 10 post x__x

2011-07-15 Thread Jian Chang
django doesn't have,
but you can extent  based on django.core.paginator.Paginator.The attachment
is what i use, you can change it by your needs



2011/7/16 Kase 

> realy i dont know how to expres this..
>
> i need this
> (is a blog app)
>
> 1) post
> 2)post
> 3)post
> ...
> 10)post
> page 1,2,3,4,5,6,7,8.last
>
> when clic 2  list of post are
> 11)post
> 12)post
> 
> 20)post
>
> django  have somthing to do this in the easiest
>
> my code is the (obius)
>
> {%for x in post%}
> {{x.title}}
> {{x.post}}
> by:{{x.user.username}} about  {(x.time|timesince)} ago
> {%endfor%}
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: blog breack after 10 post x__x

2011-07-15 Thread Jian Chang
2011/7/16 Jian Chang 

> django doesn't have,
> but you can extent  based on django.core.paginator.Paginator.The attachment
> is what i use, you can change it by your needs
>
>
>
>
> 2011/7/16 Kase 
>
>> realy i dont know how to expres this..
>>
>> i need this
>> (is a blog app)
>>
>> 1) post
>> 2)post
>> 3)post
>> ...
>> 10)post
>> page 1,2,3,4,5,6,7,8.last
>>
>> when clic 2  list of post are
>> 11)post
>> 12)post
>> 
>> 20)post
>>
>> django  have somthing to do this in the easiest
>>
>> my code is the (obius)
>>
>> {%for x in post%}
>> {{x.title}}
>> {{x.post}}
>> by:{{x.user.username}} about  {(x.time|timesince)} ago
>> {%endfor%}
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



pagination.py
Description: Binary data


Re: django.core.urlresolvers.reverse capturing group before include behavior

2011-07-15 Thread Jian Chang
try this: reverse("mysites.views.index")

2011/7/16 Squeesh 

> I have run into an issue using reverse() to lookup named urls with
> capturing groups before an include().
>
> Code:
>
> mysite/urls.py
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
>url(r'^$',  'views.index',
> name='root'),
>url(r'^(?P\w+)/test/',   include('test.urls',
> namespace='test')),
> )
> end mysite/urls.py
>
>
> mysite/test/urls.py
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
>url(r'^$',  'test.views.index',
> name='index'),
> )
> end mysite/test/urls.py
>
>
> mysite/views.py
> from django.core.urlresolvers import reverse
> from django.http import HttpResponse
>
> def index(request):
># Works: returns '/(?P\w+)/test/'
>test_url = reverse('test:index')
>
># NoReverseMatch: Reverse for 'index' with arguments '('slug',)'
>#and keyword arguments '{}' not found.
>test_url = reverse('test:index', args=['slug'])
>
># NoReverseMatch: Reverse for 'index' with arguments '()'
>#and keyword arguments '{'some_slug': 'slug'}' not found.
>test_url = reverse('test:index', kwargs={'some_slug': 'slug'})
>
># Desired output is '/slug/test/'
>
>return HttpResponse("""
>root index
>Test
>""".format(test_url=test_url))
> end mysite/views.py
>
>
> mysite/test/views.py
> from django.http import HttpResponse
>
> def index(request, some_slug):
>return HttpResponse('test index: %s' % some_slug)
> end mysite/test/views.py
>
>
> reverse('test:index') will only resolve if you don't pass it any
> arguments. And then the result is the original regex... The desired
> behavior is for it to either accept args or kwargs of 'slug' and
> return '/slug/test/'.
>
> Is there a setting that I am missing to allow for this behavior? Is
> this a known bug?
>
> Any information would be greatly appreciated.
>
>
> Derek
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Russell Keith-Magee
On Fri, Jul 15, 2011 at 5:18 PM, Paul Walsh  wrote:
> I am pretty new to Django - new enough to be developing my first Django app
> on 1.3. So, I am basing all my work on class-based generic views, and have
> never used the older generic view functions.
> A problem I have is the lack of examples and documentation on the new
> class-based generic views.

This is admittedly a big problem with the class-based generic views.
As the person responsible for committing them, I can only offer my
humble apologies for their current state.

> Some might suggest I use Django Forms - it is a reasonable suggestion of
> course. But, being new, I don't have any "view legacy" and I just like the
> idea of working with class-based generic views where possible.

Some might, and they would be correct :-)

This isn't a legacy issue at all -- Forms and Views solve different problems.

The View is solving the problem of "how do I handle this request and
convert it into a response?". The Form is solving the problem of "How
do I convert the POST data in this request into a model object (or a
change to a model object)?".

Very roughly, a view is doing the following:

 1. View gets a request
 2. View works out whether this is a GET or a POST
 3. If its a POST, View asks the Form to turn the Post into a model change
 4. Form returns success or failure
 5. View responds to the success or failure of the Form.
 6. View returns a response.

The functionality of the Form is a complete subset of the
functionality of the View -- and for this reason, it's a completely
interchangable internal component.

Now, in simple situations, it's possible for a View to guess all the
defaults for the form -- all it needs to know is that you're dealing
with a Foo model, and it can construct a default Foo ModelForm.
However, if you have more sophisticated form requirements, you're
going to need a customized Form.

We *could* have implemented this by exposing all the options of
ModelForm on the View class; but in order to keep everything clean, we
kept the ModelForm isolated, and provided the View with a way to
specify which Form class it's going to use.

So - to cover your use case of excluding fields, you define a
ModelForm that excludes the fields, then let the CreateView know the
form you want to use:

class ModelForm(forms.ModelForm):
class Meta:
model = Campaign
exclude = ('user', 'name', 'content_inlined')

class CreateCampaignView(CreateView):
form_class = CampaignForm
template_name = "forms/create.html"

I'm guessing when you say "fix a values for a field", you mean setting
the values of user, name and content_inlined before you save the new
Campaign instance; to do this, you need to inject some extra code into
the form processing logic of the form:

class CreateCampaignView(CreateView):
form_class = CampaignForm
template_name = "forms/create.html

def form_valid(self, form):
self.object.user = ... (something meaningful.. e.g., self.request.user)
return super(CreateCampaignView, self).form_valid(form)

This overrides the default behavior when the form is valid, and sets
the extra values. The super() implementation of form_valid() will then
save the instance.

For the record, this could also be done by overriding the save()
method on the ModelForm -- however, if you do that, you lose the
request object, which you will need if you're trying to set the
instance values to something that is request-sensitive.

I hope I've provided some helpful clarification here.

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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Venkatraman S
The below email contents can go into the django wiki? Explained in a lucid
manner.
Actually, it would be awesome, if someone from this group can volunteer to
extract useful
text explanations from this ML and put in the wiki.

I would have done it, but i lost my password, and i dont see a 'forgot
password' link in the wiki ;)

On Sat, Jul 16, 2011 at 7:58 AM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> On Fri, Jul 15, 2011 at 5:18 PM, Paul Walsh  wrote:
> > I am pretty new to Django - new enough to be developing my first Django
> app
> > on 1.3. So, I am basing all my work on class-based generic views, and
> have
> > never used the older generic view functions.
> > A problem I have is the lack of examples and documentation on the new
> > class-based generic views.
>
> This is admittedly a big problem with the class-based generic views.
> As the person responsible for committing them, I can only offer my
> humble apologies for their current state.
>
> > Some might suggest I use Django Forms - it is a reasonable suggestion of
> > course. But, being new, I don't have any "view legacy" and I just like
> the
> > idea of working with class-based generic views where possible.
>
> Some might, and they would be correct :-)
>
> This isn't a legacy issue at all -- Forms and Views solve different
> problems.
>
> The View is solving the problem of "how do I handle this request and
> convert it into a response?". The Form is solving the problem of "How
> do I convert the POST data in this request into a model object (or a
> change to a model object)?".
>
> Very roughly, a view is doing the following:
>
>  1. View gets a request
>  2. View works out whether this is a GET or a POST
>  3. If its a POST, View asks the Form to turn the Post into a model change
>  4. Form returns success or failure
>  5. View responds to the success or failure of the Form.
>  6. View returns a response.
>
> The functionality of the Form is a complete subset of the
> functionality of the View -- and for this reason, it's a completely
> interchangable internal component.
>
> Now, in simple situations, it's possible for a View to guess all the
> defaults for the form -- all it needs to know is that you're dealing
> with a Foo model, and it can construct a default Foo ModelForm.
> However, if you have more sophisticated form requirements, you're
> going to need a customized Form.
>
> We *could* have implemented this by exposing all the options of
> ModelForm on the View class; but in order to keep everything clean, we
> kept the ModelForm isolated, and provided the View with a way to
> specify which Form class it's going to use.
>
> So - to cover your use case of excluding fields, you define a
> ModelForm that excludes the fields, then let the CreateView know the
> form you want to use:
>
> class ModelForm(forms.ModelForm):
> class Meta:
>model = Campaign
>exclude = ('user', 'name', 'content_inlined')
>
> class CreateCampaignView(CreateView):
>form_class = CampaignForm
> template_name = "forms/create.html"
>
> I'm guessing when you say "fix a values for a field", you mean setting
> the values of user, name and content_inlined before you save the new
> Campaign instance; to do this, you need to inject some extra code into
> the form processing logic of the form:
>
> class CreateCampaignView(CreateView):
>form_class = CampaignForm
> template_name = "forms/create.html
>
> def form_valid(self, form):
>self.object.user = ... (something meaningful.. e.g.,
> self.request.user)
>return super(CreateCampaignView, self).form_valid(form)
>
> This overrides the default behavior when the form is valid, and sets
> the extra values. The super() implementation of form_valid() will then
> save the instance.
>
> For the record, this could also be done by overriding the save()
> method on the ModelForm -- however, if you do that, you lose the
> request object, which you will need if you're trying to set the
> instance values to something that is request-sensitive.
>
> I hope I've provided some helpful clarification here.
>
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: blog breack after 10 post x__x

2011-07-15 Thread Venkatraman S
What you need is a paginator, which paginates through the objects.
Try using endless_pagination. Its an awsum app.

-V

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



Re: custom method in models.py

2011-07-15 Thread Kenneth Gonsalves
On Fri, 2011-07-15 at 11:14 -0700, Suprnaturall wrote:
> class Category(models.Model):
> name = models.CharField(max_length=250)
> 
> def get_short_name():
> return name[0,20] 

def get_short_name(self)
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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