Re: ServerArrangements Wiki Page

2012-06-02 Thread Russell Keith-Magee
On Sat, Jun 2, 2012 at 11:53 PM, Henrik Genssen
 wrote:
> Hi,
>
> this page
> https://code.djangoproject.com/wiki/ServerArrangements
> seems a little outdated. Is this still the main source for listing, how to 
> run django in production?

I wouldn't describe it as the main source of anything. I wasn't even
aware that wiki page existed; from the look of it, it hasn't been
updated in over 2 years, and even then, it hasn't been updated to
point to the "new" URL for Django's official documentation (i.e., most
of the URLs are pointing to djangoproject.com/documentation, which
hasn't been the location of the docs for several years).

The official documentation for deployment is here:

https://docs.djangoproject.com/en/1.4/howto/deployment/

That document suggests mod_wsgi under apache2 as the suggested first
port of call, but also provides docs for other WSGI containers,
including gunicorn.

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: Oracle schema not working

2012-06-02 Thread akaariai
On Jun 1, 12:58 pm, Jani Tiainen  wrote:
> > Hello. The user connecting to Oracle is an ordinary user and needs to
> > prefix all tables with the schema name.
> > I've tried crafting Meta.db_table like so:
> >http://cd-docdb.fnal.gov/cgi-bin/RetrieveFile?docid=3156=1...
>
> > But I get error
>
> > DatabaseError at /
>
> > schema "foo" does not exist
> > LINE 1: ...ty", "foo"."table_name"."address_country" FROM "foo"."...
>
> > I also tried wrapping request in a TransactionMiddleware and execute
> > this SQL before the fetching (modifying Meta accordingly):
> > MyModel.objects.raw('ALTER SESSION SET CURRENT_SCHEMA=foo')
>
> > Neither way helped. The user has the needed permissions.
>
> Since Oracle doesn't make a difference between user and schema (they're
> equivalents)
>
> Simplest thing is to create (private/public) synonyms for tables for
> user in question. Otherwise you need to prefix with schema name.
>
> See also tickethttps://code.djangoproject.com/ticket/6148

I have updated the patch in that ticket to current master. It should
now work for all core backends, though GIS is still unsupported.
Please test.

 - Anssi

-- 
You received this message because you are subscribed to the Google 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 ModelForm user best practices

2012-06-02 Thread Peter of the Norse
https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form
 has a highlighted note about this very issue. The way they recommend is: 
(based on #1 below)

initial_notification = Notification(user=self.request.user, board=..., 
post=...)
form = NotificationModelForm(self.request.POST, 
initial=initial_notification)
if form.is_valid():
form.save()

This should be the solution you’re looking for.

On May 30, 2012, at 1:45 PM, RM wrote:

> Say there's a model:
> 
> class Notification(models.Model):
> user = models.ForeignKey(User)
> board = models.ForeignKey(Board)
> post = models.ForeignKey(Post)
> name = models.CharField()
> 
> class Meta:
> unique_together = ('user', 'name', 'post', 'board')
> #i know this is funny.. just for purpose of this post
> 
> In every post there's a form that you can fill with "name" value.
> This way the logged in user gets notification on every post update.
> 
> What is the best way to save the "user", "board", "post" data ?
> 
> 1. Saving in the views directly (CBV):
> 
> class NotificationModelForm(forms.ModelForm):
> class Meta:
> model = Notification
> fields = ["name"]
> 
> class CreateNotificationView(CreateView):
> model = Notification
> form_class = NotificationForm
> def form_valid(self, form):
> data = form.save(commit=False)
> data.user = self.request.user
> data.board = ...
> data.post = ...
> data.save()
> 
> * if you have model validators (unique_together for user... this won't no 
> longer work when submitting the form)
> 
> 2. Displaying all the fields in the form, with some fields hidden
> 
> class NotificationModelForm(forms.ModelForm):
> class Meta:
> fields = ["user", "board", "post", "name"]
> 
> def __init__(self, *args, **kwargs):
> super(NotificationModelForm, self).__init__(*args, **kwargs)
> for field in ["user", "board", "post"]:
> forms.field['field'].widget = forms.HiddenInput()
> #I know this can be done other ways too
> 
> Now we need to prepopulate fields with initial data for these fields
> 
> class CreateNotificationView(CreateView):
> model = Notification
> form_class = NotificationModelForm
> 
> def get_initial(self):
> initial = super(CreateNotificationView, self).get_initial()
> initial['user'] = self.request.user
> initial['board'] = ...
> initial['post'] = 
> return initial
>   
> If the same field pattern (user, board, post) is used in more forms/views... 
> I can also create a MixinView
> 
> class CommonUserFormMixin(object):
> 
> def get_form(self, form_class):
> form = super(CommonUserFormMixin, self).get_form(form_class)
> for field in ['user', 'board', 'post']:
> form.fields[field].widget = forms.HiddenInput()
> 
> Then:
> 
> class NotifcationModelForm(forms.ModelForm):
> class Meta:
> model = Notification
> fields = ["user", "board", "post", "name"]
> 
> class CreateNotificationView(CommonUserFormMixin, CreateView):
> form_class = NotificationModelForm
> model = Notification
> 
> * in 2 above scenarios we get model validators working.
> 3. Sending values to the form directly and overriding the form.save() method
> 
> class CreateNotificationView(CreateView):
> model = Notification
> form_class = NotificationModelForm
> 
> def get_form_kwargs(**kwargs):
> kwargs = super(CreateNotificationView, self).get_form_kwargs(**kwargs)
> kwargs['user'] = self.request.user
> kwargs['board'] = ...
> kwargs['post'] = ...
> return kwargs
> 
> class NotificationModelForm(forms.ModelForm):
> class Meta:
> model = Notification
> fields = ["name"]
> 
> def __init__(self, *args, **kwargs):
> self.user = kwargs.pop('user')
> self.post = kwargs.pop('post')
> self.board = kwargs.pop('board')
> 
> super(NotificationModelForm, self).__init__(*args, **kwargs)
> 
> def save(*args, **kwargs):
> n = super(NotificationModelForm, self).save(commit=False)
> n.user = self.user
> n.post = self.post
> n.board = self.board
> n.save()
> return n
> 
> 
> I'm sure there are more ways to achive the same result.
> What are your thoughts on that ?
> 
> When should I 'hide' (by using HiddenInput() widget) ModelForm fields? when 
> should I save them directly
> in view? 
> 
> Does it all depend on needs or maybe there are some "best" standards ?
> 
> 
> -- 
> 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/-/xn6xNGKJ2CEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this 

Django CRM Tool

2012-06-02 Thread Zeeshan Syed
Hey everyone,

I've been asked to create a CRM tool using Django. Just wondering what
route I should take. Would it be wise to start from scratch? Should I
play around with Django admin and mess around with that? I've looked
at the django-crm project, has anyone had any experience with that?

Any help is much appreciated.

Thanks,
Zee

-- 
You received this message because you are subscribed to the Google 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: PyPm / Django 1.4?

2012-06-02 Thread Bill Freeman
Have you considered running under a virtualenv and pip installing
exactly what you need?

On Fri, Jun 1, 2012 at 5:28 PM, Aaron C. de Bruyn  wrote:
> I am not a Windows developer--but I was recently asked to port a very small
> Django app (so it could be run locally using the dev server) on Windows.
>
> The app was developed using Django 1.4, but the ActiveState Package Manager
> (pypm) installs Django 1.3.  Rather than rewriting some of the code, I'd
> like to see Django 1.4 available under pypm.  But I am completely unfamiliar
> with the Windows side of anything Python or Django.
>
> Is there someone I can ping to get the package updated?
> Any pointers?
>
> Thanks,
>
> -A
>
> --
> 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/-/7q1DdIyDMwIJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Problem with Django Project

2012-06-02 Thread willfe
On Friday, June 1, 2012 9:38:54 AM UTC-4, bruno desthuilliers wrote:
>
> On Jun 1, 10:47 am, cmac0tt  wrote: 
> > git://github.com/cmac0tt/wikicamp.git 
>
> Some web-browsable link would have been more helpful (sorry, I'm not 
> going to clone your repo). 
>
 
I think that's just https://github.com/cmac0tt/wikicamp ... I get a 
browsable repository view when browsing there.

-- 
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/-/yc2zjDqxIjwJ.
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.



ServerArrangements Wiki Page

2012-06-02 Thread Henrik Genssen
Hi,

this page 
https://code.djangoproject.com/wiki/ServerArrangements
seems a little outdated. Is this still the main source for listing, how to run 
django in production?

1. I thought mod_python would be deprecated (a hint would be useful)
2. Gunicorn [1] is missing (has native django support) sample see [2] 
3. Twisted [3] should work now, too or was there more than ticket #172

maybe someone knows more?

I am not an export on this - so far I only used apache2. Now I am looking for 
an alternative - not for perfomance, 
but for better mem usage... and came across this wiki page

[1] http://gunicorn.org/
[2] http://dbinit.com/blog/going-green/
[3] http://code.google.com/p/django-on-twisted/

regards

Henrik

Henrik Genssen

h...@miadi.net
Tel. +49 (0)451/6195650
Fax. +49 (0)451/6195655
http://www.miadi.net
http://www.facebook.com/pages/Miadi/150192061701844

miadi GmbH
Geschäftsführer: Henrik Genssen
Sitz der Gesellschaft: Hüxstraße 1 - 9, 23552 Lübeck
Amtsgericht Lübeck HRB 10223, USt-IdNr DE
Lieferungen und Leistungen erfolgen ausschließlich auf Grundlage unserer 
allgemeinen Geschäftsbedingungen

-- 
You received this message because you are subscribed to the Google 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: Scaling django installation

2012-06-02 Thread Subhranath Chunder
On Sat, Jun 2, 2012 at 7:14 AM, Tim Chase wrote:

> On 06/01/12 09:17, Subhranath Chunder wrote:
> > (Given the fact that the server is deployed in Amazon EC2
> > Singapore location, as m1.xlarge with all it's network, memory
> > constrains in place)
>
> A couple of the other aspects that occurred to me:
>
> Is there geographical separation between your Django/web server and
> its backing database?  If your web server is serving Django
> pages/apps out of Singapore, but the database serving each of those
> requests is in the USA, it's asking for trouble.
>
Right you are. But NO in my case. :)


>
> Alternatively, if they're on the same (virtual?) server, are they
> competing for resources?  Most scalable sites have Django and
> database processes running on separate servers but ensuring that
> they're on the same local low-latency network
>
As I said currently, yes they are deployed as a single server setup. So are
competing for resources.
I'll probably change the setup to low-latency network cluster in the
future, once traffic starts to increase, and horizontal scaling is required.


>
> I presume your database queries have established indexes for the
> types of data queries you're executing.
>
YES.


>
>
> None of this precludes actually profiling your application to see
> where the slowness is actually happening, but it might be helpful to
> have in mind as you got chasing things down.
>
Sure. I'm chasing things down to keep them improving. It's better to
know/find possible bottlenecks, than ever getting badly caught on one.


>
> -tkc
>
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: Obtaining objects from a many-to-many relationship

2012-06-02 Thread Thomas Lockhart

On 12-06-02 1:15 AM, Kurtis Mullins wrote:

Have you tried b.haveone.all()?

Yes. Simplemindedly I wanted to try

B.haveone.all()

If I understand your suggestion, it would require iterating on instances 
of B to find all instances of A mentioned in B.


that would be something like

for b in B.objects.all():
  a = b.haveone.all()
  ...

which of course does work fine but may require visiting an instance of A 
more than once.


What I'm looking for is to select all unique instances of A which appear 
in B without iterating on B. Not all instances of A appearing in b (one 
specific instance of B).


tia

 - Tom



On Sat, Jun 2, 2012 at 12:36 AM, Thomas Lockhart 
> wrote:


I've got two models with one having a many-to-many relationship
with the other:

class A(models.Model):
 name = models.CharField("name")

class B(models.Model):
 haveone = models.ManyToManyField(A)

What is the idiom for getting all instances of A which are
referenced in B? I found this works:

A.objects.annotate(n=models.Count('b')).filter(n__gt=0)

But istm that there is probably a more concise and straightforward
way to accomplish this (and the solution is probably obvious but
it is escaping me). tia

 - Tom

-- 
You received this message because you are subscribed to the Google

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: Django session and Dojo dnd.

2012-06-02 Thread henzk
Hi,

i haven't tested the code and never used dojo before, but sth. like
this should work:

var source1 = new dojo.dnd.Source("itemListNode");
var source2 = new dojo.dnd.Target("selectedListNode");
dojo.connect( source1, "onDndDrop",
function(source, nodes, copy, target){
//gather items and details
var details = [];
for( i=0; i < nodes.length; i++){
var item = this.getItem(nodes[i].id);
details.push(item.data);
}
//send details to server via AJAX POST request
dojo.xhrPost({
url: "/save_details/",
content: {details: JSON.stringify(details)},
// The success handler
load: function(response) {
 alert('ok');
},
// The error handler
error: function() {
 alert("error");
}
});
});

Explanation:

- changed 'item' to 'var item' ... without the 'var' item will be
global, which is probably not what you want.
- to get around making multiple requests to the server(one for each
dropped node), put the detail of each node in the details array.
- then json-encode and send this array to your django view (assumed to
be at '/save_details/')
- in the view, access the list as
json.loads(request.POST.get('details', '[]')) and place it into
request.session

As mentioned, the code is completely untested.

Good luck!

Yours,

Hendrik Speidel

-- 
You received this message because you are subscribed to the Google 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 upload Django/Python to FTP

2012-06-02 Thread Shayne
Hi Kurtis!

Thanks for the quick reply.

Anyway, me and my web dev are both using repository now to update our
files.. from there (i guess) we will access and pull the files through
SSH(?)

Might try to ask over Stackoverflow.

Thanks so much, Kurtis!

-- 
You received this message because you are subscribed to the Google 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: Internationalization in Django 1.4 doesn't seem to work

2012-06-02 Thread kenneth gonsalves
On Sat, 2012-06-02 at 02:58 -0700, Houmie wrote:
> The good news is the problem is solved. A friendly chap in
> stackoverflow 
> actually bothered to look into it.
> 
> The problem is as simple as the translation files couldn't be found.
> For 
> some odd reason the important information about how Django locates
> them is 
> at the very last section of the documentation. It is really easy to
> miss.
> 
> All you have to do is to move the locale directory with the
> translation 
> files into your Application directory. Thats it !!! 

it may have solved your problem. But actually nowadays django looks into
settings.LOCALE_PATHS - could you check whether the svn revision number
you are using is less than 17860 or greater.
-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google 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: Internationalization in Django 1.4 doesn't seem to work

2012-06-02 Thread Houmie

>
> Hi Kenneth,


The good news is the problem is solved. A friendly chap in stackoverflow 
actually bothered to look into it.

The problem is as simple as the translation files couldn't be found.  For 
some odd reason the important information about how Django locates them is 
at the very last section of the documentation. It is really easy to miss.

All you have to do is to move the locale directory with the translation 
files into your Application directory. Thats it !!!

If you need to recreate the translation files you need top use the 
terminal, browse to the Application directory and run your command 
'django-admin.py makemessages -l de' from there.  

You can't do this from Aptana Studio 3.0, since it requires you to run any 
Django command from the root rather than from application directory.  Hence 
you need to do it in the terminal.

Just download my test app and try what I just said here, as I intend to 
remove the test project within the next few days.

Regards,
Houman

-- 
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/-/RpGtuMns31oJ.
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: Obtaining objects from a many-to-many relationship

2012-06-02 Thread Kurtis Mullins
https://docs.djangoproject.com/en/dev/topics/db/queries/#many-to-many-relationshipsfor
more information. (Unless I read your question wrong :))

On Sat, Jun 2, 2012 at 4:15 AM, Kurtis Mullins wrote:

> Have you tried b.haveone.all()?
>
>
> On Sat, Jun 2, 2012 at 12:36 AM, Thomas Lockhart 
> wrote:
>
>> I've got two models with one having a many-to-many relationship with the
>> other:
>>
>> class A(models.Model):
>>  name = models.CharField("name")
>>
>> class B(models.Model):
>>  haveone = models.ManyToManyField(A)
>>
>> What is the idiom for getting all instances of A which are referenced in
>> B? I found this works:
>>
>> A.objects.annotate(n=models.**Count('b')).filter(n__gt=0)
>>
>> But istm that there is probably a more concise and straightforward way to
>> accomplish this (and the solution is probably obvious but it is escaping
>> me). tia
>>
>>  - Tom
>>
>> --
>> You received this message because you are subscribed to the Google 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: Obtaining objects from a many-to-many relationship

2012-06-02 Thread Kurtis Mullins
Have you tried b.haveone.all()?

On Sat, Jun 2, 2012 at 12:36 AM, Thomas Lockhart wrote:

> I've got two models with one having a many-to-many relationship with the
> other:
>
> class A(models.Model):
>  name = models.CharField("name")
>
> class B(models.Model):
>  haveone = models.ManyToManyField(A)
>
> What is the idiom for getting all instances of A which are referenced in
> B? I found this works:
>
> A.objects.annotate(n=models.**Count('b')).filter(n__gt=0)
>
> But istm that there is probably a more concise and straightforward way to
> accomplish this (and the solution is probably obvious but it is escaping
> me). tia
>
>  - Tom
>
> --
> You received this message because you are subscribed to the Google 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: Internationalization in Django 1.4 doesn't seem to work

2012-06-02 Thread kenneth gonsalves
On Fri, 2012-06-01 at 10:58 -0700, Houmie wrote:
> I would really appreciate it if somebody could help me with this.
> Working on this since this morning and am totally stuck..
> 
> 

could you try with revision 17860 and see if it works. I have the same
problem, and am stuck with 17860 - unfortunately I have been unable to
replicate the problem with a simple example.
-- 
regards
Kenneth Gonsalves


-- 
You received this message because you are subscribed to the Google 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.