Re: problem with using suds and sharepoint

2014-12-19 Thread James Schneider
Based on this:

http://schemas.microsoft.com/sharepoint/soap/>schemas.microsoft.com
/sharepoint/soap/
">Item does not exist. It
may have been deleted by another user.

I'm guessing that listItemID number 2 doesn't exist, or the ID of the
parent object isn't specified. I'm not familiar with the WSDL for
SharePoint, but you are referencing an object that currently doesn't exist.

BTW, are you using the suds or suds-jurko version? I would highly recommend
the Jurko version, the original is a bit crusty...should be almost a
drop-in replacement.

https://bitbucket.org/jurko/suds

-James
On Dec 19, 2014 10:09 PM, "Hossein Rashnoo"  wrote:

> I tried to add attachment to a sharepoint document library with this
> command:
>
> result = client.service.AddAttachment("new
> doc","2","ab.ds","QUJDREVGR0hJSktMTU5PUA==")
>
> but i got this error:
>
> DEBUG:suds.client:sending to (
> http://portal:8080/rashno/_vti_bin/lists.asmx)
> message:
> 
> http://schemas.xmlsoap.org/soap/envelope/";
> xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/"; xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"; xmlns:SOAP-ENV="
> http://schemas.xmlsoap.org/soap/envelope/";>
>
>
>   
>  new doc
>  2
>  ab.ds
>  QUJDREVGR0hJSktMTU5PUA==
>   
>
> 
> DEBUG:suds.client:headers = {'SOAPAction': u'"
> http://schemas.microsoft.com/sharepoint/soap/AddAttachment";',
> 'Content-Type': 'text/xml; charset=utf-8'}
> DEBUG:suds.client:http succeeded:
> http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="
> http://www.w3.org/2001/XMLSchema";>soap:ServerException
> of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was
> thrown.http://schemas.microsoft.com/sharepoint/soap/";>Item does not exist. It
> may have been deleted by another
> user.
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.6/site-packages/suds/client.py", line 542, in
> __call__
> return client.invoke(args, kwargs)
>   File "/usr/lib/python2.6/site-packages/suds/client.py", line 602, in
> invoke
> result = self.send(soapenv)
>   File "/usr/lib/python2.6/site-packages/suds/client.py", line 643, in send
> result = self.succeeded(binding, reply.message)
>   File "/usr/lib/python2.6/site-packages/suds/client.py", line 678, in
> succeeded
> reply, result = binding.get_reply(self.method, reply)
>   File "/usr/lib/python2.6/site-packages/suds/bindings/binding.py", line
> 151, in get_reply
> self.detect_fault(soapbody)
>   File "/usr/lib/python2.6/site-packages/suds/bindings/binding.py", line
> 182, in detect_fault
> raise WebFault(p, fault)
> suds.WebFault: Server raised fault: 'Exception of type
> 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.'
>
> please help me, tnx
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ff2f5235-24aa-4f72-a14b-0bb496b9c98d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWwmH2n%2BfQkNYqg2g%2BoE3aeci5jtS9dP1ZMF6WXKF5dvA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


problem with using suds and sharepoint

2014-12-19 Thread Hossein Rashnoo
I tried to add attachment to a sharepoint document library with this 
command:

result = client.service.AddAttachment("new 
doc","2","ab.ds","QUJDREVGR0hJSktMTU5PUA==")

but i got this error:

DEBUG:suds.client:sending to (http://portal:8080/rashno/_vti_bin/lists.asmx)
message:

http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";>
   
   
  
 new doc
 2
 ab.ds
 QUJDREVGR0hJSktMTU5PUA==
  
   

DEBUG:suds.client:headers = {'SOAPAction': 
u'"http://schemas.microsoft.com/sharepoint/soap/AddAttachment";', 
'Content-Type': 'text/xml; charset=utf-8'}
DEBUG:suds.client:http succeeded:
http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>soap:ServerException
 
of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was 
thrown.http://schemas.microsoft.com/sharepoint/soap/";>Item does not exist. 
It may have been deleted by another 
user.
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 542, in 
__call__
return client.invoke(args, kwargs)
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 602, in 
invoke
result = self.send(soapenv)
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 643, in send
result = self.succeeded(binding, reply.message)
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 678, in 
succeeded
reply, result = binding.get_reply(self.method, reply)
  File "/usr/lib/python2.6/site-packages/suds/bindings/binding.py", line 
151, in get_reply
self.detect_fault(soapbody)
  File "/usr/lib/python2.6/site-packages/suds/bindings/binding.py", line 
182, in detect_fault
raise WebFault(p, fault)
suds.WebFault: Server raised fault: 'Exception of type 
'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.'

please help me, tnx

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ff2f5235-24aa-4f72-a14b-0bb496b9c98d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ModelAdmin with inlines: How to learn if/what has changed before the models are saved?

2014-12-19 Thread Collin Anderson
Hi Carsten,

save_model() happens first, then save_related() which calls save_formset() 
on each formset.

It might end up being easier to save the parent model _again_, instead of 
doing something before it's saved.

_has_changed() / has_changed() may come in handy in your case.
https://docs.djangoproject.com/en/dev/ref/forms/fields/#has-changed

Collin

On Thursday, December 18, 2014 12:20:34 PM UTC-5, Carsten Fuchs wrote:
>
> Hi fellow Django developers, 
>
> using a model with several related models, for the Django Admin I have a 
> ModelAdmin that uses several InlineModelAdmin objects, very much as in 
> the example at 
> <
> https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#inlinemodeladmin-objects>.
>  
>
>
> All works well, but when the user clicks the "Save" button in the change 
> view, I would like to find out if anything has changed in the parent 
> model or the related (inline) models, and depending on the result, 
> update one of the parent model's fields before it is saved. 
>
> Can you please tell me how can this be achieved? 
>
>
> In more detail, having read all of 
> https://docs.djangoproject.com/en/1.7/ref/contrib/admin/ and thinking 
> that I have understood most of it, the ModelAdmin methods 
>
>  save_model() 
>  save_formset() 
>  save_related() 
>
> seem to be the right approach to my problem, but are a complete mystery 
> to me: How are the related to each other, and what is their purpose? 
>
> The documentation of all three begins with "The save_* method is given 
> the HttpRequest, ...", but what follows it too sparse for my still 
> limited Django knowledge, and unfortunately I cannot see yet the bigger 
> picture about them, or how to proceed from there. 
>
> Could someone please explain how these methods work, when they are 
> called, etc.? 
>
>
> A huge thanks in advance and best regards, 
> Carsten 
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/98a9aac1-9174-47eb-9ac0-c8ea035bf279%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: change_list html template filter block inject a css class

2014-12-19 Thread Collin Anderson
Hi,

In your custom(?) filter, you could try wrapping your text in , and then in mark_safe(), though be careful with that, 
security-wise.

Honestly, it might be simplest to use Javascript to apply a special class 
after the fact.

Collin

On Thursday, December 18, 2014 9:54:07 AM UTC-5, Damjan Dimitrioski wrote:
>
> Hi,
>
> the following block of code is an excerpt from change_list.html template:
>
> {% block filters %}
>> {% if cl.has_filters %}
>>   
>> {% trans 'Filter' %}
>> 
>>
>>
>> {% for spec in cl.filter_specs %}
>>   {% if "somefilter" in spec|slugify %} 
>> {% admin_list_filter cl spec 
>> %} 
>>   
>>   {% else %}
>> {% admin_list_filter cl spec %}
>>   {% endif %}
>>
>> {% endfor %}
>>   
>> {% endif %}
>>   {% endblock %}
>>
>
> What I'm looking for is to format some 's based on given conditions.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/672b126c-b5f8-487c-8f0d-9c7478d09a82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django ManyToManyField Not Displaying in Template

2014-12-19 Thread Collin Anderson
Hi,

Did you figure it out?

This should work:

{% for p1 in partmodels %}
{% for p2 in p1.partmodel_set %}
{{ p2 }}
{% endfor %}
{% endfor %}

Collin

On Wednesday, December 17, 2014 9:52:19 AM UTC-5, Rodney Lewis wrote:
>
> Hey All:
>
> I need my template to iterate through each PartModel and then iterate 
> through the PartModels associated (through a self-referential 
> ManyToManyField) with the PartModel in question. I am doing everything I'm 
> supposed to be doing according to my reading of the "entry_set syntax" 
> section of the "Making Queries" section of the docs to no avail.
>
> http://stackoverflow.com/questions/27527717/django-manytomanyfield-not-displaying-in-template
>
> Thank you in advance for any assistance!
>
> -- 
> Rodney Lewis
> http://www.youtube.com/pyrodney
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/302e00a8-0ce9-4564-a7bc-86b803b5d022%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django-nocaptcha-recaptcha problem

2014-12-19 Thread Collin Anderson
Hi,

This looks like it could just be a CSS thing. You could try posting your 
issue on the project's github page.

https://github.com/ImaginaryLandscape/django-nocaptcha-recaptcha

Collin

On Wednesday, December 17, 2014 6:08:54 AM UTC-5, Hossein Rashnoo wrote:
>
>
> Hi, I use *django-nocaptcha-recaptcha* in my site and it worked perfect. 
> But after that i tried several times for fill a form , google not recognize 
> me as human with a click and tried to show me a challenge image. *The 
> problem is **challenge image not appear.*I attached the photo of this 
> problem.
> Sorry for bad English.
>
>
> 
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0e11c120-4545-4d4f-97da-0c277a6594a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: CSRF Failing after server upgrade.

2014-12-19 Thread Collin Anderson
Hi Ed,

Did you figure it out?

Is your login page getting cached? The CSRF token is re-generated after a 
successful login, so if you click "login" twice or hit back after a 
successful login, it won't work.

Do you happen to know, specifically, which django versions you upgraded 
from/to?

Collin

On Tuesday, December 16, 2014 4:36:56 PM UTC-5, Ed Rahn wrote:
>
> Hello,
> I get CSRF 403 errors intermittently while logging in. If I remove just 
> the cookies for the site, it doesn't fix it. If I remove all the cookies on 
> the browser or start in an incognito mode tab it works. Also some first 
> time users get the error
> Only my clients seem to be getting this, I have not been able to reproduce 
> it locally.
>
> This started happening after I upgraded from Ubuntu 14.04 to 14.10.
>
> Can anyone help me debug this?
>
> thanks
> Ed
>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5e5613ec-3017-4fdc-bcc2-9407b92ce5ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model form with optional fields issue

2014-12-19 Thread Carl Meyer
Hi Marcin,

On 12/19/2014 11:44 AM, marcin.j.no...@gmail.com wrote:
> Hello!
> 
> I have model form defined with all optional fields (required=False).
> I want use this form to update only provided fields leaving others 
> unchanged.
> But Django replaces optional fields to empty values and removes data from 
> models.
> 
> 
> A short example:
> 
> class MyForm(forms.ModelForm):
> class Meta:
> model = User
> fields = ('username', 'email')
> 
> def __init__(self, *args, **kw):
> super(MyForm, self).__init__(*args, **kw)
> for field in self.fields.values():
> field.required = False
> 
> 
> In [21]: admin = User.objects.get(username='admin')
> 
> *In [22]: admin.email*
> *Out[22]: u'ad...@example.com'*
> 
> In [23]: form = MyForm(data={'username': 'admin'}, instance=admin)
> 
> In [24]: form.is_valid()
> Out[24]: True
> 
> In [25]: form.save()
> Out[25]: 
> 
> In [26]: admin = User.objects.get(username='admin')
> 
> *In [27]: admin.email*
> *Out[27]: u''*
> 
> In my opinion this is big, fat, ugly bug or a design misconception.  
> If something is not provided does not mean that someting does not exist!
> Django should skip updating these unprovided fields by removig them from 
> cleaned_data dict. 
> 
> You can even try to save this form without data (ok with data, but with 
> unknown keys):
> 
> form = MyForm(data={'unknownfield': 'some-value'}, instance=admin)
> form.is_valid()
> 
> # form.cleaned_data has empty strings
> 
> form.save()
> 
> 
> Username and email will be replaced with empty strings. 
> Where is admin?, you'll ask... And you'll hear a strange voice - "admin is 
> cooking borscht with ravioli, dude!"
> 
> What do you think - is this expected? 

Yes, this is expected. Django's form system is designed for use with
HTML forms, which do not provide partial data: unchanged field values
are sent too, so this problem does not occur.

That in itself wouldn't prevent switching to the behavior you want,
except that it is not compatible with how checkboxes are handled in HTML
forms. If a checkbox is unchecked, the browser will not send that
checkbox's name in the submitted POST data at all. So with the behavior
you're asking for, it would be impossible to ever change a boolean field
represented by a checkbox from True to False, using an HTML form.

Carl

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54947F2F.9030304%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Model form with optional fields issue

2014-12-19 Thread marcin . j . nowak
Hello!

I have model form defined with all optional fields (required=False).
I want use this form to update only provided fields leaving others 
unchanged.
But Django replaces optional fields to empty values and removes data from 
models.


A short example:

class MyForm(forms.ModelForm):
class Meta:
model = User
fields = ('username', 'email')

def __init__(self, *args, **kw):
super(MyForm, self).__init__(*args, **kw)
for field in self.fields.values():
field.required = False


In [21]: admin = User.objects.get(username='admin')

*In [22]: admin.email*
*Out[22]: u'ad...@example.com'*

In [23]: form = MyForm(data={'username': 'admin'}, instance=admin)

In [24]: form.is_valid()
Out[24]: True

In [25]: form.save()
Out[25]: 

In [26]: admin = User.objects.get(username='admin')

*In [27]: admin.email*
*Out[27]: u''*

In my opinion this is big, fat, ugly bug or a design misconception.  
If something is not provided does not mean that someting does not exist!
Django should skip updating these unprovided fields by removig them from 
cleaned_data dict. 

You can even try to save this form without data (ok with data, but with 
unknown keys):

form = MyForm(data={'unknownfield': 'some-value'}, instance=admin)
form.is_valid()

# form.cleaned_data has empty strings

form.save()


Username and email will be replaced with empty strings. 
Where is admin?, you'll ask... And you'll hear a strange voice - "admin is 
cooking borscht with ravioli, dude!"

What do you think - is this expected? 


/Marcin

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2d75eb34-1b5f-4cde-aba8-497802a3412a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Revisiting the case-sensitive login for the default user manager

2014-12-19 Thread Roman Onosovski
Hello fellow Djangoers, I am new to the framework and just recently built a 
site using it.
However I was not aware of the username hurdle until just recently.
I did some research and found that I can make my own user manager and etc.

Now this is probably a bit of a hack, but tell me what you think.

I am on 1.6.5 and I did this: 

from:

def get_by_natural_key(self, username):
return self.get(**{self.model.USERNAME_FIELD: username})

to:

def get_by_natural_key(self, username):
return self.get(username__iexact=username)

It works and does what I need it to do. How illegal is this and what 
potential problems can this create that I may not see now?

Thanks guys

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6dc608fc-7ddb-4e29-a2d0-f1d471766ab7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Optimizing has_perm query time on PERMISSION AND GROUP PERMISSION

2014-12-19 Thread aRkadeFR

Hey mohd,

How do you know the CPU burnt come from the method has_perm?
Did you dump the query and play it again?

It's most likely to be something else FMPOV. The has_perm is just a simple
query in DB...

aRkadeFR

On 12/18/2014 05:27 PM, mohd irshad wrote:

Hello ,
I am constantly facing face max cpu usage problem because of few 
database (postgres) heavy query has_perm is one of them.


how can I optimized such query.
--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/525f6423-f10b-40f7-8514-d3b5af225d96%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54942F0E.2010003%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Raw access to cache table

2014-12-19 Thread Erik Cederstrand

> Den 18/12/2014 kl. 12.20 skrev Erik Cederstrand :
> 
> Hi list,
> 
> I'm using Django as a hub to synchronize data between various external 
> systems. To do this, I have some long-running Django management commands that 
> are started as cron jobs. To ensure that only one job is working on a data 
> set at any one time, I have implemented a locking system using the Django 
> cache system.
> 
> Due to my less-than-stellar programming talent, a cron job may need to be 
> killed once in a while. To avoid leaving orphaned locks in the cache, I want 
> to clean up any locks before exiting, and I may not know which cache keys 
> exist at the time of exit. Therefore, I want to write a signal handler that 
> searches the Django cache for any entries that can be traced to the current 
> process (my cache keys can be used for this purpose) and delete those.
> 
> AFAICS, the Django cache API can't be used for this. There's cache.clear() 
> but I don't want to delete all cache entries. I'm using the database backend, 
> so I'm thinking I could access the database table directly and issue any 
> custom SQL on that. But it does feel hackish, so maybe one of you have a 
> better approach? Maybe I got the whole thing backwards?

Just to wrap this up, I wrote a function to get all or some cache entries. Most 
of the code is copy-paste from django.core.cache.backends.db.


def get_cache_entries(key_prefix=None):
db = router.db_for_read(cache.cache_model_class)
table = connections[db].ops.quote_name(cache._table)
with connections[db].cursor() as cursor:
sql = "SELECT cache_key, value FROM %s" % table
params = None
if key_prefix:
sql += " WHERE cache_key LIKE %s"
params = (key_prefix + '%',)
cursor.execute(sql, params=params)
rows = cursor.fetchall()
res = {}
for row in rows:
value = connections[db].ops.process_clob(row[1])
res[row[0]] = pickle.loads(base64.b64decode(force_bytes(value)))
return res


Erik

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0A0F1930-E3B1-4CB1-B67A-206D706ECF98%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: Database queries location

2014-12-19 Thread aRkadeFR

Depend exactly on what to compute for your post data.

I would almost write no logic code in the views.

I split every application as follow:
- managers.py: All the logic as a table level (raw SQL, complex queries)
- models.py: All logic as a row level / object level (python computing data)
- forms.py: All logic as forms data / processing / validation for 
request data


Have a good one,

aRkadeFR

On 12/18/2014 10:12 PM, pythonista wrote:

I understand that functions can be placed in the models fille

However if I have complex queries that receive post input does the


Query live in the model  the views or an external module



--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54941478.4060102%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Select a single field from database (postgresql)

2014-12-19 Thread aRkadeFR

Hello Cássio,

You first need to map your cars table with a Model in Django
(https://docs.djangoproject.com/en/1.7/topics/db/models/),
then you can construct your query something like this:

Car.objects.order_by('-registered').last()

Check out the documentation on queries here:
https://docs.djangoproject.com/en/1.7/topics/db/queries/

Have a good one,

aRkadeFR


On 12/19/2014 12:51 PM, Cássio Van Helden Gameiro wrote:
Hi, i have a database with many cars, and i want to select the last 
car based the hour that it was registered, can someone help me?


Thanks.
--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fecb3393-d336-4aa8-8058-f6bbf9cfbfc4%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54941319.9040806%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Re: Can't open manage.py

2014-12-19 Thread Guilherme Leal
Are you sure that your shell is running on the same folder that contains
the manage.py?

Em Fri Dec 19 2014 at 09:53:05, Valéria Pacheco 
escreveu:

> I ran this command $ python manage.py migrate
>
> and the following error occurs
>
> python: can't open file 'manage.py': [Errno 2] No such file or directory
>
>
> The file exists though.
>
>
>  --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/26f2a151-f068-4a0b-bc97-97671401a6d0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOs3Lp6CknRuvhJ2nPZ2RKt4BbFbHWjW20NjFEdwfs4MMK8x%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Can't open manage.py

2014-12-19 Thread Valéria Pacheco


I ran this command $ python manage.py migrate 

and the following error occurs

python: can't open file 'manage.py': [Errno 2] No such file or directory


The file exists though.


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/26f2a151-f068-4a0b-bc97-97671401a6d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Select a single field from database (postgresql)

2014-12-19 Thread Cássio Van Helden Gameiro
Hi, i have a database with many cars, and i want to select the last car 
based the hour that it was registered, can someone help me?

Thanks.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fecb3393-d336-4aa8-8058-f6bbf9cfbfc4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7 not working with mysql-connector-python 1.1.6 & Python 3.3 ?

2014-12-19 Thread Felipe Serrano
Same problem, your Fix works great!... Thanks, using

MacOS 10.7, Django 1.7, DjanogCMS3, Python 3.4.2

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eb800b8b-8bd9-4aab-89af-8ecaa680626d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.