Re: Getting at Oracle ROWID

2012-06-07 Thread rahajiyev

> MyModel.objects.extra(select={'rowid': "rowid || ''"})
>
Thanks. I don't think extra() takes primary_key=True, does it?
I wouldn't want Django to auto-add column id otherwise.

Assuming I have:
MyModel.objects.extra(select={'id': "rowid || ''"})
OK, that's fine for fetching the ID itself, suitable for creating
forms. But what if I want to fetch an item by this virtual PK, or
update by PK with or without prior fetching?

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



mssql

2012-06-07 Thread Min Hong Tan
hi all,

i'm going to use django-mssql.  is there any one has use this b4? and any
working example?
am i need to define a model in models.py?? how if i run syndb. will it sync
to my default. mysql
database?

Regards,
MH

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



how to have a foreign key to a field of same model which in turn is foreign key to another model ..

2012-06-07 Thread vijay shanker
hi
how can i have this:
client_groups = models.ForeignKey(User, to_field="groups")

it din worked

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



[no subject]

2012-06-07 Thread Satvir Toor
here is my problem
As i request for a url  specified in urlpatterns variable in urls.py
file of the djangoproject It gives
TypeError
Exception Value: 'str' object is not callable
 suggest me

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



Re: Update database with model changes

2012-06-07 Thread Robert Steckroth
Well, that would be a lesson for me.
Looks like I will have to incorporate south into my endeavours.
Much thanks to the Django community.




On Thu, Jun 7, 2012 at 8:55 PM, Psamathos  wrote:
> South will handle schema migrations for you: http://south.aeracode.org/
>
> This tutorial is a good place to start and covers the basic set-up:
> http://south.aeracode.org/docs/tutorial/part1.html
>
> Basically, you want to revert your changes so your model matches your
> database, install south and configure your app to use it, then convert your
> models to use south by typing:
>
> python manage.py schemamigration [appname] --initial
>
> This creates migration files which are stored in [appname]/migrations/
> You can then apply these migrations using this command:
>
> python manage.py migrate [appname]
>
> Note that you need to do this for each app in your project. When you change
> the model and want to update the database, you can create migration files
> automatically with:
>
> python manage.py schemamigration [appname] --auto
>
> Then just apply them as you did with the initial migration.
>
> Some best practices for avoiding issues with South:
>
> If your model has a NOT NULL field then it should always have a default.
> That way South will know what value to fill in when it creates the field.
> If you are changing a pre-existing model field drastically and don't care
> about losing data, I find it most convenient to remove the field, migrate
> the schema, then add the field again with the new specification . This way
> you will avoid conflicts with any existing constraints. Note that to
> preserve the data you'll need to create a (more complicated) data migration.
>
> Hope this helps.
>
>
> On Thursday, 7 June 2012 14:05:13 UTC-4, Surgemcgee wrote:
>>
>> Hey Gang, is there a way to update the database with a syncdb or
>> other command after a model has been changed? I added a field
>> the the model after the syncdb.
>>
>>
>> --
>> Bust0ut, Surgemcgee: Systems Engineer ---
>> PBDefence.com
>> BudTVNetwork.com
>> RadioWeedShow.com
>> "Bringing entertainment to Unix"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/-TIpt70lWX4J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



-- 
Bust0ut, Surgemcgee: Systems Engineer ---
PBDefence.com
BudTVNetwork.com
RadioWeedShow.com
"Bringing entertainment to Unix"

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



Re: Update database with model changes

2012-06-07 Thread Psamathos
South will handle schema migrations for you: http://south.aeracode.org/

This tutorial is a good place to start and covers the basic set-up: 
http://south.aeracode.org/docs/tutorial/part1.html

Basically, you want to revert your changes so your model matches your 
database, install south and configure your app to use it, then convert your 
models to use south by typing:

python manage.py schemamigration [appname] --initial

This creates migration files which are stored in [appname]/migrations/
You can then apply these migrations using this command:

python manage.py migrate [appname]

Note that you need to do this for each app in your project. When you change 
the model and want to update the database, you can create migration files 
automatically with:

python manage.py schemamigration [appname] --auto

Then just apply them as you did with the initial migration.

Some best practices for avoiding issues with South:

   - If your model has a NOT NULL field then it should always have a 
   default. That way South will know what value to fill in when it creates the 
   field.
   - If you are changing a pre-existing model field drastically and don't 
   care about losing data, I find it most convenient to remove the field, 
   migrate the schema, then add the field again with the new specification . 
   This way you will avoid conflicts with any existing constraints. Note that 
   to preserve the data you'll need to create a (more complicated) data 
   migration.
   
Hope this helps.


On Thursday, 7 June 2012 14:05:13 UTC-4, Surgemcgee wrote:
>
> Hey Gang, is there a way to update the database with a syncdb or 
> other command after a model has been changed? I added a field 
> the the model after the syncdb. 
>
>
> -- 
> Bust0ut, Surgemcgee: Systems Engineer --- 
> PBDefence.com 
> BudTVNetwork.com 
> RadioWeedShow.com 
> "Bringing entertainment to Unix" 
>

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



How override RequestContext in generic views?

2012-06-07 Thread Mikhail Golubev
Hello,

I'm a kind of newbie with Django and recently I faced the following
problem.

I wrote custom context processor, that adds in RequestContext
'base_template' variable. It works fine but in some views I'd like to
override somehow this variable. I can do this with default shortcuts
function like render or render_to_response cause RequestContext
instance is updated with supplied context dictionary inside
render_to_string function as 'context_instance.update(dictionary)'.
But if I use class based generic views their render_to_response method
behaves differently.

e.g. I override get_context_data_method this way:

def get_context_data(self, **kwargs):
context = super(EditLayout, self).get_context_data(**kwargs)
context['base_template'] = "layout_edit.xhtml"
context["edit_mode"] = True
return context

but still get default value of 'base_template' (set in my context
processor ) in actually rendered template.

I found this workaround:
def render_to_response(self, context, **response_kwargs):
return render(self.request, self.get_template_names()[0],
context)

But I think that must be some better way to do it. Do I miss something?

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



Django mod_wsgi + No data received in browser

2012-06-07 Thread Jose
I have the following code in wsgi.py and when I try viewing my site in
a browser I get a no data received message (Unable to load the webpage
because the server sent no data.)

I feel like I'm missing the part where this wsgi.py file loads the
actual contents of my site...

import os
import sys
import django.core.handlers.wsgi

# Reorder sys.path so new directories at the front.
sys.path = []
sys.path[:0] = ['/usr/bin/python26',
'/home/deploy/envs/site/lib/python2.6/site-packages/
setuptools-0.6c11-py2.6.egg',

'/home/deploy/envs/site/lib/python2.6/site-packages/pip-1.1-
py2.6.egg',

'/home/deploy/envs/site/lib/python2.6/site-packages',

'/home/deploy/envs/site/lib/python2.6/site-packages/PIL',
'/usr/lib64/python26.zip',
'/usr/lib64/python2.6',
'/usr/lib64/python2.6/plat-linux2',
'/usr/lib64/python2.6/lib-tk',
'/usr/lib64/python2.6/lib-dynload',
'/usr/lib64/python2.6/site-packages',
'/usr/lib64/python2.6/site-packages/Numeric',
'/usr/lib64/python2.6/site-packages/gtk-2.0',
'/usr/lib/python2.6/site-packages',
'/home/deploy/web/cms.site.com']

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

application = django.core.handlers.wsgi.WSGIHandler()

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



Re: Question

2012-06-07 Thread Gerald Klein
I agree with Nik, the tutorial works but you have to make sure to pay close
attention and follow every step. I made the mistake the first time though
because I am a veteran of assuming too much and ended up missing nuances
that were pivotal to get things to work and beat my head against the wall
till someone told me what I'm telling you. Be patient and please ask direct
questions so that we can answer them directly with example.

--jerry

On Thu, Jun 7, 2012 at 2:46 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

> The official tutorial is probably the best "getting started" literature
> for Django that I've come across. What sorts confusion/bugs are you
> encountering?
>
> And just to make sure: this is the tutorial you're referring to?
> https://docs.djangoproject.com/en/1.4/intro/tutorial01/
>
> _Nik
>
> On 6/7/2012 12:36 PM, Peregil wrote:
> > I am trying to learn how to work with Django, and I am trying to make
> > a user registration with a login/password user. However, all the
> > tutorials are confusing and with so many bugs to run something. I
> > would appreciate if someone knows a great website, book, or have an
> > example how to create this page.
> >
> > Thanks and have a great day
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 

Gerald Klein DBA

contac...@geraldklein.com

www.geraldklein.com 

j...@zognet.com

708-599-0352


Arch Awesome, Ranger & Vim the coding triple threat.

Linux registered user #548580

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



Re: Question

2012-06-07 Thread Nikolas Stevenson-Molnar
The official tutorial is probably the best "getting started" literature
for Django that I've come across. What sorts confusion/bugs are you
encountering?

And just to make sure: this is the tutorial you're referring to?
https://docs.djangoproject.com/en/1.4/intro/tutorial01/

_Nik

On 6/7/2012 12:36 PM, Peregil wrote:
> I am trying to learn how to work with Django, and I am trying to make
> a user registration with a login/password user. However, all the
> tutorials are confusing and with so many bugs to run something. I
> would appreciate if someone knows a great website, book, or have an
> example how to create this page.
>
> Thanks and have a great day
>

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



Question

2012-06-07 Thread Peregil
I am trying to learn how to work with Django, and I am trying to make
a user registration with a login/password user. However, all the
tutorials are confusing and with so many bugs to run something. I
would appreciate if someone knows a great website, book, or have an
example how to create this page.

Thanks and have a great day

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



Re: Develop a Facebook app with Django

2012-06-07 Thread Timothy Makobu
Hi. Checkout this thread
https://groups.google.com/forum/?fromgroups#!topic/django-users/fyGDJmTvpz4

On Thu, Jun 7, 2012 at 10:15 PM, francescobocca...@libero.it <
francescobocca...@libero.it> wrote:

> Hi all,
> i read some documentation on the web about Django and Facebook but i didn't
> found a right way to develop my Facebook application with Djando.
> Can you suggest how can start it?
> Thanks
>
> Francesco
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: question about migrating php project

2012-06-07 Thread CLIFFORD ILKAY

On 06/07/2012 01:26 PM, kjs wrote:

Hello,

I am about to launch a Codeigniter project, but have future thoughts
about trying out Django sometime down the line.

My data is in MySQL and I have the urls as:

www.site.com/product/id/slug-name

The id is they primary id of the product.

If I do switch over to Django, will it be simple able to keep the
primary_id intact for my tables, so I don't have to change the urls?


Hi,

That would work just fine. Are the column names of your primary keys 
called "id"? Django assumes that by default. If it's not and let's say 
for the sake of the example it's product_id, it's simple to override 
Django's default behaviour and have Django recognize that as the PK.


I'm curious, if you're considering Django now, why not start the project 
now in Django? If you're an experienced developer and your project is 
relatively low complexity, you could probably build it while you're 
doing the (excellent) Django tutorial. That's how I built my first 
Django app about six years ago. It's a very well-documented, 
easy-to-grasp, productive framework where you can ramp up very quickly 
without having to know everything about it up front. The IRC channel 
(#django on irc.freenode.net) and this list are both fantastic support 
resources. The community is quite friendly and there are many very 
capable people who generously share their knowledge and time to help 
newcomers. I'd encourage to take the leap now if you're thinking about 
doing it anyway.

--
Regards,

Clifford Ilkay
Dinamis
1419-3230 Yonge St.
Toronto, ON
Canada  M4N 3P6


+1 416-410-3326

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



Develop a Facebook app with Django

2012-06-07 Thread francescobocca...@libero.it
Hi all,
i read some documentation on the web about Django and Facebook but i didn't 
found a right way to develop my Facebook application with Djando.
Can you suggest how can start it?
Thanks

Francesco

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



Re: Django session and Dojo dnd.

2012-06-07 Thread voss
Hi Hendrik,

THANK YOU, THANK YOU, and THANK YOU!! I found it!! I made a mistake when 
defining the url, and that's why I kept getting the "code 400" error.

Your test code is extremely beneficial! I can't thank you enough for all 
your help! 

   voss

On Thursday, June 7, 2012 1:04:27 PM UTC-5, henzk wrote:
>
>  Hi Voss,
>
> you were missing a comma after "details: JSON.stringify(details)"
> However, i don't think that was the cause of the problem. When using 
> csrf_exempt you do not need to include the csrf token.
>
> I have now created a test project and it's working here. The project is 
> called 'testp' and the app is called 'testa'
>
> #testp.urls
> from django.conf.urls import patterns, include, url
>
> urlpatterns = patterns('',
> url(r'^dojo/$', 'testa.views.dojo'),
> url(r'^test/$', 'testa.views.new_session'),
> )
>
> #testa.views
> from django.views.decorators.csrf import csrf_exempt
> from django.shortcuts import render
> from django.http import HttpResponse
>
> def dojo(request):
> return render(request, 'dojo.html')
>
> @csrf_exempt
> def new_session(request):
> if request.is_ajax():
> return HttpResponse('ok')
> else:
> return HttpResponse('only AJAX requests are allowed!')
>
> #dojo.html
> 
> 
>  src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js";<http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js>
> >
> 
> var details = [1,2,3,4,5]
> dojo.xhrPost( {
> url: "/test/",
> content: {details: JSON.stringify(details)},
> load: function(response){
> alert(response);
> },
> error: function(){
> alert("error");
> }
> });
> 
> 
> 
>
> If i visit localhost:8000/dojo/ it alerts 'ok'
>
> Maybe you can deduce your error by comparing this to your setup.
> Also, do you have a debugging tool like firebug? It really helps me out 
> quite often.
>
> Good luck!
>
> hendrik
>
> On 06/07/2012 06:58 PM, voss wrote: 
>
> Hi Hendrik,
>
> Thank you for your prompt reply. I really appreciate it!
>
> Yes, I am using the django development server, and it is on port 8000.  I, 
> too, read that the https can cause the '\x16\x03\x01' problem, but I don't 
> see how this can happen in my case because I did not create any https'. 
>
> Although it may not be csrf, do you think csrfmiddlewaretoken: '{{ 
> csrf_token }}' could be the missing piece (see 
> http://stackoverflow.com/questions/9085068/django-jquery-get-to-post)? It 
> seems to make sense to me because {% csrf_token %} is required for a normal 
> post request. If so, how do I use it in dojo.xhrPost? I tried  
>
>
> dojo.xhrPost( {
> url: "/test/",
> content: {
> details: JSON.stringify(details)
> csrfmiddlewaretoken: '{{ csrf_token }}'
> }, 
> load: function(response){
> alert(response);
> },
> error: function(){
> alert("error");
> } 
> });
>
>
> , but it did not change anything. I also commented out the is_ajax line, 
> but I got the same debug message.
>
>
> voss
>
> On Thursday, June 7, 2012 11:32:14 AM UTC-5, henzk wrote: 
>>
>>  Hi Voss,
>>
>> i guess you are right ... it may not be related to CSRF-Protection at all.
>> Are you using the django development server? I have found some references 
>> for '\x16\x03\x01' using google, e.g.
>>
>> http://wishmesh.com/2010/05/apache-logs-contains-x16x03x01-when-accessing-site-via-https/
>>
>> It seems that this is related to browsers that speak HTTPS to a 
>> (misconfigured) HTTP server.
>>
>> Can you verify that this happens also when using the django devserver on 
>> port 8000?
>> Another thing you could try is to get rid of the is_ajax check.
>> In either case you should return a response for non-ajax requests also 
>> ... otherwise you will provoke a HTTP500 in these cases.
>>
>> hendrik
>>
>>
>> On 06/07/2012 06:17 PM, voss wrote: 
>>
>> Hello Hendrik,
>>
>> To simplify things and to do some tests, I started with disabling the 
>> csrf protection. Here is my JS:
>>
>> dojo.xhrPost( {
>> url: "/test/",
>> content: {details: JSON.stringify(details)}, 
>> load: function(response){
>> alert(response);
>> },
>> error: function(){
>> alert("error");
>> } 
>> });
>>
>>
>> In views.py, I have:
>>
>> 

question about migrating php project

2012-06-07 Thread kjs
Hello,

I am about to launch a Codeigniter project, but have future thoughts about 
trying out Django sometime down the line.

My data is in MySQL and I have the urls as:

www.site.com/product/id/slug-name

The id is they primary id of the product.

If I do switch over to Django, will it be simple able to keep the 
primary_id intact for my tables, so I don't have to change the urls? Or 
will it take a bit of effort to massage the data so it has the same primary 
id. I imagine it shouldn't be too difficult, but just wanted to double 
check before I launch with my urls.

So, i'd like:

www.site.com/product/10/widget

to work in both codeigniter and django without needing to modify anything. 
Or would it be better to create a new number and use that instead of the 
primary_id and use that to lookup my record.

Thanks!

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



Admin links not working after switching to Django 1.4

2012-06-07 Thread mete
Hello folks,

i have a django application that was created using 1.3.1, when i
change the runtime to use django 1.4 via virtualenv, on the admin
page: there is only the main screen , and no links to crud operations.

Anyone faced a similar issue?

Thanks in advance
Mete

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



Re: Django session and Dojo dnd.

2012-06-07 Thread voss
Hello Hendrik,

Your code works on my machine, too!! I don't know what is wrong with my 
code. I will definitely compare it carefully to yours. Hopefully, I will 
find the cause soon.

By the way, I do have firebug running all the time, but it does not show 
any errors.

Once again, thank you so much for all your help! Your help is very much 
appreciated.
   voss

On Thursday, June 7, 2012 1:04:27 PM UTC-5, henzk wrote:
>
>  Hi Voss,
>
> you were missing a comma after "details: JSON.stringify(details)"
> However, i don't think that was the cause of the problem. When using 
> csrf_exempt you do not need to include the csrf token.
>
> I have now created a test project and it's working here. The project is 
> called 'testp' and the app is called 'testa'
>
> #testp.urls
> from django.conf.urls import patterns, include, url
>
> urlpatterns = patterns('',
> url(r'^dojo/$', 'testa.views.dojo'),
> url(r'^test/$', 'testa.views.new_session'),
> )
>
> #testa.views
> from django.views.decorators.csrf import csrf_exempt
> from django.shortcuts import render
> from django.http import HttpResponse
>
> def dojo(request):
> return render(request, 'dojo.html')
>
> @csrf_exempt
> def new_session(request):
> if request.is_ajax():
> return HttpResponse('ok')
> else:
> return HttpResponse('only AJAX requests are allowed!')
>
> #dojo.html
> 
> 
>  src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js";<http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js>
> >
> 
> var details = [1,2,3,4,5]
> dojo.xhrPost( {
> url: "/test/",
> content: {details: JSON.stringify(details)},
> load: function(response){
> alert(response);
> },
> error: function(){
> alert("error");
> }
> });
> 
> 
> 
>
> If i visit localhost:8000/dojo/ it alerts 'ok'
>
> Maybe you can deduce your error by comparing this to your setup.
> Also, do you have a debugging tool like firebug? It really helps me out 
> quite often.
>
> Good luck!
>
> hendrik
>
> On 06/07/2012 06:58 PM, voss wrote: 
>
> Hi Hendrik,
>
> Thank you for your prompt reply. I really appreciate it!
>
> Yes, I am using the django development server, and it is on port 8000.  I, 
> too, read that the https can cause the '\x16\x03\x01' problem, but I don't 
> see how this can happen in my case because I did not create any https'. 
>
> Although it may not be csrf, do you think csrfmiddlewaretoken: '{{ 
> csrf_token }}' could be the missing piece (see 
> http://stackoverflow.com/questions/9085068/django-jquery-get-to-post)? It 
> seems to make sense to me because {% csrf_token %} is required for a normal 
> post request. If so, how do I use it in dojo.xhrPost? I tried  
>
>
> dojo.xhrPost( {
> url: "/test/",
> content: {
> details: JSON.stringify(details)
> csrfmiddlewaretoken: '{{ csrf_token }}'
> }, 
> load: function(response){
> alert(response);
> },
> error: function(){
> alert("error");
> } 
> });
>
>
> , but it did not change anything. I also commented out the is_ajax line, 
> but I got the same debug message.
>
>
> voss
>
> On Thursday, June 7, 2012 11:32:14 AM UTC-5, henzk wrote: 
>>
>>  Hi Voss,
>>
>> i guess you are right ... it may not be related to CSRF-Protection at all.
>> Are you using the django development server? I have found some references 
>> for '\x16\x03\x01' using google, e.g.
>>
>> http://wishmesh.com/2010/05/apache-logs-contains-x16x03x01-when-accessing-site-via-https/
>>
>> It seems that this is related to browsers that speak HTTPS to a 
>> (misconfigured) HTTP server.
>>
>> Can you verify that this happens also when using the django devserver on 
>> port 8000?
>> Another thing you could try is to get rid of the is_ajax check.
>> In either case you should return a response for non-ajax requests also 
>> ... otherwise you will provoke a HTTP500 in these cases.
>>
>> hendrik
>>
>>
>> On 06/07/2012 06:17 PM, voss wrote: 
>>
>> Hello Hendrik,
>>
>> To simplify things and to do some tests, I started with disabling the 
>> csrf protection. Here is my JS:
>>
>> dojo.xhrPost( {
>> url: "/test/",
>> content: {details: JSON.stringify(details)}, 
>> load: function(response){
>> alert(response);
>> },
>> error: function(){
>> 

Two asks about customization admin-interface

2012-06-07 Thread Dominis
Greetings, i read about admin customization, but dont find answers... or 
dont understand it.
I have 2 questions.

1. I need to just add one css class for specialy field. It can be solve via 
Formsets, but i dont understand how do it for one field, i dont wanna to 
touch other fields in formset. I need it for add js_rich_text_editor, like 
FCKEditor.

2. I need to change layout of a model in admin site. Explain - i have a 
some articles, which have field "order". I want set this field visible in 
list of all articles, for more comfort for user. And add some method for 
change order (UP and DOWN the articles), i thought exist some way to make 
first part of it through function

def __unicode__(self):
return self.title

but can't understand how. And don't have any idea how make the second part. 
I need create method which will change order, it's seems pretty easy, but 
how i can call it from admin-interface?

Thx.

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



Load photos in front-end, which way i should to choose?

2012-06-07 Thread Dominis
Greetings.
I beginner in Django, and now i need to load photos from local_storage to 
front-end. But i dont understand which way is better for this.
I need to it work like this:
On my site i have category called Lamps, with few articles, on_table_lamp, 
night_lamp and other... Each article (on the site) have unique path to 
itself, which seems like /category_name/article_name/.  I wanna load photos 
from directory with structure identiques by site navigation, mean photos 
for on_table_lamp store in 
root_dir_of_my_projects/photo-storage/LAMPS/ON_TABLE_LAMPS (last two 
sections equal of site route). How i can load photos from it? What i should 
make for it?

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



Re: Update database with model changes

2012-06-07 Thread Nikhil Verma
If you mean you added a field after creating a model class table you need
to generate the sql statement for the new field only( for hint , django
will generate automatically if you do python manage.py sql appname and see
the sql) in a file and execute that file .

Let say you have xyz.sql just run that file.The table/database will be
updated.
I hope this info might help you !

On Thu, Jun 7, 2012 at 11:35 PM, Kevin Anthony wrote:

> Use south
>
> Kevin
> Please excuse brevity, sent from phone
> On Jun 7, 2012 2:05 PM, "Robert Steckroth" 
> wrote:
>
>> Hey Gang, is there a way to update the database with a syncdb or
>> other command after a model has been changed? I added a field
>> the the model after the syncdb.
>>
>>
>> --
>> Bust0ut, Surgemcgee: Systems Engineer ---
>> PBDefence.com
>> BudTVNetwork.com
>> RadioWeedShow.com
>> "Bringing entertainment to Unix"
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Regards
Nikhil Verma
+91-958-273-3156

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



Re: Update database with model changes

2012-06-07 Thread Kevin Anthony
Use south

Kevin
Please excuse brevity, sent from phone
On Jun 7, 2012 2:05 PM, "Robert Steckroth" 
wrote:

> Hey Gang, is there a way to update the database with a syncdb or
> other command after a model has been changed? I added a field
> the the model after the syncdb.
>
>
> --
> Bust0ut, Surgemcgee: Systems Engineer ---
> PBDefence.com
> BudTVNetwork.com
> RadioWeedShow.com
> "Bringing entertainment to Unix"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Update database with model changes

2012-06-07 Thread Robert Steckroth
Hey Gang, is there a way to update the database with a syncdb or
other command after a model has been changed? I added a field
the the model after the syncdb.


-- 
Bust0ut, Surgemcgee: Systems Engineer ---
PBDefence.com
BudTVNetwork.com
RadioWeedShow.com
"Bringing entertainment to Unix"

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



Re: Django session and Dojo dnd.

2012-06-07 Thread Hendrik Speidel

Hi Voss,

you were missing a comma after "details: JSON.stringify(details)"
However, i don't think that was the cause of the problem. When using 
csrf_exempt you do not need to include the csrf token.


I have now created a test project and it's working here. The project is 
called 'testp' and the app is called 'testa'


#testp.urls
from django.conf.urls import patterns, include, url

urlpatterns = patterns('',
url(r'^dojo/$', 'testa.views.dojo'),
url(r'^test/$', 'testa.views.new_session'),
)

#testa.views
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render
from django.http import HttpResponse

def dojo(request):
return render(request, 'dojo.html')

@csrf_exempt
def new_session(request):
if request.is_ajax():
return HttpResponse('ok')
else:
return HttpResponse('only AJAX requests are allowed!')

#dojo.html


src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js";>


var details = [1,2,3,4,5]
dojo.xhrPost( {
url: "/test/",
content: {details: JSON.stringify(details)},
load: function(response){
alert(response);
},
error: function(){
alert("error");
}
});




If i visit localhost:8000/dojo/ it alerts 'ok'

Maybe you can deduce your error by comparing this to your setup.
Also, do you have a debugging tool like firebug? It really helps me out 
quite often.


Good luck!

hendrik

On 06/07/2012 06:58 PM, voss wrote:

Hi Hendrik,

Thank you for your prompt reply. I really appreciate it!

Yes, I am using the django development server, and it is on port 
8000.  I, too, read that the https can cause the '\x16\x03\x01' 
problem, but I don't see how this can happen in my case because I did 
not create any https'.


Although it may not be csrf, do you think |csrfmiddlewaretoken:'{{ 
csrf_token }}'| could be the missing piece (see 
http://stackoverflow.com/questions/9085068/django-jquery-get-to-post)? 
It seems to make sense to me because {% csrf_token %} is required for 
a normal post request. If so, how do I use it in dojo.xhrPost? I tried



dojo.xhrPost( {
url: "/test/",
content: {
details: JSON.stringify(details)
csrfmiddlewaretoken: '{{ csrf_token }}'
},
load: function(response){
alert(response);
},
error: function(){
alert("error");
}
});


, but it did not change anything. I also commented out the is_ajax 
line, but I got the same debug message.



voss

On Thursday, June 7, 2012 11:32:14 AM UTC-5, henzk wrote:

Hi Voss,

i guess you are right ... it may not be related to CSRF-Protection
at all.
Are you using the django development server? I have found some
references for '\x16\x03\x01' using google, e.g.

http://wishmesh.com/2010/05/apache-logs-contains-x16x03x01-when-accessing-site-via-https/



It seems that this is related to browsers that speak HTTPS to a
(misconfigured) HTTP server.

Can you verify that this happens also when using the django
devserver on port 8000?
Another thing you could try is to get rid of the is_ajax check.
In either case you should return a response for non-ajax requests
also ... otherwise you will provoke a HTTP500 in these cases.

hendrik


On 06/07/2012 06:17 PM, voss wrote:

Hello Hendrik,

To simplify things and to do some tests, I started with disabling
the csrf protection. Here is my JS:

dojo.xhrPost( {
url: "/test/",
content: {details: JSON.stringify(details)},
load: function(response){
alert(response);
},
error: function(){
alert("error");
}
});


In views.py, I have:

@csrf_exempt
def new_session(request):
if request.is_ajax():
return HttpResponse('ok')


In theory, I should see the 'ok' alert, but, instead, I got
"null". The debug message shows:

[07/Jun/2012 10:31:06] code 400, message Bad request syntax

('\x16\x03\x01\x00\x8f\x01\x00\x00\x8b\x03\x01O\xd0\xc9:}m\x9e\x04\xbf_:$`\x96v\xca\x1b\x92\xb8\xc7?M\x0f\xbdc\x8e\xfb+\x84E\x8c?\x00\x00H\x00\xff\xc0')
[07/Jun/2012 10:31:06] 

Re: Django session and Dojo dnd.

Hi Hendrik,

Thank you for your prompt reply. I really appreciate it!

Yes, I am using the django development server, and it is on port 8000.  I, 
too, read that the https can cause the '\x16\x03\x01' problem, but I don't 
see how this can happen in my case because I did not create any https'. 

Although it may not be csrf, do you think csrfmiddlewaretoken: '{{ 
csrf_token }}' could be the missing piece (see 
http://stackoverflow.com/questions/9085068/django-jquery-get-to-post)? It 
seems to make sense to me because {% csrf_token %} is required for a normal 
post request. If so, how do I use it in dojo.xhrPost? I tried  


dojo.xhrPost( {
url: "/test/",
content: {
details: JSON.stringify(details)
csrfmiddlewaretoken: '{{ csrf_token }}'
}, 
load: function(response){
alert(response);
},
error: function(){
alert("error");
} 
});


, but it did not change anything. I also commented out the is_ajax line, 
but I got the same debug message.


voss

On Thursday, June 7, 2012 11:32:14 AM UTC-5, henzk wrote:
>
>  Hi Voss,
>
> i guess you are right ... it may not be related to CSRF-Protection at all.
> Are you using the django development server? I have found some references 
> for '\x16\x03\x01' using google, e.g.
>
> http://wishmesh.com/2010/05/apache-logs-contains-x16x03x01-when-accessing-site-via-https/
>
> It seems that this is related to browsers that speak HTTPS to a 
> (misconfigured) HTTP server.
>
> Can you verify that this happens also when using the django devserver on 
> port 8000?
> Another thing you could try is to get rid of the is_ajax check.
> In either case you should return a response for non-ajax requests also ... 
> otherwise you will provoke a HTTP500 in these cases.
>
> hendrik
>
>
> On 06/07/2012 06:17 PM, voss wrote: 
>
> Hello Hendrik,
>
> To simplify things and to do some tests, I started with disabling the csrf 
> protection. Here is my JS:
>
> dojo.xhrPost( {
> url: "/test/",
> content: {details: JSON.stringify(details)}, 
> load: function(response){
> alert(response);
> },
> error: function(){
> alert("error");
> } 
> });
>
>
> In views.py, I have:
>
> @csrf_exempt
> def new_session(request):
> if request.is_ajax():
> return HttpResponse('ok')
>
>
> In theory, I should see the 'ok' alert, but, instead, I got "null". The 
> debug message shows:
>
> [07/Jun/2012 10:31:06] code 400, message Bad request syntax 
> ('\x16\x03\x01\x00\x8f\x01\x00\x00\x8b\x03\x01O\xd0\xc9:}m\x9e\x04\xbf_:$`\x96v\xca\x1b\x92\xb8\xc7?M\x0f\xbdc\x8e\xfb+\x84E\x8c?\x00\x00H\x00\xff\xc0')
> [07/Jun/2012 10:31:06] "??O??:}m??_:$`?vM?c??+?E??H??" 400 -
>
> This error message looks similar to that before the csrf_exempt decorator 
> was added, which suggests to me that the problem may not be in the csrf 
> protection. Am I right? Any thoughts would be greatly appreciated!
>
> voss
>
>
> On Monday, June 4, 2012 8:21:15 PM UTC-5, henzk wrote: 
>>
>> Hi Voss, 
>>
>>  i forgot about django's CSRF protection.
>> You can use the csrf_exempt decorator on the view function to disable 
>> django's CSRF protection - however, i wouldn't recommend that.
>>
>>  There is a script at 
>> https://docs.djangoproject.com/en/dev/ref/contrib/csrf/ 
>> To use the script with dojo instead of jquery, you will need to adapt it 
>> a little:
>>
>>  -copy the getCookie function to your code
>>  
>>  then, every time you make a POST request to your application using 
>> dojo.xhrPost, add this to the arguments object:
>>
>>  headers: {'X-CSRFToken': getCookie('csrftoken')}
>>
>>  If you are still getting HTTP 400 errors, verify that the request looks 
>> sane in firebug and check that it contains a X_HTTP_REQUESTED_WITH header 
>> set to XMLHttpRequest (but i am pretty sure dojo adds this one 
>> automatically).
>>
>>  hendrik
>>
>> Am Montag, 4. Juni 2012 18:33:21 UTC+2 schrieb voss: 
>>>
>>> Hi Hendrik,
>>>
>>> I forgot to mention in my previous message that the debug shows the 
>>> following: 
>>>
>>> code 400, message Bad request syntax 
>>> ("\x16\x03\x01\x00\x8b\x01\x00\x00\x87\x03\x01O\xcc\xd8\xc0\x18hZ\x7f\xa3h\xb9l\xaf\xdb\xfbp}(\xc1\xc6\xa5g\x18\xe5!\x87\xd4\xe2`_'\x90\x00\x00H\x00\xff\xc0")
>>>
>>> Thank you!
>>>
>>> voss
>>>
>>>
>>>
>>> On Saturday, June 2, 2012 8:46:38 AM UTC-5, henzk wrote: 

 Hi, 

 i haven't tested the code and never used dojo 

Re: Django session and Dojo dnd.


Hi Voss,

i guess you are right ... it may not be related to CSRF-Protection at all.
Are you using the django development server? I have found some 
references for '\x16\x03\x01' using google, e.g.

http://wishmesh.com/2010/05/apache-logs-contains-x16x03x01-when-accessing-site-via-https/

It seems that this is related to browsers that speak HTTPS to a 
(misconfigured) HTTP server.


Can you verify that this happens also when using the django devserver on 
port 8000?

Another thing you could try is to get rid of the is_ajax check.
In either case you should return a response for non-ajax requests also 
... otherwise you will provoke a HTTP500 in these cases.


hendrik


On 06/07/2012 06:17 PM, voss wrote:

Hello Hendrik,

To simplify things and to do some tests, I started with disabling the 
csrf protection. Here is my JS:


dojo.xhrPost( {
url: "/test/",
content: {details: JSON.stringify(details)},
load: function(response){
alert(response);
},
error: function(){
alert("error");
}
});


In views.py, I have:

@csrf_exempt
def new_session(request):
if request.is_ajax():
return HttpResponse('ok')


In theory, I should see the 'ok' alert, but, instead, I got "null". 
The debug message shows:


[07/Jun/2012 10:31:06] code 400, message Bad request syntax 
('\x16\x03\x01\x00\x8f\x01\x00\x00\x8b\x03\x01O\xd0\xc9:}m\x9e\x04\xbf_:$`\x96v\xca\x1b\x92\xb8\xc7?M\x0f\xbdc\x8e\xfb+\x84E\x8c?\x00\x00H\x00\xff\xc0')

[07/Jun/2012 10:31:06] "??O??:}m??_:$`?vM?c??+?E??H??" 400 -

This error message looks similar to that before the csrf_exempt 
decorator was added, which suggests to me that the problem may not be 
in the csrf protection. Am I right? Any thoughts would be greatly 
appreciated!


voss


On Monday, June 4, 2012 8:21:15 PM UTC-5, henzk wrote:

Hi Voss,

i forgot about django's CSRF protection.
You can use the csrf_exempt decorator on the view function to
disable django's CSRF protection - however, i wouldn't recommend that.

There is a script at
https://docs.djangoproject.com/en/dev/ref/contrib/csrf/

To use the script with dojo instead of jquery, you will need to
adapt it a little:

-copy the getCookie function to your code

then, every time you make a POST request to your application using
dojo.xhrPost, add this to the arguments object:

headers: {'X-CSRFToken': getCookie('csrftoken')}

If you are still getting HTTP 400 errors, verify that the request
looks sane in firebug and check that it contains a
X_HTTP_REQUESTED_WITH header set to XMLHttpRequest (but i am
pretty sure dojo adds this one automatically).

hendrik

Am Montag, 4. Juni 2012 18:33:21 UTC+2 schrieb voss:

Hi Hendrik,

I forgot to mention in my previous message that the debug
shows the following:

code 400, message Bad request syntax

("\x16\x03\x01\x00\x8b\x01\x00\x00\x87\x03\x01O\xcc\xd8\xc0\x18hZ\x7f\xa3h\xb9l\xaf\xdb\xfbp}(\xc1\xc6\xa5g\x18\xe5!\x87\xd4\xe2`_'\x90\x00\x00H\x00\xff\xc0")

Thank you!

voss



On Saturday, June 2, 2012 8:46:38 AM UTC-5, henzk wrote:

Hi,

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

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

Explanation:

- changed 'item' to 'var item' ... without the 'var' item
will be
global, which is probably not what you want.
- to get around making multiple requests to the 

Re: Django session and Dojo dnd.

Hello Hendrik,

To simplify things and to do some tests, I started with disabling the csrf 
protection. Here is my JS:

dojo.xhrPost( {
url: "/test/",
content: {details: JSON.stringify(details)}, 
load: function(response){
alert(response);
},
error: function(){
alert("error");
} 
});


In views.py, I have:

@csrf_exempt
def new_session(request):
if request.is_ajax():
return HttpResponse('ok')


In theory, I should see the 'ok' alert, but, instead, I got "null". The 
debug message shows:

[07/Jun/2012 10:31:06] code 400, message Bad request syntax 
('\x16\x03\x01\x00\x8f\x01\x00\x00\x8b\x03\x01O\xd0\xc9:}m\x9e\x04\xbf_:$`\x96v\xca\x1b\x92\xb8\xc7?M\x0f\xbdc\x8e\xfb+\x84E\x8c?\x00\x00H\x00\xff\xc0')
[07/Jun/2012 10:31:06] "??O??:}m??_:$`?vM?c??+?E??H??" 400 -

This error message looks similar to that before the csrf_exempt decorator 
was added, which suggests to me that the problem may not be in the csrf 
protection. Am I right? Any thoughts would be greatly appreciated!

voss


On Monday, June 4, 2012 8:21:15 PM UTC-5, henzk wrote:
>
> Hi Voss,
>
> i forgot about django's CSRF protection.
> You can use the csrf_exempt decorator on the view function to disable 
> django's CSRF protection - however, i wouldn't recommend that.
>
> There is a script at 
> https://docs.djangoproject.com/en/dev/ref/contrib/csrf/ 
> To use the script with dojo instead of jquery, you will need to adapt it a 
> little:
>
> -copy the getCookie function to your code
>
> then, every time you make a POST request to your application using 
> dojo.xhrPost, add this to the arguments object:
>
> headers: {'X-CSRFToken': getCookie('csrftoken')}
>
> If you are still getting HTTP 400 errors, verify that the request looks 
> sane in firebug and check that it contains a X_HTTP_REQUESTED_WITH header 
> set to XMLHttpRequest (but i am pretty sure dojo adds this one 
> automatically).
>
> hendrik
>
> Am Montag, 4. Juni 2012 18:33:21 UTC+2 schrieb voss:
>>
>> Hi Hendrik,
>>
>> I forgot to mention in my previous message that the debug shows the 
>> following: 
>>
>> code 400, message Bad request syntax 
>> ("\x16\x03\x01\x00\x8b\x01\x00\x00\x87\x03\x01O\xcc\xd8\xc0\x18hZ\x7f\xa3h\xb9l\xaf\xdb\xfbp}(\xc1\xc6\xa5g\x18\xe5!\x87\xd4\xe2`_'\x90\x00\x00H\x00\xff\xc0")
>>
>> Thank you!
>>
>> voss
>>
>>
>>
>> On Saturday, June 2, 2012 8:46:38 AM UTC-5, henzk wrote:
>>>
>>> Hi, 
>>>
>>> i haven't tested the code and never used dojo before, but sth. like 
>>> this should work: 
>>>
>>> var source1 = new dojo.dnd.Source("itemListNode"); 
>>> var source2 = new dojo.dnd.Target("selectedListNode"); 
>>> dojo.connect( source1, "onDndDrop", 
>>> function(source, nodes, copy, target){ 
>>> //gather items and details 
>>> var details = []; 
>>> for( i=0; i < nodes.length; i++){ 
>>> var item = this.getItem(nodes[i].id); 
>>> details.push(item.data); 
>>> } 
>>> //send details to server via AJAX POST request 
>>> dojo.xhrPost({ 
>>> url: "/save_details/", 
>>> content: {details: JSON.stringify(details)}, 
>>> // The success handler 
>>> load: function(response) { 
>>>  alert('ok'); 
>>> }, 
>>> // The error handler 
>>> error: function() { 
>>>  alert("error"); 
>>> } 
>>> }); 
>>> }); 
>>>
>>> Explanation: 
>>>
>>> - changed 'item' to 'var item' ... without the 'var' item will be 
>>> global, which is probably not what you want. 
>>> - to get around making multiple requests to the server(one for each 
>>> dropped node), put the detail of each node in the details array. 
>>> - then json-encode and send this array to your django view (assumed to 
>>> be at '/save_details/') 
>>> - in the view, access the list as 
>>> json.loads(request.POST.get('details', '[]')) and place it into 
>>> request.session 
>>>
>>> As mentioned, the code is completely untested. 
>>>
>>> Good luck! 
>>>
>>> Yours, 
>>>
>>> Hendrik Speidel 
>>>
>>

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



Re: Getting at Oracle ROWID

On Thursday, June 7, 2012 3:55:37 AM UTC-6, rahajiyev wrote:
>
> There's an existing Oracle database I want to hook Django up with. The 
> problem is, the table I need lacks single-key primary keys. Oracle 
> does provide its unique table-wide ROWID which can normally be used as 
> a PK with a few restrictions. But it's a LOB, so a cast to string is 
> normally required to fetch it: SELECT ROWID || '' 
> Writing this expression a piece of cake for CakePHP and its 
> virtualFields. Can Django do the same?


MyModel.objects.extra(select={'rowid': "rowid || ''"})

Cheers,
Ian

 

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



Re: Python FAQ: Webdev


On 07/06/2012 04:25 μμ, Peter of the Norse wrote:


There's a large group of programmers, especially in Python, that loves "Do one 
thing, and do it well". If you don't need database support, then half of Django goes 
unused. If you do need to save data, then you'll love ModelForms. I like that Django has 
everything I need and that they all work together. But if you'd rather use MongoDB, then 
it's every difficult.

Peter of the Norse
rahmc...@radio1190.org



   
I agree with your point of view even though I have found some projects 
combining Django with mongo db.
Anyway what I like about Django is that it has a rich feature set, it is 
infinitely extendable AND can be virtualized (though pip, fabric, etc) 
making replication of installation easy.



--
 --
   Nick Apostolakis
  e-mail: nicka...@oncrete.gr
 Web Site: http://nick.oncrete.gr
 --


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



Redirect form after post, and download pdf

This is probably very easy, but i cannot get this working (Django
1.2).

I want to generate a pdf based on the values of a form, and redirect
the form to a thanks page.

Generating the pdf is no problem, but first generate the pdf to
download, and after that redirect the form the the thanks page doesn't
work at all (because the view "stops" after the return).

Any idea?

Rob

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



Re: limit number of related instance for m2m field in django-admin

You could customize the Admin Book Creation Form's save() method to check
for X number of books an author already has.

Note: I have very limited experience customizing the Admin application and
have only used this method through a normal Form.

On Thu, Jun 7, 2012 at 7:56 AM, vijay shanker  wrote:

> hi
> is there any way to limit the number of instances that can be attached
> to a m2m field.
> e.g
> author = models.manytomany(Book)
>
> i want to limit the max number of book objects that can be attached to
> author.
> How to go about this.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Python FAQ: Webdev


On May 12, 2012, at 11:49 PM, Nick Apostolakis wrote:

> On 13/05/2012 07:32 πμ, Peter Murphy wrote:
>> All,
>> 
>> The site recommends "Flask" by the way - not Django. The author thinks
>> it is too heavyweight for his or her uses. But there seems to be a lot
>> of ideas in the article about how to make a framework that seem to be
>> captured in Django.
>> 
>> Best regards,
>> Peter
>> 
>> [* http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ ]
>> 
>>   
> An interesting article, I didn't realize Django was too "heavy weight".
> I also didn't know about Flask and Pyramid either.

There's a large group of programmers, especially in Python, that loves "Do one 
thing, and do it well". If you don't need database support, then half of Django 
goes unused. If you do need to save data, then you'll love ModelForms. I like 
that Django has everything I need and that they all work together. But if you'd 
rather use MongoDB, then it's every difficult. 

Peter of the Norse
rahmc...@radio1190.org



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



Re: running a task in fabfile from django


On 06/06/2012 01:28 PM, umit sethi wrote:

Hi,


I have a fabric task eg- def run_task():
#code here

 From the command prompt I run this task: fab -c env.fabricrc run_task -
H hostnamr

How can I run this task from django?I click on a button on a webpage
in django app and it should do this. How can I achieve this?


Hi,

I don't know what are you trying to achieve, but you can just add a view 
calling subprocess.Popen and run the command. But that's  probably a 
very bad solution (difficult to know without further information), 
depending on what you want achieve, you might want to check Celery and 
django-celery.


HTH

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



limit number of related instance for m2m field in django-admin

hi
is there any way to limit the number of instances that can be attached
to a m2m field.
e.g
author = models.manytomany(Book)

i want to limit the max number of book objects that can be attached to
author.
How to go about this.

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



Re: Understanding Django for PHP developer

Bruno,
exactly what I've been looking for! Thanks!


On Jun 4, 11:28 am, bruno desthuilliers
 wrote:
> On Jun 3, 12:18 pm, mikegolf  wrote:
>
> > Hi,
> > I've started to learn Django recently, however for last 5+ years I've
> > been developing using PHP (especially Yii) and thus asking if there's
> > any tutorial / documentation on significant differences in
> > *thinking*.
> > What I mean is for example objects' lifecycle - for PHP the life cycle
> > of object is strictly related to the single request..
> > I know that for Python / Django developers these are obvious things,
> > but not for me. Thus I'd love to see an article / document which
> > points these base and significant differences.
> > Any recommendations?
>
> Well, the answer may not be as simple as it seems, as it first
> requires a correct understanding of Python's execution model,
> namespaces, scopes and bindings (aka "variables") - and this would
> make for a rather long and technical document. Then you have to know
> how your django application is deployed.
>
> I think the most important points wrt/ "objects lifcycle" are (overly
> simplified):
>
> * a Python module's top-level code is executed once the first time the
> module is imported
> * "import", "class" and "function" statements are executable
> statements
> * the code at the toplevel of a "class" statement is executed once
> before the metaclass is called and the class object created
> * all this will occur for each of your django server processes
> * you can have multiple processes serving the same django application,
> and ay request can be mapped to any process (this depends on the front
> server and gateway so you have no control over this)
>
> To make a long story short: remember you are in a long running
> process, so never modify (mutate or rebind) any module or class
> attribute when serving a request.
>
> As an exemple, I once spent quite a few hours debugging a seemingly
> intermittent and very very strang problem on a form. The root problem
> was a younger co-worker wrote code that was mutating some of the
> form's *class* attributes in the class initializer, and depending on
> which process would process the form's submission, things would - or
> not - get totally mixed up.
>
> A more common mistake is to initialize a class or module date
> attribute with the result of a call to datetime.datetime.now() and
> wonder why it's not updated on each and every request.

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



Re: Accessing Backend DB for UI

YeahI got it, Thank you brother .

Thank You

On Thu, Jun 7, 2012 at 10:44 AM, Dennis Lee Bieber wrote:

> On Thu, 7 Jun 2012 09:45:53 +0530, Tanveer Ali Sha
>  declaimed the following in
> gmane.comp.python.django.user:
>
> > sorry ,I have a Perl back-end running as an API,i want to control that in
> > my front end using Django.How can I do that.?
> >
>
> API to what? A common database system?
>
>If so, the best solution is to bypass the PERL and talk directly to
> the database engine; Django may support the database engine itself.
>
>Otherwise, Django will not be involved at all -- it will be pure
> hand-written Python calling the PERL operations -- I presume the PERL is
> command line driven, so Python can invoke it via any of: os.system(),
> subprocess.popen(), etc.
>
>Django is optimized to be an end-to-end framework... from HTTP
> request/response handling, HTML templating, through business logic, and
> directly into a database engine --although it doesn't force one to use
> all of the framework (the template system is probably the easiest thing
> to substitute). If your database is only accessible via PERL scripts,
> that means you have to replace the Django database interface with your
> own Python code (or create a DB-API 2 compatible library -- which may be
> pure Python, or a compiled C-language extension -- that will interface
> with the PERL scripts; then add some tweaks to the Django database
> modules to recognize your new library as a valid database option).
> --
>Wulfraed Dennis Lee Bieber AF6VN
>wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Getting at Oracle ROWID

There's an existing Oracle database I want to hook Django up with. The
problem is, the table I need lacks single-key primary keys. Oracle
does provide its unique table-wide ROWID which can normally be used as
a PK with a few restrictions. But it's a LOB, so a cast to string is
normally required to fetch it: SELECT ROWID || ''
Writing this expression a piece of cake for CakePHP and its
virtualFields. Can Django do the same?

Well, you guessed it, I've actually learned CakePHP and finished
writing a simple operator interface for remote Oracle + local Postgres
+ auth roles. Now I have some spare time to rewrite it in Django,
learning it at the same time (got some background learning it a year
or two ago).

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



Re: Error creating project from the Command Prompt


7.6.2012 10:29, andres orozco kirjoitti:

I've installed django 1.4 and i want to test the installation, i don't
know too much about this cuz' i'm just learning, but i tried it using
the windows 7 command prompt but i've got this error 
http://i.imgur.com/znZGW.png
could someone help me please?



Your path indicates that you have installed Python 3.2. Django is only 
Python 2.x compatible currently.


So install Python 2.7.x

Since you're beginner I also promote my blogpost how to make life easier 
in Windows 7:

http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/

--
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 post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Error creating project from the Command Prompt

I've installed django 1.4 and i want to test the installation, i don't
know too much about this cuz' i'm just learning, but i tried it using
the windows 7 command prompt but i've got this error 
http://i.imgur.com/znZGW.png
could someone help me please?

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



Re: Getting the last modified datetime from a DateTimeField

Please read:
http://stackoverflow.com/questions/1737017/django-auto-now-and-auto-now-add


On Jun 7, 8:14 am, Jesus Noland  wrote:
> Thank you for your reply.
>
> Ok so if I type out:
>
> m = Model.objects.get(id=1)
>
> then
>
> m.date
>
> Will give me the date and time of the last time it was saved? Because that
> is not what I am seeing. I am seeing the date the model was first created.
>
>
>
>
>
>
>
> On Tuesday, June 5, 2012 12:33:36 PM UTC-7, Jesus Noland wrote:
>
> > Hello everyone,
>
> > I am using Django 1.3 on Python 2.7 and I have a field in a model setup
> > like this:
>
> > date = models.DateTimeField(auto_now=True, auto_now_add=True)
>
> > now I would like to know how to get the last modified date from this field 
> > if my model
>
> > is called 'm':
>
> > m.date.last_modified ???
>
> > Your help is greatly appreciated. Thank you.

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



Re: Getting the last modified datetime from a DateTimeField

Thank you for your reply.

Ok so if I type out:

m = Model.objects.get(id=1)

then

m.date

Will give me the date and time of the last time it was saved? Because that 
is not what I am seeing. I am seeing the date the model was first created.

On Tuesday, June 5, 2012 12:33:36 PM UTC-7, Jesus Noland wrote:
>
> Hello everyone,
>
> I am using Django 1.3 on Python 2.7 and I have a field in a model setup 
> like this:
>
> date = models.DateTimeField(auto_now=True, auto_now_add=True)
>
>
> now I would like to know how to get the last modified date from this field if 
> my model
>
> is called 'm':
>
>
> m.date.last_modified ???
>
>
> Your help is greatly appreciated. Thank you.
>
>

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