Re: Self referencing models initialization

2014-03-13 Thread Erik Cederstrand
Den 13/03/2014 kl. 06.34 skrev Santiago Palacio Gómez :

> Hi everyone,
> 
> I'm a Django newbie, and I was following the tutorial for 1.6, creating a new 
> app where one of the models is self-referencing. They ask to, in manage.py 
> shell, create an instance of the model. But, as my model has a self reference 
> foreign key, I can't pass any object to the key. I also would not like to 
> leave it Nullable, as it may cause errors. Rather, I'd just like to pass 
> 'self' as the reference, this is, the key it references should be its self 
> key.
> 
> Is it possible? Thanks in advance!

What is meant in the tutorial is most definitely not that the model 'instance' 
should reference itself, but rather that the instance should reference another 
instance of the same type, i.e. a parent-child relationship. Something like:

class Person(models.Model):
  mother = models.ForeignKey('self', null=True)
  father = models.ForeignKey('self', null=True)

You need to keep the field nullable because something must be root of the 
relationship structure (unless you want to create only cyclic relationships, 
which is not recommended for family structures...). To create a relationship do 
this:

eve = Person.objects.create()
adam = Person.objects.create()
abel = Person.objects.create(mother=eve, father=adam)


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/23D801C1-ED14-40B2-B241-588FD3F29709%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.


Re: django.utils.html.smart_urlquote() is incorrectly unquoting embedded url?

2014-03-13 Thread Md. Enzam Hossain
Ticket filed - https://code.djangoproject.com/ticket/22267#ticket

On Wednesday, March 12, 2014 6:03:30 PM UTC, Erik Romijn wrote:
>
> Hello, 
>
> On 12 Mar 2014, at 17:48, Md. Enzam Hossain > 
> wrote: 
> > When we give django.utils.html.smart_urlquote() an url with an already 
> embedded query as a query paramater, it is unquoting it which it should not 
> do. 
>
> At first sight, this appears to be an intended behaviour. See <
> https://github.com/django/django/blob/master/django/utils/html.py#L203> 
> and the link mentioned in the comment. 
>
> If you still believe that this is a bug, it would be best to create a 
> ticket:  so that we can track 
> it and take a closer look. 
>
> cheers, 
> 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/e5be4945-e8d8-49eb-94cf-f218187f7327%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Best way to implement translations overrides ?

2014-03-13 Thread Alessandro Pasotti
Hi,

I'm running a multi-site Django application, with SITE_ID hack to set the
correct site on each request based on hostname.

I'd like to add per-site translations overrides like this:

* middleware set SITE_ID
* each SITE_ID can have custom translations stored in a DB table
* when _() is called, the DB table is queried for SITE_ID, LANG_CODE and
the translation string
* if a record is returned that tranlation is used instead of the "normal"
translations (the one stored in language folder)

Is this possible?

Any hint would be highly appreciated.

-- 
Alessandro Pasotti
w3:   www.itopen.it

-- 
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/CAL5Q670O6a67hr1CN11MUGcrd9sizYgb7jj%3DvQJHs1tJdyTiQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Log django database queries using logging

2014-03-13 Thread Anju SB
Dear All,

  I  am a newbie in Django programming. I want to log insert, update, 
delete and failed select query in my daily log file. I configured 
'django.db.backends' in the logger of the Logging dict in Settings.py. But 
I get all the queries in that application. I need only insert, update, 
delete and failed select queries.

Please help me

Thanking you

 Anju

-- 
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/4b34ac77-5a38-46e1-875e-f74c600c7e08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django "CSRF cookie not set" question

2014-03-13 Thread Xin Kuo
Hi, 
 I am developing a management system by django 1.6.  Using django + wsgi + 
apache to implement this project, there are some html on the one directory, 
angularjs $http use "POST" mehtod to visit the django web url to get some 
data (django web url on the other directory). 

front end angularjs code:
tagManControllers.controller('loginController', ['$scope', '$http', 
'$window', '$cookies',
function($scope, $http, $window, $cookies){

$scope.login = function(){

 
//call the remote service
var passwd_md5 = CryptoJS.MD5($scope.password);

$http({method: 'GET', url: login_url + $scope.name + '&p=' + 
passwd_md5})
.success(function(data, status, headers, config){

if (data.result == '200'){

var tmp_url = data.link;
$cookies.csrftoken = data.token; //get cookie from 
server
$window.location.href = tmp_url;
}
else{

$window.alert(tmp_info);
}

})
.error(function(data, status, headers, config){
   
});
return true;
};
}]);
 
backend python:
   result['token'] = request.META['CSRF_COOKIE']
jsonReturn = json.dumps(result, indent=4)
response = HttpResponse(jsonReturn, content_type="application/json", 
status=200)


"post" method frontend code:
 $scope.addTag = function(){

var json_string = JSON.stringify($scope.tag_);
var csrftoken = $cookies.csrftoken;

$http({method:'POST', url: add_tags_url + json_string, 
headers:{'X-CSRFToken': csrftoken}})
.success(function(data){

if(data.result != '200'){
   
$window.alert(tmp_info);
}
})
.error(function(data){

 
});
};

return error info:
Forbidden (403)

CSRF verification failed. Request aborted.
Help

Reason given for failure:

CSRF cookie not set.

In general, this can occur when there is a genuine Cross Site Request 
Forgery, or when Django's CSRF 
mechanism
 has 
not been used correctly. For POST forms, you need to ensure:

   - Your browser is accepting cookies.
   - The view function uses 
RequestContext
 for 
   the template, instead of Context.
   - In the template, there is a {% csrf_token %} template tag inside each 
   POST form that targets an internal URL.
   - If you are not using CsrfViewMiddleware, then you must use csrf_protect on 
   any views that use the csrf_token template tag, as well as those that 
   accept the POST data.

You're seeing the help section of this page because you have DEBUG = True in 
your Django settings file. Change that to False, and only the initial error 
message will be displayed.

You can customize this page using the CSRF_FAILURE_VIEW setting.





-- 
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/ec748562-4220-42d2-9448-f4f44cd09cfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Gunicor + Postgres + Python 3

2014-03-13 Thread John Deng
Hi, Henrique.

Did you config the url.py?

在 2014年3月10日星期一UTC+8下午12时14分18秒,Henrique Oliveira写道:
>
> Hi there,
>
> I have set Django + gunicorn + python 3 in a production env, but I am 
> gettin critical timeout on simple request(home).
> Any Ideas?
>
> 14-03-09 23:11:21 [14029] [INFO] Listening at: http://127.0.0.1:8001(14029)
> 2014-03-09 23:11:21 [14029] [INFO] Using worker: sync
> 2014-03-09 23:11:21 [14039] [INFO] Booting worker with pid: 14039
> 2014-03-09 23:11:21 [14040] [INFO] Booting worker with pid: 14040
> 2014-03-09 23:11:21 [14041] [INFO] Booting worker with pid: 14041
> 2014-03-09 23:11:31 [14040] [DEBUG] GET /done
> 2014-03-09 23:12:02 [14029] [CRITICAL] WORKER TIMEOUT (pid:14040)
> 2014-03-09 23:12:02 [14029] [CRITICAL] WORKER TIMEOUT (pid:14040)
>
> Cheers
>

-- 
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/cc625db9-a6bf-4194-8c64-f5e6a5a4836c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Logging database queries

2014-03-13 Thread Anju SB
Dear All,

I am a newbie in Django programming and developing a web application using 
django 1.3 and postgresql.  I want to log insert, update, delete and failed 
select queries in my daily log file.  I configured  'django.db.backends' in 
the logger of the Logging dict in Settings.py.   But I get all the queries 
in that application. I need only insert, update, delete and failed select 
queries. 

Please help me to move on 

Thanking you 
Anju 

-- 
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/f5d6457e-9b23-4395-86c0-89f673689d46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Self referencing models initialization

2014-03-13 Thread Santiago Palacio Gómez
Ok, just did that and it worked (had to delete and re-create the db). Thank 
you very much for your quick reply.

One last question though, just for curiosity, is there no way to create 
such cyclic relationships? If so, how?


El jueves, 13 de marzo de 2014 03:41:05 UTC-5, Erik Cederstrand escribió:
>
> Den 13/03/2014 kl. 06.34 skrev Santiago Palacio Gómez 
> >: 
>
>
> > Hi everyone, 
> > 
> > I'm a Django newbie, and I was following the tutorial for 1.6, creating 
> a new app where one of the models is self-referencing. They ask to, in 
> manage.py shell, create an instance of the model. But, as my model has a 
> self reference foreign key, I can't pass any object to the key. I also 
> would not like to leave it Nullable, as it may cause errors. Rather, I'd 
> just like to pass 'self' as the reference, this is, the key it references 
> should be its self key. 
> > 
> > Is it possible? Thanks in advance! 
>
> What is meant in the tutorial is most definitely not that the model 
> ‘instance’ should reference itself, but rather that the instance should 
> reference another instance of the same type, i.e. a parent-child 
> relationship. Something like: 
>
> class Person(models.Model): 
>   mother = models.ForeignKey(’self', null=True) 
>   father = models.ForeignKey(’self', null=True) 
>
> You need to keep the field nullable because something must be root of the 
> relationship structure (unless you want to create only cyclic 
> relationships, which is not recommended for family structures...). To 
> create a relationship do this: 
>
> eve = Person.objects.create() 
> adam = Person.objects.create() 
> abel = Person.objects.create(mother=eve, father=adam) 
>
>
> 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/acbebc7a-60c5-4950-a3ac-51af5b34bc0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Self referencing models initialization

2014-03-13 Thread Shawn Milochik
On Thu, Mar 13, 2014 at 1:07 PM, Santiago Palacio Gómez
wrote:

> Ok, just did that and it worked (had to delete and re-create the db).
> Thank you very much for your quick reply.
>
> One last question though, just for curiosity, is there no way to create
> such cyclic relationships? If so, how?
>

You can always make a relationship cyclical after the fact by just
populating the foreign key field. You just can't have it required, because
then you have a chick-and-egg problem. It's possible you could make it work
by deferring the commit using commit=False [1], but overall it's probably a
bad idea.

[1]
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method

-- 
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/CAOzwKwHwnBTTHgabZArwBJUb1PrhHznr%2BgMqbvZdZ5_nXbaaBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Self referencing models initialization

2014-03-13 Thread Santiago Palacio Gómez
I see, nice tip. Thanks!

El jueves, 13 de marzo de 2014 12:35:48 UTC-5, Shawn Milochik escribió:
>
> On Thu, Mar 13, 2014 at 1:07 PM, Santiago Palacio Gómez 
> 
> > wrote:
>
>> Ok, just did that and it worked (had to delete and re-create the db). 
>> Thank you very much for your quick reply.
>>
>> One last question though, just for curiosity, is there no way to create 
>> such cyclic relationships? If so, how?
>>
>
> You can always make a relationship cyclical after the fact by just 
> populating the foreign key field. You just can't have it required, because 
> then you have a chick-and-egg problem. It's possible you could make it work 
> by deferring the commit using commit=False [1], but overall it's probably a 
> bad idea.
>
> [1] 
> https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-save-method
>  

-- 
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/295c0912-76e3-480e-b670-f69f758fd269%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django not showing css - static files

2014-03-13 Thread Mike Dewhirst

On 14/03/2014 9:05am, Luggaz wrote:

Good day,

My static files are not showing on production, they show when I run them
development mode. I am running Django1.6 on apache,mod_wsgi. I get the
not found error on the files.


Have you copied all your static files into STATIC_ROOT ??



I have been on it for hours and have tried changing and tweaking
STATIC_ROOT and STATICFILES_DIR

I have attached 3 images, the apache file, and the difference between
the dev and the production screenshot.

Regards
Lunga

--
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/dcfa6c8e-9183-45ec-bfcf-74b5db3910c9%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/532237E0.7040001%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


ForeignKey Field does not exist?

2014-03-13 Thread wasingej
I am trying to develop a web interface in Django which manages email 
lists.  In one table, ListEntry, I have entries containing information 
about lists.  In another table, OwnerEntry, I have information about list 
owners.  Each entry in the OwnerEntry table has the username of a list 
owner, and a ForeignKey to the list that owner administrates.  An owner can 
administrate multiple lists meaning that there could be entries in the 
OwnerEntry table with the same owner name but different ForeignKeys 
pertaining to different lists.

Here is models.py:

class ListEntry(models.Model):
name = models.CharField(max_length=64)
date = models.DateTimeField('date created')

class Meta:
ordering = ('name',)

class OwnerEntry(models.Model):
name = models.CharField(max_length=32)
list = models.ForeignKey(ListEntry)

class Meta:
ordering = ('name',)

I am trying to test this setup out in the shell and initiallize my local 
database with the following code:

from list_app.models import *
from datetime import *

le1 = ListEntry(
name = "Physics 211 email list",
date = datetime.now(),
)
le1.save()

le2 = ListEntry(
name = "Physics 265 email list",
date = datetime(2014,1,1),
)
le2.save()

oe1 = OwnerEntry(
name = 'wasingej',
list = le1,
)
oe1.save()

oe2 = OwnerEntry(
name = 'wasingej',
list = le2,
)
oe2.save()

oe3 = OwnerEntry(
name = 'doej',
list = le2,
)
oe3.save()

When I go to grab information about the list with 'l = 
OwnerEntry(name='wasingej')', intuition would tell me that 'l' would be a 
list of entries with the name 'wasingej'.  However, when I try to access 
the value of 'l.list' django gives me this:

Traceback (most recent call last):
  File "", line 1, in 
  File 
"/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py", 
line 324, in __get__
"%s has no %s." % (self.field.model.__name__, self.field.name))
DoesNotExist: OwnerEntry has no list.

What am I doing wrong here?

-- 
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/54a3d6d7-58f6-4f97-b1ee-d8f18516b405%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ForeignKey Field does not exist?

2014-03-13 Thread Shawn Milochik
On Thu, Mar 13, 2014 at 7:27 PM, wasingej wrote:

>
> When I go to grab information about the list with 'l =
> OwnerEntry(name='wasingej')', intuition would tell me that 'l' would be a
> list of entries with the name 'wasingej'.  However, when I try to access
> the value of 'l.list' django gives me this:
>
>
You want: records = OwnerEntry.objects.filter(name='wasingej')

-- 
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/CAOzwKwG_yppdZqFuNR_TOtR_a8Ak6k753cU5pH4W-h3EfFKZOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: problem with integrating bootstrap 3.1.1 and django 1.6

2014-03-13 Thread Camilo Torres

On Sunday, March 9, 2014 3:59:02 PM UTC-4:30, rafiee.nima wrote:
>
> On Sunday, March 9, 2014 10:29:37 PM UTC+3:30, Camilo Torres wrote:
>>
>> On Sunday, March 9, 2014 12:11:11 PM UTC-4:30, rafiee.nima wrote:
>>>
>>> I am new to bootstarp and I want to use it in my django project.
>>> I put the needed folder's(css , js , img) in my project static folder 
>>> and config my setting.py to access static directory
>>> I can access bootstrap.css from 
>>> http:///..myprojecet/static/bootstrap.css which means I correctly config 
>>> setting.py
>>> but the problem is that no bootstrap style applied to my temeplates. (I 
>>> also check in  firebug if css and js files been inclueded )
>>>
>>> here is my base.html code that other templates inhierent from it
>>>
>>> {% load static %}
>>> 
>>> 
>>> 
>>> 
>>> 
>>>  >> media="screen">
>>> 
>>>  
>>> 
>>> 
>>>   Dropup
>>>   >> data-toggle="dropdown">
>>> 
>>> Toggle Dropdown
>>>   
>>>   
>>>   
>>> 
>>> {% block body_block %}
>>> {% endblock %}
>>>
>>> 
>>> 
>>> 
>>> 
>>>
>> Hello,
>>
>> This URL looks bad:  http:///..myprojecet/static/bootstrap.css
>> What is in your settings.py?
>> Should it be: {% static 'bootstrap.min.css'% }?
>>
>
>
> tnx for reply 
> the actual ulr was http://127.0.0.1:8000/static/css/bootstrap.min.csswhich I 
> use to test if I correctly configure static path and url in my 
> setting.py 
> I attached my setting.py  
>
Hello,

Your configuration seems OK to serve static content from withing 
application directories.

Where in the file system are you putting your static file 
(css/bootstrap.min.css)?

Try this:
if you already have an application, use that, else create one like this:

python manage.py startapp testapp

Inside the newly created test app directory, create static/css/ and put 
your file there. Now try to reload your template to see if the template 
loads.

This may make it work for you, but in your case, is not the final solution. 
You may need to actually put these static files that are 'site global' in a 
central location in your filesystem, let's say: /var/www/static/(css|js|etc)

To do that, you need to add a setting to your settings.py:

STATICFILES_DIRS = (
'/var/www/static/',)

That way you put all of your static site wide files inside subdirectories 
in a common path.

Regards,
Camilo

-- 
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/37c0d7de-776b-4078-b915-b66235f934a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Log django database queries using logging

2014-03-13 Thread Russell Keith-Magee
Hi Anju,

Firstly - if you want to filter log messages that meet a specific
criterion, you can install a filter into your logging configuration. Python
and Django's logging documentation both contain sections about filtering:

http://docs.python.org/2/library/logging.html#filter-objects
https://docs.djangoproject.com/en/dev/topics/logging/#id4

Secondly - I'd be questioning whether Django is the right place to be
logging this. Your database also has logging capabilities; I'd be looking
to see whether you can configure your database to produce the logs you need.

Yours,
Russ Magee %-)



On Thu, Mar 13, 2014 at 3:18 PM, Anju SB  wrote:

> Dear All,
>
>   I  am a newbie in Django programming. I want to log insert, update,
> delete and failed select query in my daily log file. I configured
> 'django.db.backends' in the logger of the Logging dict in Settings.py. But
> I get all the queries in that application. I need only insert, update,
> delete and failed select queries.
>
> Please help me
>
> Thanking you
>
>  Anju
>
> --
> 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/4b34ac77-5a38-46e1-875e-f74c600c7e08%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/CAJxq84-qxE9uSb_nt1YF-QyeFySmg7emTv0GPeay2dK0EoVZgw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Documentation of modules

2014-03-13 Thread Camilo Torres
Hello,

I don't know of the existence of that reference documentation. You can try 
the source code documentation:
https://github.com/django/django

On Wednesday, March 12, 2014 4:13:38 AM UTC-4:30, Christian Waterkeyn wrote:
>
> Thanks.
> But this is not reference documentation!
> For example, the link django.core.management points to information for 
> "Writing custom django-admin commands"
> What I am looking for is the documentation of the classes, methods and 
> properties in the management module. This is visible in the link I gave in 
> my initial message, but I want something up-to-date, and certified by 
> djangoproject.
>
> UTC+1, C. Kirby a écrit :
>>
>> There is a link to the module index on the django project site.
>> Direct link: https://docs.djangoproject.com/en/1.6/py-modindex/
>>
>> On Tuesday, March 11, 2014 11:33:24 AM UTC-5, Christian Waterkeyn wrote:
>>>
>>> Hello,
>>>
>>> I am looking for a reference documentation of the django modules.
>>> For example django.core.management
>>> I found by google the url: 
>>> http://docs.nullpobug.com/django/trunk/django.core.management-module.html
>>> But I am not sure it is up-to-date, and surprised not to find it inside 
>>> the djangoproject.com site
>>>
>>> Where is the best place to browse the modules reference documentation?
>>>
>>> Thank you for your help!
>>>
>>> Christian
>>>
>>

-- 
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/2332b18d-2a70-41a2-a381-d3fba379d2df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Log django database queries using logging

2014-03-13 Thread Anju SB

Thank You Mr. Russell Keith-Magee.

I want to log other details regarding the application.  So I selected the 
django logging.  

LOG_URL =  '/var/log/Crime_Mapping/'
 
import logging

class CustomQueryFilter(logging.Filter):
def filter(self, record):
for action in ['INSERT', 'UPDATE', 'DELETE']:
if action in getattr(record, 'sql', ''):
return True
return False
 

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse',
},
'db_query_filter': {
'()': CustomQueryFilter,
},
},
'formatters': {
'verbose': {
'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] 
%(module)s %(process)d %(thread)d %(message)s",
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'file':{
'level': 'DEBUG',
'filters': ['db_query_filter'],
'class': 'logging.FileHandler',
'filename': LOG_URL+'crime_log.log',
'formatter': 'verbose'
},

},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'my_logger': {
'handlers': ['file'],
'level': 'DEBUG',
},
'django.db': {
'level': 'DEBUG',
'handers': ['file'],
'filters': ['db_query_filter'],
'propagate': True,
},

}
} 


But i get all queries in my log file



 

On Friday, 14 March 2014 08:25:38 UTC+5:30, Russell Keith-Magee wrote:
>
> Hi Anju,
>
> Firstly - if you want to filter log messages that meet a specific 
> criterion, you can install a filter into your logging configuration. Python 
> and Django's logging documentation both contain sections about filtering:
>
> http://docs.python.org/2/library/logging.html#filter-objects
> https://docs.djangoproject.com/en/dev/topics/logging/#id4
>
> Secondly - I'd be questioning whether Django is the right place to be 
> logging this. Your database also has logging capabilities; I'd be looking 
> to see whether you can configure your database to produce the logs you need.
>
> Yours,
> Russ Magee %-)
>
>
>
> On Thu, Mar 13, 2014 at 3:18 PM, Anju SB  >wrote:
>
>> Dear All,
>>
>>   I  am a newbie in Django programming. I want to log insert, update, 
>> delete and failed select query in my daily log file. I configured 
>> 'django.db.backends' in the logger of the Logging dict in Settings.py. But 
>> I get all the queries in that application. I need only insert, update, 
>> delete and failed select queries.
>>
>> Please help me
>>
>> Thanking you
>>
>>  Anju
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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/4b34ac77-5a38-46e1-875e-f74c600c7e08%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/8e2bc20e-276a-4cdc-a282-aa783e0998f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.