Re: delete obsolete content type entries...

2013-02-10 Thread vijay shanker
we can delete all obsolete ContentType entries manually.
>>>for each in ContentType.objects.filter(app_label=appname): each.delete()
 thanks

On Friday, May 4, 2007 8:42:51 PM UTC+5:30, Jens Diemer wrote:
>
>
> I have delete some app models. So, in the internal django tables 
> "django_content_type" and "auth_permission" are some old content types 
> entries.
>
> So i received errors like: "ContentType matching query does not exist." 
> (When i create a new user group).
>
> Is there a way to update the django tables automatically?
>
> -- 
> Mfg.
>
> Jens Diemer
>
>
> 
> A django powered CMS: http://www.pylucid.org
>
>

-- 
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: Problems doing ajax post with ImageField

2013-02-10 Thread Jani Tiainen

Hi,

There is no way to save files through XHR, (not at least without HTML5 
features).


One quite common approach is to use temporary, hidden iframe where form 
is duplicated along the filefield and then submit that form as normal 
page submit and then to read response one way or another.


I don't know exact procedure how that works in jquery but maybe this 
helps: http://bit.ly/11AA3dW


11.2.2013 0:28, bobhaugen kirjoitti:

Here's the relevant parts of the model:

class Resource(models.Model):
 photo = ThumbnailerImageField(_("photo"),
 upload_to='photos', blank=True, null=True)

This works fine in admin and with regular form posts.

Trying to use jquery.post in one situation to post a photo without
suffering a page reload.

With the regular post, the photo field returns like this (in
form.cleaned_data):
'photo': 

And request.FILES is like this:
]}>

With the jquery post, photo is None and the MultiValueDict is empty.

In both cases the form is set up with enctype="multipart/form-data",
and the form is instantiated in the view with
form = ResourceForm(request.POST, request.FILES)

What am I doing wrong?

Here's the javascript:

$("#detailForm").submit(function(event) {
event.preventDefault();

var $form = $( this ),
url = $form.attr( 'action' );

var formData = $form.serialize();
saveResource(url, formData);

});

function saveResource(url, formData)
{
notifySaving();
var jqxhr = $.post( url, formData,
function( data ) {
$('#detailModal').modal('hide');
notifySaved();
resourceSaved = true;
})
.fail(function()
{
$('#detailModal').modal('hide');
notifyProblem();
resourceSaved = false;
startRetrying();
}
);
}

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





--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: how to render data coming from server to template using ajax!

2013-02-10 Thread mulianto
hi,

the basic is the same with full html site, except in ajax you only render part 
of your html output.

so in ajax you can use ajax call the target url, and the output from the html 
output is display in the div specified.

use jquery or prototype for easy manipulation.

hope help

Sent from my iPhone

On 11 Feb 2013, at 07:04, Amit  wrote:

> Hi,
> 
> Javascript does not understand django template syntax. In your case you can 
> return a template rendered with django, and replace the html.
> 
> Thannks,
> 
> On Sunday, February 10, 2013 3:12:47 PM UTC+5:30, doniyor wrote:
> hey guys, i am stuck in this problem. i posted the problem on 
> stackoverflow.com also, 
> http://stackoverflow.com/questions/14787772/sorting-queryset-of-search-result-and-render-back-thru-ajax
> 
> but till now no one could answer there, so i am asking here again. anyone 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.
>  
>  

-- 
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: forign key no forms

2013-02-10 Thread Sandeep kaur
2013/2/11 Carlos Andre :
> Olá pessoal!
> Olha, preciso que um foreign key seja acessível com o forms!
> Tentei de algumas maneiras e não consegui! materiais também não tão
> sucintos!
> alguém pode  me ajudar com essa questão?
> Obrigado pela a atenção!
>
The foreign key is by default acessible in the forms in the form of
drop down. You just need to define the form of your model and the in
template file write this :


{% csrf_token %}

{{ form.as_table }}




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




How many sites about Django like djangoXXX?

2013-02-10 Thread Jingqiang Zhang
As far as I know:

   - https://www.djangoproject.com/
   - http://www.djangosites.org/
   - http://www.djangobook.com/
   - https://www.django-cms.org/
   - http://djangolinks.com/
   - http://djangosnippets.org/
   - http://djangostars.com/
   - http://geodjango.org/

Any others?

-- 
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: Appscale and Django

2013-02-10 Thread Chris Bunch
Hello,
   You can certainly run Django apps on AppScale, provided that your app 
works fine on App Engine. There's an out of date article 
(https://developers.google.com/appengine/articles/django) that details what 
the transition process tends to look like, and it mostly boils down to how 
you store state in your application. If you only store state via a 
database, then it's usually straightforward enough to translate it to the 
App Engine Datastore (which in AppScale can be Cassandra, HBase, etc). 
We've seen users run into some problems in some areas, mainly when they 
don't put state in the database (e.g., on the filesystem). In those cases, 
you can transition your app to look for the data in the database instead of 
the local filesystem (and of course, store it in the database instead of 
the filesystem). This can still be problematic if your data is particularly 
large (too large for the Datastore) but you can always put it in the 
Blobstore to get around this. In App Engine, there are limits on the sizes 
of data you can store in the Datastore and Blobstore, but in AppScale, you 
can always turn those limits off.

As far as stability and reliability goes, we've improved a lot in the last 
few months, so I'd definitely recommend giving AppScale a try and let us 
know what you think of it! Feel free to e-mail me back or reach us on IRC 
(#appscale on freenode.net) if you have any questions or the like.

On Thursday, February 7, 2013 1:57:20 PM UTC-8, hinnack wrote:
>
> Hi all, 
>
> is someone on the list using Appscale [1] with Django? 
> If yes, what is your setup (MySQL, Mongo, E2, Eucalyptus [2], KVM, etc.) 
> What is your experiance towards stalability, reliability and performance? 
>
> [1] http://appscale.cs.ucsb.edu 
> [2] http://www.eucalyptus.com 
>
> regards 
>
> Henrik 
>

-- 
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: createsuperuser with a custom User model

2013-02-10 Thread mack the finger
Ah, I didn't add my fields to REQUIRED_FIELDS, thanks. I was thinking 
createsuperuser would look at the fields I had included in 
create_superuser's signature...

On Sunday, February 10, 2013 7:04:59 PM UTC-5, Russell Keith-Magee wrote:
>
>
> On Mon, Feb 11, 2013 at 7:48 AM, mack the finger 
>  > wrote:
>
>> I created a custom User model. It has a few extra fields, most notably a 
>> "date_of_birth" field. Now when I try to crete a new superuser instance via 
>> the management command, I get this error:
>>
>> TypeError: create_superuser() takes exactly 4 arguments (3 given)
>>
>> My "create_superuser" manager method looks like this:
>>
>> def create_superuser(self, email, date_of_birth, password):
>> u = self.create_user(email, date_of_birth, password)
>> u.superuser = True
>> u.save()
>> return u
>>
>> The management command isn't asking for the dob... Is this a known 
>> shortcoming of the new custom User model, or am I not doing something right?
>>
>
> If the management command isn't asking for the date of birth, then it 
> sounds like you haven't put the DOB field in the list of REQUIRED_FIELDS. 
>
>
> https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.models.CustomUser.REQUIRED_FIELDS
>
> The other possibility is that you're not using a pre-release version of 
> Django 1.5. Custom user models are a new feature, and aren't available in 
> Django 1.4; you have to use the 1.5 release candidate or a version from git 
> to get this feature.
>
> Yours,
> Russ Magee %-)
>

-- 
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: how to render data coming from server to template using ajax!

2013-02-10 Thread Amit
Hi,

Javascript does not understand django template syntax. In your case you can 
return a template rendered with django, and replace the html.

Thannks,

On Sunday, February 10, 2013 3:12:47 PM UTC+5:30, doniyor wrote:
>
> hey guys, i am stuck in this problem. i posted the problem on 
> stackoverflow.com also, 
> http://stackoverflow.com/questions/14787772/sorting-queryset-of-search-result-and-render-back-thru-ajax
>
> but till now no one could answer there, so i am asking here again. anyone 
> 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: createsuperuser with a custom User model

2013-02-10 Thread Russell Keith-Magee
On Mon, Feb 11, 2013 at 7:48 AM, mack the finger  wrote:

> I created a custom User model. It has a few extra fields, most notably a
> "date_of_birth" field. Now when I try to crete a new superuser instance via
> the management command, I get this error:
>
> TypeError: create_superuser() takes exactly 4 arguments (3 given)
>
> My "create_superuser" manager method looks like this:
>
> def create_superuser(self, email, date_of_birth, password):
> u = self.create_user(email, date_of_birth, password)
> u.superuser = True
> u.save()
> return u
>
> The management command isn't asking for the dob... Is this a known
> shortcoming of the new custom User model, or am I not doing something right?
>

If the management command isn't asking for the date of birth, then it
sounds like you haven't put the DOB field in the list of REQUIRED_FIELDS.

https://docs.djangoproject.com/en/dev/topics/auth/customizing/#django.contrib.auth.models.CustomUser.REQUIRED_FIELDS

The other possibility is that you're not using a pre-release version of
Django 1.5. Custom user models are a new feature, and aren't available in
Django 1.4; you have to use the 1.5 release candidate or a version from git
to get this feature.

Yours,
Russ Magee %-)

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




createsuperuser with a custom User model

2013-02-10 Thread mack the finger
I created a custom User model. It has a few extra fields, most notably a 
"date_of_birth" field. Now when I try to crete a new superuser instance via 
the management command, I get this error:

TypeError: create_superuser() takes exactly 4 arguments (3 given)

My "create_superuser" manager method looks like this:

def create_superuser(self, email, date_of_birth, password):
u = self.create_user(email, date_of_birth, password)
u.superuser = True
u.save()
return u

The management command isn't asking for the dob... Is this a known 
shortcoming of the new custom User model, or am I not doing something right?

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




forign key no forms

2013-02-10 Thread Carlos Andre
Olá pessoal!
Olha, preciso que um foreign key seja acessível com o forms!
Tentei de algumas maneiras e não consegui! materiais também não tão
sucintos!
alguém pode  me ajudar com essa questão?
Obrigado pela a atenção!

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




Problems doing ajax post with ImageField

2013-02-10 Thread bobhaugen
Here's the relevant parts of the model:

class Resource(models.Model):
photo = ThumbnailerImageField(_("photo"),
upload_to='photos', blank=True, null=True)

This works fine in admin and with regular form posts.

Trying to use jquery.post in one situation to post a photo without 
suffering a page reload.

With the regular post, the photo field returns like this (in 
form.cleaned_data):
'photo': 

And request.FILES is like this:
]}>

With the jquery post, photo is None and the MultiValueDict is empty.  

In both cases the form is set up with enctype="multipart/form-data", 
and the form is instantiated in the view with 
form = ResourceForm(request.POST, request.FILES)

What am I doing wrong?

Here's the javascript:

$("#detailForm").submit(function(event) {
event.preventDefault();

var $form = $( this ),
url = $form.attr( 'action' );

var formData = $form.serialize();
saveResource(url, formData); 

});

function saveResource(url, formData)
{
notifySaving();
var jqxhr = $.post( url, formData,
function( data ) {
$('#detailModal').modal('hide');
notifySaved();
resourceSaved = true;
})
.fail(function() 
{ 
$('#detailModal').modal('hide');
notifyProblem(); 
resourceSaved = false;
startRetrying();
}
);
}

-- 
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-admin.py and manage.py both fail in dev

2013-02-10 Thread David
Problem solved.  Once I straightened out my path issues it came down to the 
following:

*python manage.py validate*

works fine while
*
manage.py validate*

does not. It just returns the help text as if I had run *manage.py* with no 
parameters. 

Clearly either Win7 or Python33 or Django 1.6dev is not passing the 
validate parameter to manage.py.  I recall that under Win NT and XP you 
could adjust how parameters were passed when a program was set to execute 
an extension by default.  If you can still set that I cannot find it.


On Sunday, February 10, 2013 1:22:17 AM UTC-5, David wrote:
>
> When I run either django-admin.py or manage.py all I get is the help 
> screen for the command regardless of the parameters I give.
>
> For example: 
> *django-admin.py startproject mysite* 
> returns the help screen.  It does not create mysite/.
>
> I am working with Python33 and the Dev version of Django refreshed with 
> git. 
>
> Clearly django-admin is on the python path since it is executed.  
> *
> import django
> print(django.get_version())*
>

-- 
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: Collectstatic not working

2013-02-10 Thread Brad
The problem is that you have your STATIC_ROOT as one of the
STATICFILES_DIRS. The STATIC_ROOT directory should be empty, that is
where all the static files from different places will be gathered when
you run collectstatic. You should probably create a static directory
under the myapp directory and move all your static files there. Leave
the STATIC_ROOT setting as you have it now, and don't specify
STATICFILES_DIRS. By default django looks in static directories under
all apps in INSTALLED_APPS.

On Mon, 2013-02-11 at 01:50 +0530, Satinderpal Singh wrote:
> On running ./manage.py  collectstatic in the terminal, gives
> following message.
> 
> 
> 
> "The STATICFILES_DIRS setting should "
> django.core.exceptions.ImproperlyConfigured: The STATICFILES_DIRS
> setting should not contain the STATIC_ROOT 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Collectstatic not working

2013-02-10 Thread Lucas Magnum
Remove the
 os.path.join(PROJECT_PATH, 'static'),
>From staticfiles_dir by default this already included.



[]'s

Lucas Magnum.


2013/2/10 Satinderpal Singh 

> I am trying to configure the static files for my project by following the
> Django guide https://docs.djangoproject.com/en/dev/howto/static-files/
>  My project is like this:
>
>  Automation
>  |
>  |-static
>  | |
>  | |-css
>  | |-js
>  |-__init__.py
>  |-settings.py
>  |-urls.py
>  |-wsgi.py
>  |
>  |-myapp
>  |
>  |-templates
>
> PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
> STATIC_ROOT = os.path.join(PROJECT_PATH,'static')
> STATICFILES_DIRS = (
>  os.path.join(PROJECT_PATH,
> 'static'),
> )
> On running ./manage.py  collectstatic in the terminal, gives following
> message.
>
> "The STATICFILES_DIRS setting should "
> django.core.exceptions.ImproperlyConfigured: The STATICFILES_DIRS setting
> should not contain the STATIC_ROOT setting
>
> How could i solve this problem.
>
> --
> Satinderpal Singh
> http://satindergoraya.blogspot.in/
> http://satindergoraya91.blogspot.in/
>
> --
> 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.




Reset userdata at a specific time without refreshing

2013-02-10 Thread Jak
Hello,

I am creating an app that keeps track of how many classes a person attends 
a month. Basically a person gets 10 classes a month, and each time they 
come to a class I deduct a class from their total. On the 1st of each month 
at 12:01am I want the class packs to reset.

I've created some code to do this, but in order for it to work, the the 
website needs to be refreshed at exactly that time. Is there anyway to make 
it reset at that time without having a user refresh the page.

I haven't hosted the app yet.

(This might be a simple question, I'm new to python/Django)

Thanks

Jake

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




Announcing django-modeltranslation-0.5

2013-02-10 Thread Dirk Eschler
Hello,

i'm pleased to announce a new release of django-modeltranslation, a Django 
app used to translate dynamic content using a registration approach.

The 0.5 release is an important milestone which sorts out many caveats and 
inconsistencies that have been present in earlier versions. It adds official 
support for most non-text-like fields, a new multilingual manager, support for 
fallback languages and incorporates many improvements and bugfixes from the 
community.

Special thanks goes to Jacek Tomaszewski for addressing the deeper problems in 
modeltranslation with his django-modeltranslation-wrapper app. The changes and 
improvements made by the wrapper have been fully merged into 
modeltranslation's core with this release. And better: Jacek recently agreed 
to become a core committer, which makes me feel very positive about the 
project's future again.

Changelog
=
https://github.com/deschler/django-modeltranslation/blob/master/CHANGELOG.txt

Documentation
=
https://django-modeltranslation.readthedocs.org/en/latest/

Installation

$ pip install django-modeltranslation

Project Home

https://github.com/deschler/django-modeltranslation


Best Regards,
Dirk Eschler

-- 
Dirk Eschler 

-- 
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: Recursive Query

2013-02-10 Thread esatterwh...@wi.rr.com
Although an old thread, I think it is still relevant.

postgresql does support recursive queries 
http://www.postgresql.org/docs/8.4/static/queries-with.html

And while not directly support by Django's ORM, could be done using the 
extra clause. Might be an interesting experiment to create a custom manager 
that could perform such queries.

On Tuesday, March 18, 2008 7:52:21 AM UTC-5, Nacho wrote:
>
> I have a category table in my models such as 
>
> class Category(models.Model): 
> parent = ForeignKey('self') 
> name = CharField(maxlength=30) 
>
> I would like to, being in an item, be able to get all his lineage. 
>
> Is there any way of doing this with django? 
>
> Thank you, 
>
> Regards

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




Raw query with "where-in" clause

2013-02-10 Thread Thanos Diacakis
Hey all,

I have the following query:

cursor.execute( "select * from MyTable where Foo=%s or Bar in %s", 
[some_id, some_array] )

This seems to work fine if len(some_array) > 1 but it blows up if there are 
zero or one items in the array (invalid SQL syntax).

Is there a better way to do this?  The Python DB-API docs seems to be very 
light.  Could not find anything relevant.

Thanks

Thanos


-- 
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-admin.py and manage.py both fail in dev

2013-02-10 Thread Ramiro Morales
On Sun, Feb 10, 2013 at 3:22 AM, David Flory  wrote:
> When I run either django-admin.py or manage.py all I get is the help screen
> for the command regardless of the parameters I give.
>
> For example:
> django-admin.py startproject mysite
> returns the help screen.  It does not create mysite/.
>
> I am working with Python33 and the Dev version of Django refreshed with git.
>
> Clearly django-admin is on the python path since it is executed.
>
> import django
> print(django.get_version())

What that shows is that Django is in the Python search path.

It doesn't mean django-admin.py is on the OS PATH.

What you need to do is execute django-admin.py through your
Python interpreter like any Python script:

C:\Users\Me\work> C:\python27\python path\to\django-admin.py startproject mysite

(Replace C:\python27\ with the path to your python.exe. Or if you have
already added such dor to your OS PATH then you can simply use
>python django-admin.py startproject mysite)

Don't rely on any brittle faking of the .py file extension as a native
so it behaves like a native executable or .bat file. IMHO all of them
are broken in some way or another under Windows. Hopefully the PEP 397
'py' launcher included with Python >= 3.3 will solve this for good.

Write it explicitly Instead like shown above. That's something that
works on every platform for every interpreted programming language.

Same advice goes to executing the manage.py script you will get
afterward. e.g.:

mysite> C:\python27\python manage.py startapp my1stapp

Regards,

-- 
Ramiro Morales
@ramiromorales

-- 
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-admin.py and manage.py both fail in dev

2013-02-10 Thread David
and that the code fragment in my OP works and returns the dev version.

On Sunday, February 10, 2013 10:43:14 AM UTC-5, David Flory wrote:
>
> I should have said that I am running Windows 7 (64 bit) and 64 bit VC10 
> versions of my software. 

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




django generate pdf with tables and charts

2013-02-10 Thread Jaimin Patel
I am trying to generate pdf using django template, also need some support 
of javascript code. I have tried PISA, ReportLib and wkhtmltopdf but it 
seems that it doesn't wait for Javascript. 

Can someone suggest good solution or example?

-- 
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: Locating the Django admin Page

2013-02-10 Thread vikalp sahni
I hope you have settled up admin contrib app properly on your settings.py

https://docs.djangoproject.com/en/dev/ref/contrib/admin/


On Sunday, February 10, 2013, Thota Madhu Sudhan Rao wrote:

> I am running apache tomcat server in Amazon EC2 and running django
> application
> The admin page of Django is not here
> http://ipaddress:8080/admin
>
> Where do I find 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  'cvml', 'django-users%2bunsubscr...@googlegroups.com');>.
> To post to this group, send email to 
> django-users@googlegroups.com '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: IntegrityError when creating a brand new model instance

2013-02-10 Thread Some Developer

On 10/02/13 15:07, Bill Freeman wrote:

Did you previously have a field named 'title' in this model that was
marked unique, that you have since removed?  If so, the column may still
be in the database with a unique constraint.  Since it's no longer in
the model, some default may be being used when you save, and that's
obviously not unique.  Use suitable tools for your database (if
PostgreSQL, I suggest PGAdminIII) to examine the schema.  You may be
able to drop the column, or at least the constraint (back up the
database first).

If there never was such a field, then the problem originates in another
model.  You still may be able to figure it out by inspecting the
database schema.  You can also temporarily set up to catch the Integrity
Error close to the origin, and call pdb.set_trace(), where you can
examine the query to see what models are involved.

Bill


OK, I've just found something rather strange. If I just do a simple:

tag = BlogTag(title=form.cleaned_data['title'],
description=form.cleaned_data['description'],
num_articles=0)

tag.save()

I get an IntegrityError and the model fails to save. On the other hand 
if I do the following:


try:
tag = BlogTag(title=form.cleaned_data['title'],
description=form.cleaned_data['description'],
num_articles=0)

tag.save()

except Exception:
pass

the model saves correctly (I've checked manually in the SQLite database) 
and there is no error shown at all (as expected since I have ignored the 
exception).


Any idea why this is the case? If it truly were a database constraint 
violation I would have assumed that it would fail to save no matter what 
you did regarding Python exceptions.


This feels like a bug in Django to me.

Suggestions welcome.

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




django-admin.py and manage.py both fail in dev

2013-02-10 Thread David Flory
I should have said that I am running Windows 7 (64 bit) and 64 bit VC10 
versions of my software. 

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




Busting template fragment caches inside a sitewide cache: possible?

2013-02-10 Thread Matt Andrews
Hi all.

I have a site which makes use of Google's Analytics API which allows me to 
grab the most-viewed content on my site and then show it in various ways 
around the site ("most popular articles" etc). The query against this API 
is slow (takes a couple of seconds) so I've been caching it as described in 
my StackOverflow question about the technique 
here
,

The basic process is this:

   - A cron job hits a URL endpoint every 15 minutes
   - This URL makes the API request and caches the results (for 1 hour, in 
   case the cron ever fails)
   - Meanwhile, my app's views request this data and get served the cached 
   data.
   - In my views, I wrap all usage of this data in named template fragment 
   caches
   - The cron endpoint clears both the high-level cache (which the views 
   call) and the template fragment caches
   - I use a site-wide cache for the entire app.

This kind of works, but occasionally results in blank spaces where the data 
should be -- running the cron job manually has no effect on this. 
Occasionally, experimenting with restarting the server, clearing the app's 
cache and immediately calling the cron endpoints can fix things. After an 
hour or so things tend to work themselves out but it seems that the 15 
minute updates don't actually reflect in the templates.

The StackOverflow advice I got seemed to suggest that using template 
fragment caching *inside* a sitewide cached view should respect the inner 
cache setting, but it doesn't seem to.

Can anyone suggest a strategy for making this work reliably? Every time I 
deploy a new build of the app (and restart the server) it wipes the cache 
and pinging the update URL does nothing. I'm sure my logic is just a little 
wrong.

thanks
Matt

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




Locating the Django admin Page

2013-02-10 Thread Thota Madhu Sudhan Rao
I am running apache tomcat server in Amazon EC2 and running django 
application
The admin page of Django is not here
http://ipaddress:8080/admin

Where do I find 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




django-admin.py and manage.py both fail in dev

2013-02-10 Thread David Flory
When I run either django-admin.py or manage.py all I get is the help screen 
for the command regardless of the parameters I give.

For example: 
*django-admin.py startproject mysite* 
returns the help screen.  It does not create mysite/.

I am working with Python33 and the Dev version of Django refreshed with 
git. 

Clearly django-admin is on the python path since it is executed.  
*
import django
print(django.get_version())*

-- 
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: IntegrityError when creating a brand new model instance

2013-02-10 Thread Bill Freeman
Did you previously have a field named 'title' in this model that was marked
unique, that you have since removed?  If so, the column may still be in the
database with a unique constraint.  Since it's no longer in the model, some
default may be being used when you save, and that's obviously not unique.
Use suitable tools for your database (if PostgreSQL, I suggest PGAdminIII)
to examine the schema.  You may be able to drop the column, or at least the
constraint (back up the database first).

If there never was such a field, then the problem originates in another
model.  You still may be able to figure it out by inspecting the database
schema.  You can also temporarily set up to catch the Integrity Error close
to the origin, and call pdb.set_trace(), where you can examine the query to
see what models are involved.

Bill

On Sat, Feb 9, 2013 at 3:44 AM, Some Developer wrote:

> On 08/02/13 14:08, Andre Terra wrote:
>
>> Please post traceback, settings.py, etc.
>>
>> On Fri, Feb 8, 2013 at 5:18 AM, Some Developer
>> > >>
>> wrote:
>>
>> I have a model for a Tag object with simply has two fields. A title
>> (which has the unique constraint) and a description. I also have a
>> FormView based view class which handles the creation of Tag objects.
>>
>> When I try and save the object in the form_valid() method I always
>> get an IntegrityError stating that the title column is not unique.
>> This is somewhat puzzling as I have deleted the SQLite database file
>> and recreated it using syncdb / migrate so it is completely empty.
>>
>> I'm completely baffled by this error.
>>
>
> Opps. I forgot to post the code.
>
> class TagCreate(FormView):
> template_name = 'blog/tag_create.html'
> success_url = reverse_lazy('blog_tag_create_**confirmed')
> model = BlogTag
> form_class = CreateTagForm
>
> def form_valid(self, form):
> tag = BlogTag(
> title=form.cleaned_data['**title'],
> description=form.cleaned_data[**'description'],
> num_articles=0)
>
> tag.save()
>
> return super(TagCreate, self).form_valid(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+unsubscribe@**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.




Multipple apps

2013-02-10 Thread Hum
Hello, how can I service several apps in one project using wsgi?
Thanks for the help

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




how to render data coming from server to template using ajax!

2013-02-10 Thread doniyor
hey guys, i am stuck in this problem. i posted the problem on 
stackoverflow.com 
also, 
http://stackoverflow.com/questions/14787772/sorting-queryset-of-search-result-and-render-back-thru-ajax

but till now no one could answer there, so i am asking here again. anyone 
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.