Re: IDE django with perforce

2013-05-29 Thread kamta singh
sorry yr,from beginning i am using pycharm


On Thu, May 30, 2013 at 11:08 AM, Avnesh Shakya wrote:

> Try Pycharm, but use always eclipse. eclipse is better than it.
> Regards,
> Avnesh Shakya
>
>
> On Thu, May 30, 2013 at 10:53 AM, Aswani Kumar wrote:
>
>> hi guys,
>>
>> we are having problem with eclipse 3.8 with pydev perforce plugins on
>> ubuntu 13.04
>>
>> *problem :* after using for few days or unexpected shutdown, eclipse
>> stops working i mean opening.
>>
>> we need perforce with django, can any one tell me whats the best ide for
>> django with integrated perforce plugin.
>>
>> any online step by step tutorial will do good.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Regards
Kamta Prasad Singh
981890

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




Re: IDE django with perforce

2013-05-29 Thread Avnesh Shakya
Try Pycharm, but use always eclipse. eclipse is better than it.
Regards,
Avnesh Shakya


On Thu, May 30, 2013 at 10:53 AM, Aswani Kumar  wrote:

> hi guys,
>
> we are having problem with eclipse 3.8 with pydev perforce plugins on
> ubuntu 13.04
>
> *problem :* after using for few days or unexpected shutdown, eclipse
> stops working i mean opening.
>
> we need perforce with django, can any one tell me whats the best ide for
> django with integrated perforce plugin.
>
> any online step by step tutorial will do good.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: IDE django with perforce

2013-05-29 Thread kamta singh
use pycharm


On Thu, May 30, 2013 at 10:53 AM, Aswani Kumar  wrote:

> hi guys,
>
> we are having problem with eclipse 3.8 with pydev perforce plugins on
> ubuntu 13.04
>
> *problem :* after using for few days or unexpected shutdown, eclipse
> stops working i mean opening.
>
> we need perforce with django, can any one tell me whats the best ide for
> django with integrated perforce plugin.
>
> any online step by step tutorial will do good.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Regards
Kamta Prasad Singh
981890

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




IDE django with perforce

2013-05-29 Thread Aswani Kumar
hi guys,

we are having problem with eclipse 3.8 with pydev perforce plugins on 
ubuntu 13.04

*problem :* after using for few days or unexpected shutdown, eclipse stops 
working i mean opening.

we need perforce with django, can any one tell me whats the best ide for 
django with integrated perforce plugin.

any online step by step tutorial will do good.

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




Re: Scripts to update Django tables

2013-05-29 Thread Mike Dewhirst

On 30/05/2013 12:01am, Brian wrote:

I'm new to Django (and frameworks in general) and having an issue with a
project I'm working on.  Basically, I want to scrape data from a sports
league website on a regular schedule and add updated stats into my
database.


I think the way you have described the task is a little scary. It sounds 
as though you haven't bothered to get permission to acquire the data. I 
could be wrong.


What you want however isn't too difficult to achieve. The Django 
framework was/is designed to build interactive websites layered on top 
of a database. So once you have modelled your data in Django and created 
your database accordingly you are nearly there. Django is (much more 
than) just a bunch of Python libraries which incude mechanisms for 
saving data. You need to write your own Python script to munge the 
incoming data to match your model(s) and call Django routines to save it 
into the database. I haven't done that myself but that's how I would 
tackle it.


All of the Django tutorials for models I've looked at seem to

give me information on how to add table data manually using the
manage.py shell, fixtures, or fields on an admin page, but I cannot find
anything about doing this more automatically through a script.  Is there
something I'm missing, or am I trying to use Django models for something
they aren't meant to be used for?

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




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




input data will be lost if there are errors in the form

2013-05-29 Thread Jeff Hsu
Hi,

I find this very interesting.  In my html template form:


{% csrf_token %}
   
{{ form.title.errors}}

*{{form.title}}*
.
This is fine, and it will show the previous inputs if there are errors in 
the form, however, if I try to customize the html input field, for example, 
as below, instead of using automatic generated {{form.title}}
 *  *

The previous inputs will be lost if there are errors in the form.  Does 
anybody know why?  I need some direction and explanation for this.  Thank 
you

Jeff



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




Please ,How to pass request.user to wizard form field?

2013-05-29 Thread amoypeople
sorry ,please forgive me my poor english.

  I  customize a FriendMultiplySelectedField which inherited 
from forms.ModelMultipleChoiceField , to query a list friend for choice . 
when I added __init__  function in form  to accept request.usr  and then 
pass it to FriendMultiplySelectedField.  i meet a problem with form 
validation .
I found  the reason maybe field wizardform prefix had lost when added 
__init__ function in Form.
Did I do something wrong, I wonder how does wizardform process 
__ init__, and if  remove __init__ function in form ,how can i pass 
request.user to field. thanks

### my customize field
class FriendMultiplySelectField(forms.ModelMultipleChoiceField):
def __init__(self, user=None, cache_choices=False, required=True,
 widget=None, label=None, initial=None,
 help_text=None, *args, **kwargs):
if  user != None:
queryset = Friend.objects.filter(to_user_id=user)
else:
queryset = Friend.objects

super(FriendMultiplySelectField, self).__init__(queryset,
cache_choices, 
required,
widget, label, 
initial,
help_text, *args, 
**kwargs)


class ProjectSettingForm(forms.Form):
publish_now =  forms.BooleanField(label="publish 
now",required=False,initial=True)
publish_time = forms.DateTimeField(required=False,label="publish time")
def __init__(self,*args,**kwargs):
self.user = kwargs.pop("user")
super(ProjectSettingForm, self).__init__( args,kwargs)
self.fields["people"] = 
FriendMultiplySelectField(required=False,label="asign to",user=self.user)


class CreateTask(SessionWizardView):
file_storage = 
FileSystemStorage(location=os.path.join(settings.MEDIA_ROOT,'task_attachment'))
def get_template_names(self):
return [TEMPLATES[self.steps.current]]
def get_form_kwargs(self ,step=None):
kwargs = super(CreateTask,self).get_form_kwargs(step)
if step == self.steps.last:
kwargs.update(user=self.request.user)
return kwargs

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




Re: ORM Prefetch related and only()

2013-05-29 Thread Àlex Pérez
As you say the raw sql always is the solution.

But I take a few time to think how that could be possible with the ORM, and
like
akaariai says the prefetch_related get the values for de _default_manager.

But if i defined a temporally manager that makes the only clausure it
works, but i don't know if is thread safe.



class OtherManager(models.Manager):
def get_query_set(self):
return
super(OtherManager,self).get_query_set().only("nombre")

class Especialidad(models.Model):
nombre = models.CharField(max_length=255)

objects = models.Manager()
otro = OtherManager()


Especialidad._default_manager = Especialidad.otro
tpl_vars["list"] = list(tpl_vars["list"])
Especialidad._default_manager = Especialidad.objects

Thank's!


2013/5/29 Christophe Pettus 

>
> On May 29, 2013, at 12:44 PM, Àlex Pérez wrote:
>
> > You know the way to simulate  the behaviour that i want.?
>
> Raw SQL.  At the point you are doing a multi-join query and selecting a
> subset of the fields to be returned, you probably should switch to raw SQL
> anyway.
>
> --
> -- Christophe Pettus
>x...@thebuild.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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




Re: ORM Prefetch related and only()

2013-05-29 Thread Christophe Pettus

On May 29, 2013, at 12:44 PM, Àlex Pérez wrote:

> You know the way to simulate  the behaviour that i want.?

Raw SQL.  At the point you are doing a multi-join query and selecting a subset 
of the fields to be returned, you probably should switch to raw SQL anyway.

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

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




Re: ORM Prefetch related and only()

2013-05-29 Thread Àlex Pérez
Ok thank's!!!

but you thinks thats the normal behaviour? this could be included in future
versions of the orm?

You know the way to simulate  the behaviour that i want.?

2013/5/29 akaariai 

> There is no way to alter the behavior of prefetch_related. It fetches
> the related objects with the query defined by the related manager and
> that's it.
>
>  - Anssi
>




-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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




ANNOUNCE: django-modelqueryform

2013-05-29 Thread C. Kirby
I've just placed django-modelqueryform on github
http://github.com/ckirby/django-modelqueryform
 
and PyPi.

django-modelqueryform is a project that allows users to 
build somewhat complex queries against a model tree.
It can help with complex user search, report generation,
and other like workflows. 

django-modelqueryform provides a Form class for 
subclassing which provides a form for generating 
queries against a model and a form processor to  run 
the generated query

The generated form allows building a query with logical 
or of values in a single model field and logical and 
between fields 

The generated form is made up of MultipleChoiceFields 
for each field in the model. The choices for the field will 
be the choices as defined on the model field if they exist. 
Otherwise it will pull the distinct values for that field and 
use them.

Input, feedback, thoughts all welcome.

Thanks,
Chaim Kirby

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




Re: ORM Prefetch related and only()

2013-05-29 Thread akaariai
There is no way to alter the behavior of prefetch_related. It fetches
the related objects with the query defined by the related manager and
that's it.

 - Anssi

On 29 touko, 19:40, Àlex Pérez  wrote:
> I want to know if there is a way that the query that is executed to get the
> prefetch related information can get only certains values, actually that
> only works for select_related,
>
> May be i have done something wrong but the prefetch_related query is
> getting all the fields of the model.
>
> Someone can help me please?
>
> --
> Alex Perez
> alex.pe...@bebabum.com
>
>  *bebabum* be successful
>
> c/ Còrsega 301-303, Àtic 2
> 08008 
> Barcelonahttp://www.bebabum.comhttp://www.facebook.com/bebabumhttp://twitter.com/bebabum
>
> This message is intended exclusively for its addressee and may contain
> information that is confidential and protected by professional privilege.
> If you are not the intended recipient you are hereby notified that any
> dissemination, copy or disclosure of this communication is strictly
> prohibited by law.
>
> Este mensaje se dirige exclusivamente a su destinatario y puede contener
> información privilegiada o confidencial. Si no es vd. el destinatario
> indicado,
> queda notificado que la utilización, divulgación y/o copia sin autorización
> está prohibida en virtud de la legislación vigente.
>
> Le informamos que los datos personales que facilite/ha facilitado pasarán a
> formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
> por finalidad gestionar las relaciones con usted.
> Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
> oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
> de e-mail l...@bebabum.com

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




Re: Admin for proxy model for custom User

2013-05-29 Thread Andres Osinski
I omitted the code from the sample, but I do have that. The issue
seems to be that when the admin page loads, it's neither hitting the
deafault get_queryset() method in the ModelAdmin, not hitting the
proxy model's default manager methods. This is likely to be a bug.

On Tue, May 28, 2013 at 11:35 PM, Tomas Neme  wrote:
> Silly, but aren't you missing
>
> class Patient()
> save(self):
> self.kind = 'p'
> super(Patient, self).save()
>
> or some such thing and something similar for Doctor? I guess it might be in
> the forms, but since it's nowhere in the code you showed...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
Andrés Osinski
http://www.andresosinski.com.ar/

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




Re: linking the logged in user to other models to filter query sets -( noobie )

2013-05-29 Thread C. Kirby
Not knowing the specifics of your UserAccount model I will assume it has an 
organization = ForeignKeyField(Organization)

In that case in your view you can just do:

user_organization = request.user.organization

and use that to filter the query

On Wednesday, May 29, 2013 10:45:54 AM UTC-5, tony gair wrote:
>
> I think my first post was a bit messy and I left some information out
> I have an organisation as a foreign key contained in my abstact user 
> object which is Heating_User. The premises also contains the organisation 
> as a foreign key. What I am looking to do on my premises view is to filter 
> the premises so that the organisation is the same as that for the logged in 
> user. Although my model does include the premises id I want it so there is 
> a organisation wide flag that would list all the premises if that flag was 
> set. The superuser flag I (oh my that looks really useful). I think you 
> have probably told me what I need to know but I'm not sure. I guess what I 
> am asking in addition is how do I access the logged in user organisation 
> foreign key so that I can filter the query? 
>
> I hope that makes sense, I am quite new to this, but very enthused!!
>
> On Wednesday, 29 May 2013 15:16:32 UTC, Tom Evans wrote:
>>
>> On Wed, May 29, 2013 at 3:29 PM, tony gair  wrote: 
>> > 
>> > 
>> > I've done a basic django app with a user which contains an organisation 
>> and 
>> > premises foreign key inside the user model which has been inherited 
>> using 
>> > the features of django 1.5. 
>> > 
>> > I use the organisation id and premises id inside other models which I 
>> would 
>> > like to present themselves providing they are the same. 
>> > 
>> > I have tried to closely follow the 'two scoops of django approach' in 
>> that I 
>> > use a CBV with django braces approach to show my models. 
>> > 
>> > It is very important for me only to show the models in the views which 
>> use 
>> > either the organisation id or premises id. 
>> > 
>> > At the moment in my  forms.py for my  user it looks like 
>> > 
>> >  
>> > #forms.py 
>> > class HeatingUserForm ( forms.ModelForm): 
>> > 
>> > premises = CustomModelChoiceField(queryset=Premises.objects.all()) 
>> > organisation = 
>> CustomModelChoiceField(queryset=Organisation.objects.all()) 
>> > class Meta: 
>> > model=Heating_User 
>> > fields = [ 'username', 'password', 'first_name', 'last_name', 
>> > 'email', 'is_staff', 'is_active', 'date_joined', 'jobtitle', 
>> 'organisation', 
>> > 'premises' ] 
>> > 
>> > *** 
>> > 
>> > Unless the user is a super user, I want the organisation to be 
>> restricted to 
>> > the organisation that the logged in user is of the same . The premises 
>> > should be restricted to those premises that have the same id as the 
>> logged 
>> > in user. 
>> > 
>> > Can anyone tell me how this is done? 
>> > 
>> > :) 
>> > 
>>
>> You want to do different things in the form based upon the current 
>> user, so the first step is to require that a user object is passed to 
>> the form's __init__ method. Then, you simply manipulate the queryset 
>> attributes on the desired fields after calling the super class' 
>> __init__ method. 
>>
>> Also, if premises and organisation are foreign key fields, as it 
>> seems, you don't need to declare the fields at all: 
>>
>> class HeatingUserForm (forms.ModelForm): 
>> def __init__(self, *args, **kwargs): 
>> self.user = kwargs.pop('user') 
>> super(HeatingUserForm, self).__init__(*args, **kwargs) 
>> if self.user.is_superuser: 
>> self.fields['premises'].queryset = Premises.objects.all() 
>> self.fields['organisation'].queryset = 
>> Organisation.objects.all() 
>> else: 
>> self.fields['premises'].queryset = 
>> Premises.objects.filter(users=self.user) 
>> self.fields['organisation'].queryset = 
>> Organisation.objects.filter(users=self.user) 
>> class Meta: 
>> model=Heating_User 
>> fields = [ … ] 
>>
>> You could also do some additional cleanup work, if the number of 
>> choices for either of those two fields is exactly one, you could 
>> replace the widget on the form field with a hidden input, so that you 
>> do not display a pointless control (OTOH, it may not be pointless). 
>>
>> Cheers 
>>
>> Tom 
>>
>

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




ORM Prefetch related and only()

2013-05-29 Thread Àlex Pérez
I want to know if there is a way that the query that is executed to get the
prefetch related information can get only certains values, actually that
only works for select_related,

May be i have done something wrong but the prefetch_related query is
getting all the fields of the model.

Someone can help me please?


-- 
Alex Perez
alex.pe...@bebabum.com

 *bebabum* be successful

c/ Còrsega 301-303, Àtic 2
08008 Barcelona
http://www.bebabum.com
http://www.facebook.com/bebabum
http://twitter.com/bebabum

This message is intended exclusively for its addressee and may contain
information that is confidential and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any
dissemination, copy or disclosure of this communication is strictly
prohibited by law.

Este mensaje se dirige exclusivamente a su destinatario y puede contener
información privilegiada o confidencial. Si no es vd. el destinatario
indicado,
queda notificado que la utilización, divulgación y/o copia sin autorización
está prohibida en virtud de la legislación vigente.

Le informamos que los datos personales que facilite/ha facilitado pasarán a
formar parte de un fichero responsabilidad de bebabum, S.L. y que tiene
por finalidad gestionar las relaciones con usted.
Tiene derecho al acceso, rectificación cancelación y oposición en nuestra
oficina ubicada en c/ Còrsega 301-303, Àtic 2 de Barcelona o a la dirección
de e-mail l...@bebabum.com

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




Re: Allow visitor to add a form to a formset

2013-05-29 Thread Cody Scott
My issue was that I was putting my form_name in the 
cp['form_name-TOTAL_FORMS'] and it is always just form.

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




Re: linking the logged in user to other models to filter query sets -( noobie )

2013-05-29 Thread tony gair
I think my first post was a bit messy and I left some information out
I have an organisation as a foreign key contained in my abstact user object 
which is Heating_User. The premises also contains the organisation as a 
foreign key. What I am looking to do on my premises view is to filter the 
premises so that the organisation is the same as that for the logged in 
user. Although my model does include the premises id I want it so there is 
a organisation wide flag that would list all the premises if that flag was 
set. The superuser flag I (oh my that looks really useful). I think you 
have probably told me what I need to know but I'm not sure. I guess what I 
am asking in addition is how do I access the logged in user organisation 
foreign key so that I can filter the query? 

I hope that makes sense, I am quite new to this, but very enthused!!

On Wednesday, 29 May 2013 15:16:32 UTC, Tom Evans wrote:
>
> On Wed, May 29, 2013 at 3:29 PM, tony gair  
> wrote: 
> > 
> > 
> > I've done a basic django app with a user which contains an organisation 
> and 
> > premises foreign key inside the user model which has been inherited 
> using 
> > the features of django 1.5. 
> > 
> > I use the organisation id and premises id inside other models which I 
> would 
> > like to present themselves providing they are the same. 
> > 
> > I have tried to closely follow the 'two scoops of django approach' in 
> that I 
> > use a CBV with django braces approach to show my models. 
> > 
> > It is very important for me only to show the models in the views which 
> use 
> > either the organisation id or premises id. 
> > 
> > At the moment in my  forms.py for my  user it looks like 
> > 
> >  
> > #forms.py 
> > class HeatingUserForm ( forms.ModelForm): 
> > 
> > premises = CustomModelChoiceField(queryset=Premises.objects.all()) 
> > organisation = 
> CustomModelChoiceField(queryset=Organisation.objects.all()) 
> > class Meta: 
> > model=Heating_User 
> > fields = [ 'username', 'password', 'first_name', 'last_name', 
> > 'email', 'is_staff', 'is_active', 'date_joined', 'jobtitle', 
> 'organisation', 
> > 'premises' ] 
> > 
> > *** 
> > 
> > Unless the user is a super user, I want the organisation to be 
> restricted to 
> > the organisation that the logged in user is of the same . The premises 
> > should be restricted to those premises that have the same id as the 
> logged 
> > in user. 
> > 
> > Can anyone tell me how this is done? 
> > 
> > :) 
> > 
>
> You want to do different things in the form based upon the current 
> user, so the first step is to require that a user object is passed to 
> the form's __init__ method. Then, you simply manipulate the queryset 
> attributes on the desired fields after calling the super class' 
> __init__ method. 
>
> Also, if premises and organisation are foreign key fields, as it 
> seems, you don't need to declare the fields at all: 
>
> class HeatingUserForm (forms.ModelForm): 
> def __init__(self, *args, **kwargs): 
> self.user = kwargs.pop('user') 
> super(HeatingUserForm, self).__init__(*args, **kwargs) 
> if self.user.is_superuser: 
> self.fields['premises'].queryset = Premises.objects.all() 
> self.fields['organisation'].queryset = 
> Organisation.objects.all() 
> else: 
> self.fields['premises'].queryset = 
> Premises.objects.filter(users=self.user) 
> self.fields['organisation'].queryset = 
> Organisation.objects.filter(users=self.user) 
> class Meta: 
> model=Heating_User 
> fields = [ … ] 
>
> You could also do some additional cleanup work, if the number of 
> choices for either of those two fields is exactly one, you could 
> replace the widget on the form field with a hidden input, so that you 
> do not display a pointless control (OTOH, it may not be pointless). 
>
> Cheers 
>
> Tom 
>

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




Re: linking the logged in user to other models to filter query sets -( noobie )

2013-05-29 Thread Tom Evans
On Wed, May 29, 2013 at 3:29 PM, tony gair  wrote:
>
>
> I've done a basic django app with a user which contains an organisation and
> premises foreign key inside the user model which has been inherited using
> the features of django 1.5.
>
> I use the organisation id and premises id inside other models which I would
> like to present themselves providing they are the same.
>
> I have tried to closely follow the 'two scoops of django approach' in that I
> use a CBV with django braces approach to show my models.
>
> It is very important for me only to show the models in the views which use
> either the organisation id or premises id.
>
> At the moment in my  forms.py for my  user it looks like
>
> 
> #forms.py
> class HeatingUserForm ( forms.ModelForm):
>
> premises = CustomModelChoiceField(queryset=Premises.objects.all())
> organisation = CustomModelChoiceField(queryset=Organisation.objects.all())
> class Meta:
> model=Heating_User
> fields = [ 'username', 'password', 'first_name', 'last_name',
> 'email', 'is_staff', 'is_active', 'date_joined', 'jobtitle', 'organisation',
> 'premises' ]
>
> ***
>
> Unless the user is a super user, I want the organisation to be restricted to
> the organisation that the logged in user is of the same . The premises
> should be restricted to those premises that have the same id as the logged
> in user.
>
> Can anyone tell me how this is done?
>
> :)
>

You want to do different things in the form based upon the current
user, so the first step is to require that a user object is passed to
the form's __init__ method. Then, you simply manipulate the queryset
attributes on the desired fields after calling the super class'
__init__ method.

Also, if premises and organisation are foreign key fields, as it
seems, you don't need to declare the fields at all:

class HeatingUserForm (forms.ModelForm):
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user')
super(HeatingUserForm, self).__init__(*args, **kwargs)
if self.user.is_superuser:
self.fields['premises'].queryset = Premises.objects.all()
self.fields['organisation'].queryset = Organisation.objects.all()
else:
self.fields['premises'].queryset =
Premises.objects.filter(users=self.user)
self.fields['organisation'].queryset =
Organisation.objects.filter(users=self.user)
class Meta:
model=Heating_User
fields = [ … ]

You could also do some additional cleanup work, if the number of
choices for either of those two fields is exactly one, you could
replace the widget on the form field with a hidden input, so that you
do not display a pointless control (OTOH, it may not be pointless).

Cheers

Tom

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




Re: Scripts to update Django tables

2013-05-29 Thread Tom Evans
On Wed, May 29, 2013 at 3:01 PM, Brian  wrote:
> I'm new to Django (and frameworks in general) and having an issue with a
> project I'm working on.  Basically, I want to scrape data from a sports
> league website on a regular schedule and add updated stats into my database.
> All of the Django tutorials for models I've looked at seem to give me
> information on how to add table data manually using the manage.py shell,
> fixtures, or fields on an admin page, but I cannot find anything about doing
> this more automatically through a script.  Is there something I'm missing,
> or am I trying to use Django models for something they aren't meant to be
> used for?

Django can certainly be used outside of the request cycle. You can
write management commands:

https://docs.djangoproject.com/en/1.5/howto/custom-management-commands/

or you can just use Django as you would any other python library, as
long as you configure it first:

https://docs.djangoproject.com/en/1.5/topics/settings/#using-settings-without-setting-django-settings-module

Cheers

Tom

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




Re: Scripts to update Django tables

2013-05-29 Thread C. Kirby
Django models instances are python objects and are manipulated as such.

Lets say you had a model:

def Game(Model):
team1 = TextField()
team2 = TextField()
date = DateField()
location = TextField()

In order to create new model instances and save them to a database you 
would do:

import Game

game = Game()
game.team1 = "Mine"
game.team2 = "Yours"
game.date = datetime.today()
game.location = "Game Place"
game.save()

On Wednesday, May 29, 2013 9:01:00 AM UTC-5, Brian wrote:
>
> I'm new to Django (and frameworks in general) and having an issue with a 
> project I'm working on.  Basically, I want to scrape data from a sports 
> league website on a regular schedule and add updated stats into my 
> database.  All of the Django tutorials for models I've looked at seem to 
> give me information on how to add table data manually using the manage.py 
> shell, fixtures, or fields on an admin page, but I cannot find anything 
> about doing this more automatically through a script.  Is there something 
> I'm missing, or am I trying to use Django models for something they aren't 
> meant to be used for? 

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




Re: Scripts to update Django tables

2013-05-29 Thread Avraham Serour
add your script to celery and make the necessary imports so the script can
use your model just like you did in manage shell
take a look at
http://stackoverflow.com/questions/1310495/running-a-python-script-outside-of-django
but in this case I suggest not creating a subcommand as the first answer
says

good luck
avraham


On Wed, May 29, 2013 at 5:01 PM, Brian  wrote:

> I'm new to Django (and frameworks in general) and having an issue with a
> project I'm working on.  Basically, I want to scrape data from a sports
> league website on a regular schedule and add updated stats into my
> database.  All of the Django tutorials for models I've looked at seem to
> give me information on how to add table data manually using the manage.py
> shell, fixtures, or fields on an admin page, but I cannot find anything
> about doing this more automatically through a script.  Is there something
> I'm missing, or am I trying to use Django models for something they aren't
> meant to be used for?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Allow visitor to add a form to a formset

2013-05-29 Thread C. Kirby
It's actually not the most straightforward process. 
Here is a jquery plugin that will help you: 
http://code.google.com/p/django-dynamic-formset/
And here is a way to do it via POST without using javascript: 
http://brantsteen.com/blog/django-adding-inline-formset-rows-without-javascript/


On Wednesday, May 29, 2013 9:47:44 AM UTC-5, Cody Scott wrote:
>
> I have a form with one field for emails.
>
> I would like to allow the visitor to add another email field. What do I 
> need to do to allow the user to create another form?
>
> #following the 
> docshttps://docs.djangoproject.com/en/1.5/topics/forms/formsets/#adding-additional-fields-to-a-formset#I
>  don't see an add field button or instructions on how to create it
> #forms.pyclass BaseEmailFormSet(BaseFormSet):
> def add_fields(self, form, index):
> super(BaseEmailFormSet, self).add_fields(form, index)
> form.fields["email"] = forms.CharField()
>
> class AddMemberEmailForm(forms.Form):
> email = forms.EmailField()
> AddMemberEmailFormSet = formset_factory(AddMemberEmailForm,
> formset=BaseEmailFormSet)
> #views.pyfrom .forms import AddMemberEmailFormSet
> email_formset = AddMemberEmailFormSet()
> if request.method == 'POST':
>   email_formset = AddMemberEmailFormSet(request.POST, request.FILES)
>   if email_formset.is_valid():
> print "valid!"
> # pass 'email_formset': email_formset, to template
> #Template{% csrf_token %}
>   {{email_formset.management_form}}
>   
>{% for form in email_formset %}
>  {{form}}
>{%endfor%}
>   
>name="add_member_email" class="btn btn-info" />
>
>
>

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




Allow visitor to add a form to a formset

2013-05-29 Thread Cody Scott
I have a form with one field for emails.

I would like to allow the visitor to add another email field. What do I 
need to do to allow the user to create another form?

#following the 
docshttps://docs.djangoproject.com/en/1.5/topics/forms/formsets/#adding-additional-fields-to-a-formset#I
 don't see an add field button or instructions on how to create it
#forms.pyclass BaseEmailFormSet(BaseFormSet):
def add_fields(self, form, index):
super(BaseEmailFormSet, self).add_fields(form, index)
form.fields["email"] = forms.CharField()

class AddMemberEmailForm(forms.Form):
email = forms.EmailField()
AddMemberEmailFormSet = formset_factory(AddMemberEmailForm,
formset=BaseEmailFormSet)
#views.pyfrom .forms import AddMemberEmailFormSet
email_formset = AddMemberEmailFormSet()
if request.method == 'POST':
  email_formset = AddMemberEmailFormSet(request.POST, request.FILES)
  if email_formset.is_valid():
print "valid!"
# pass 'email_formset': email_formset, to template
#Template{% csrf_token %}
  {{email_formset.management_form}}
  
   {% for form in email_formset %}
 {{form}}
   {%endfor%}
  
  


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




linking the logged in user to other models to filter query sets -( noobie )

2013-05-29 Thread tony gair


I've done a basic django app with a user which contains an organisation and 
premises foreign key inside the user model which has been inherited using 
the features of django 1.5.

I use the organisation id and premises id inside other models which I would 
like to present themselves providing they are the same.

I have tried to closely follow the 'two scoops of django approach' in that 
I use a CBV with django braces approach to show my models.

It is very important for me only to show the models in the views which use 
either the organisation id or premises id.

At the moment in my  forms.py for my  user it looks like


#forms.py
class HeatingUserForm ( forms.ModelForm):

premises = CustomModelChoiceField(queryset=Premises.objects.all())
organisation = CustomModelChoiceField(queryset=Organisation.objects.all())
class Meta:
model=Heating_User
fields = [ 'username', 'password', 'first_name', 'last_name', 
'email', 'is_staff', 'is_active', 'date_joined', 'jobtitle', 
'organisation', 'premises' ]

***

Unless the user is a super user, I want the organisation to be restricted 
to the organisation that the logged in user is of the same . The premises 
should be restricted to those premises that have the same id as the logged 
in user. 

Can anyone tell me how this is done?

:)

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




Re: No module named wsgi

2013-05-29 Thread Lunga Baliwe
Thanks for your replying, am only seeing your reply now.


On Thu, May 23, 2013 at 7:49 PM, Sandeep kaur  wrote:

> On Thu, May 23, 2013 at 8:29 PM, Luggaz  wrote:
> > I don't know what I dd but it seems to work now!
> >
> mod wsgi installation could have also solved he purpose, using this
> command :
>
> $sudo apt-get install apache2 libapache2-mod-wsgi
>
> --
> Sandeep Kaur
> E-Mail: mkaurkha...@gmail.com
> Blog: sandymadaan.wordpress.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Scripts to update Django tables

2013-05-29 Thread Brian
I'm new to Django (and frameworks in general) and having an issue with a 
project I'm working on.  Basically, I want to scrape data from a sports 
league website on a regular schedule and add updated stats into my 
database.  All of the Django tutorials for models I've looked at seem to 
give me information on how to add table data manually using the manage.py 
shell, fixtures, or fields on an admin page, but I cannot find anything 
about doing this more automatically through a script.  Is there something 
I'm missing, or am I trying to use Django models for something they aren't 
meant to be used for? 

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




Dump LineString GEOM to Point GEOM (One Model To Another)

2013-05-29 Thread kpurdon
Is it possible, outside of using a raw SQL query (PostGIS/PostgreSQL) to do 
a GEOM dump.

I have a table (model) where 1 row is 1 LineString and I need to dump that 
table into another table (model) where 1 row is 1 point from the LineString.

Raw SQL would be something like:

SELECT geom AS points FROM ST_DumpPoints((SELECT fl_line FROM 
greenland.line_paths WHERE ...));

In this case line_paths is the LineString table and fl_line the LineString 
GEOM.

How can I do this within GeoDjango w/o using rawSQL and bypassing the 
models?

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




Tastypie-mongoengine it is possible to filter

2013-05-29 Thread Hélio Miranda
I am using in my application Tastypie-mongoengine, and was trying to do a 
filter on a field with ReferenceListField, is this possible?

Is that here: 
http://django-tastypie-mongoengine.readthedocs.org/en/latest/usage.html
I find nothing

I was trying to use it in my class goal:
filtering = {
 'PlayerClub': ALL_WITH_RELATIONS
}

But without any success.
I wonder if it is possible to make a filter on a field with 
ReferenceListField?

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




Make a raw_id_fields input textbox wider

2013-05-29 Thread Victor
*SORRY My previous message was incomplete ***
I'm trying  to make the input textbox of a raw_id_fields wider than the default 
size  but without success.
Here is what I tried ('codarticolo' is the raw_id_fields):

admin.py
.
class MovimentomagInline(admin.TabularInline):
formfield_overrides = {
models.CharField: {'widget': TextInput(attrs={'size':'30'})},
models.TextField: {'widget': Textarea(attrs={'rows':4, 'cols':40})},
}
widgets = {
'codarticolo': SelectMultiple(attrs={'size': 30})
}

 #   list_display = ('codarticolo', 'numconfezioni', 
'numerounita','totalepezzi')
raw_id_fields = ['codarticolo',]
fields = ('codarticolo', 'numconfezioni', 'numerounita','totalepezzi')
model=Movimentomag
extra=3

What should I do?
Ciao
Vittorio

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




Make a raw_id_fields input textbox wider

2013-05-29 Thread Victor
I'm trying  to make the input textbox of a raw_id_fields wider than the default 
size  but without success.
Here is what I tried ('codarticolo' is the raw_id_fields):

admin.py
.
class MovimentomagInline(admin.TabularInline):
formfield_overrides = {
models.CharField: {'widget': TextInput(attrs={'size':'30'})},
models.TextField: {'widget': Textarea(attrs={'rows':4, 'cols':40})},
}
widgets = {
'codarticolo': SelectMultiple(attrs={'size': 30})
}

 #   list_display = ('codarticolo', 'numconfezioni', 
'numerounita','totalepezzi')
raw_id_fields = ['codarticolo',]
fields = ('codarticolo', 'numconfezioni', 'numerounita','totalepezzi')
model=Movimentomag
extra=3

What should I do?
Ciao
Vittorio

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




Re: Selecting site in admin

2013-05-29 Thread Amirouche Boubekki
Use groups maybe this can help
http://stackoverflow.com/questions/8392780/django-admin-group-permissions-to-edit-or-view-models


2013/5/28 Mário Neto 

> Do you can this in your template
>
>
> 2013/5/28 Victor 
>
>> As a newbye I'm happily using admin.
>>
>> Now I would like to select what a user can see in the admin main page
>> according to its username just as a (non-working) example I would like to
>> follow this idea
>>
>> in admin.py
>>
>> if request.user=='victor':
>>   admin.site.register(Categorie)
>>   admin.site.register(Codiciiva)
>>   admin.site.register(Magazzini)
>> else:
>>   admin.site.register(Marca)
>>   admin.site.register(Fornitori,FornitoriOption)
>>   admin.site.register(Pazienti,PazientiOption)
>>   admin.site.register(unita_misura)
>>
>> How can I do this?
>>
>> Ciao
>> Vittorio
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
> --
> Att. *Mário Araújo Chaves Neto*
> *Programmer, Designer and U.I. Engineer*
> *
> *
> *MBA in Design Digital* - 2008 - FIC
> *Analysis and Systems Development* - 2011 - Estácio
> *D**esign and Implementation of Internet Environments* - 2003 - FIC
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: django database cache for longtime?

2013-05-29 Thread Gonzalo Delgado
El 28/05/13 20:04, kase escribió:
> i need cache a page  where i'm process a lot information
> 
> and i dont wish process again
> and  i dont wish keep in memory RAM, (maybe nobody ever review) 
> 
> so i wish put this page in a database cache but what can i do for never
> expire?

You want to use Redis[0].

There's also this django-redis[1] app that uses Redis as a cache
backend. It allows you to set keys with infinite timeout :-)

[0] http://redis.io/
[1] https://github.com/niwibe/django-redis

-- 
Gonzalo Delgado

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




Tastypie Advanced Filtering

2013-05-29 Thread Hélio Miranda
I am new to using django and tastypie. And I'm trying to make a filter to 
know how many players belong to a club, sending the id of the club, where 
the field in question has a relation to the collection Club

I'm trying this:

Código (Python):
class PlayerResource(resources.MongoEngineResource):
   
PlayerClub = fields.ReferencedListField(of='Rela.Resource.ClubResource',
 attribute='PlayerClub', full=True, null=True)
   
def apply_filters(self, request, applicable_filters):
   base_object_list = super(PlayerResource, self
).apply_filters(request, applicable_filters)
   
   query = request.GET.get('PlayerClub', None)
if query:
qset = (
Q(PlayerClubname__icontains=query)
)
base_object_list = base_object_list.filter(qset).distinct()
   
return base_object_list
   
class Meta:
queryset = Player.objects.all()
allowed_methods = ('get', 'post', 'put', 'delete')
list_allowed_methods = ['get', 'post','put', 'delete']
authorization = Authorization()
#fields = ['id', 'PlayerName', 'PlayerAge']
resource_name = 'Player'
   
filtering = {
#'PlayerClub': ALL_WITH_RELATIONS,
'PlayerAge' : ALL,
'PlayerClub': 'icontains',
}
def determine_format(self, request):
return "application/json"


But it gives me says: 'exact' is not an allowed filter on the 'PlayerClub' 
field.
I do not know if what I'm doing is good or if it makes sense?
My solitação GET is: *
http://localhost:8080/Rela/api/v1/Player?PlayerClub=519dd7b28774a704d4a97748
*

Someone can help me?

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




Re: Object Lookup after Save

2013-05-29 Thread Martin J. Laubach
  Well, that is what repeatable read is supposed to do -- once you do a 
Foo.objects.all() (or whatever) query, re-running the query will give you 
the same result. That's why it's called repeatable read. You have to either 
start a new transaction to break that visibility barrier or not use 
repeatable read in the first place. Which actually sounds like what you 
should be doing as, by the sound of it, gearman does not seem to deal with 
that isolation level very well.

 mjl

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