Re: Traceback from csrf_exempt in 1.3.1

2012-03-02 Thread Thomas Orozco
You seem to have no 500.html page.

This traceback won't actually show the error that happened, but error out
on the fact that it can't find a template to display the 500 error.

1. Are you running DEBUG = True?
2. Wouldn't you rather want to simplejson.dum
>
> I have never used csrf_exempt before.  I keep experiencing a traceback
> with 1.3.1, which may be self-induced. Here is my views file:
>
> auth/views.py
> from django.http import HttpResponse
> from django.utils import simplejson
> from django.views.decorators.csrf import csrf_exempt
>
> @csrf_exempt
> def json_api(request):
>return HttpResponse(simplejson.dumps(request),
> mimetype="application/json")
>
> When I do a curl:
>
> curl -i -X POST -d '{"screencast":{"subject":"tools"}}'
> http://127.0.0.1:8000/auth/
>
> I experience 500 Internal Server Error:
>
> Traceback (most recent call last):
>
>  File "/Library/Python/2.7/site-packages/django/core/servers/
> basehttp.py", line 283, in run
>self.result = application(self.environ, self.start_response)
>
>  File "/Library/Python/2.7/site-packages/django/core/handlers/
> wsgi.py", line 272, in __call__
>response = self.get_response(request)
>
>  File "/Library/Python/2.7/site-packages/django/core/handlers/
> base.py", line 169, in get_response
>response = self.handle_uncaught_exception(request, resolver,
> sys.exc_info())
>
>  File "/Library/Python/2.7/site-packages/django/core/handlers/
> base.py", line 218, in handle_uncaught_exception
>return callback(request, **param_dict)
>
>  File "/Library/Python/2.7/site-packages/django/utils/decorators.py",
> line 93, in _wrapped_view
>response = view_func(request, *args, **kwargs)
>
>  File "/Library/Python/2.7/site-packages/django/views/defaults.py",
> line 30, in server_error
>t = loader.get_template(template_name) # You need to create a
> 500.html template.
>
>  File "/Library/Python/2.7/site-packages/django/template/loader.py",
> line 157, in get_template
>template, origin = find_template(template_name)
>
>  File "/Library/Python/2.7/site-packages/django/template/loader.py",
> line 138, in find_template
>raise TemplateDoesNotExist(name)
>
> --
> 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: social graph

2012-03-05 Thread Thomas Orozco
You might want to look into the Django socialauth app
Le 5 mars 2012 14:08, "suresh dokania"  a écrit :

> How to access user 's facebook profile information using django ?
> And how to find their friends and use their info as well ?
>
> --
> 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: Traceback from csrf_exempt in 1.3.1

2012-03-05 Thread Thomas Orozco
Your view is likely raising an exception (but if you don't use csrf exempt
then access is denied and the erroring view code is not run).
Le 2 mars 2012 21:42, "Ethan Whitt"  a écrit :

> I get a 403 error when I comment out csrf_example as such:
>
> auth/views.py
> from django.http import HttpResponse
> from django.utils import simplejson
> #from django.views.decorators.csrf import csrf_exempt
>
> #@csrf_exempt
> def json_api(request):
>  return HttpResponse(simplejson.dumps(request), mimetype="application/
> json")
>
> Here is my urls.py
>
> url(r'^auth/', 'auth.views.json_api'),
>
> Once I uncomment the two csrf_exempt statements, I get the 500 error?
> Any ideas?
>
>
>
> On Mar 2, 6:57 am, Thomas Orozco  wrote:
> > You seem to have no 500.html page.
> >
> > This traceback won't actually show the error that happened, but error out
> > on the fact that it can't find a template to display the 500 error.
> >
> > 1. Are you running DEBUG = True?
> > 2. Wouldn't you rather want to simplejson.dum
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > I have never used csrf_exempt before.  I keep experiencing a traceback
> > > with 1.3.1, which may be self-induced. Here is my views file:
> >
> > > auth/views.py
> > > from django.http import HttpResponse
> > > from django.utils import simplejson
> > > from django.views.decorators.csrf import csrf_exempt
> >
> > > @csrf_exempt
> > > def json_api(request):
> > >return HttpResponse(simplejson.dumps(request),
> > > mimetype="application/json")
> >
> > > When I do a curl:
> >
> > > curl -i -X POST -d '{"screencast":{"subject":"tools"}}'
> > >http://127.0.0.1:8000/auth/
> >
> > > I experience 500 Internal Server Error:
> >
> > > Traceback (most recent call last):
> >
> > >  File "/Library/Python/2.7/site-packages/django/core/servers/
> > > basehttp.py", line 283, in run
> > >self.result = application(self.environ, self.start_response)
> >
> > >  File "/Library/Python/2.7/site-packages/django/core/handlers/
> > > wsgi.py", line 272, in __call__
> > >response = self.get_response(request)
> >
> > >  File "/Library/Python/2.7/site-packages/django/core/handlers/
> > > base.py", line 169, in get_response
> > >response = self.handle_uncaught_exception(request, resolver,
> > > sys.exc_info())
> >
> > >  File "/Library/Python/2.7/site-packages/django/core/handlers/
> > > base.py", line 218, in handle_uncaught_exception
> > >return callback(request, **param_dict)
> >
> > >  File "/Library/Python/2.7/site-packages/django/utils/decorators.py",
> > > line 93, in _wrapped_view
> > >response = view_func(request, *args, **kwargs)
> >
> > >  File "/Library/Python/2.7/site-packages/django/views/defaults.py",
> > > line 30, in server_error
> > >t = loader.get_template(template_name) # You need to create a
> > > 500.html template.
> >
> > >  File "/Library/Python/2.7/site-packages/django/template/loader.py",
> > > line 157, in get_template
> > >template, origin = find_template(template_name)
> >
> > >  File "/Library/Python/2.7/site-packages/django/template/loader.py",
> > > line 138, in find_template
> > >raise TemplateDoesNotExist(name)
> >
> > > --
> > > 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.
>
>

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



Best practices for calling an external service in a Django app

2012-05-11 Thread Thomas Orozco
Hi,

Here's my situation: one of my views needs to call an external service
(through a socket ; actually the said service is on the same server).

I don't even need to know about the service's response as I'll inquire
about it asynchronously in an effort to avoid delay on the user's end.

What are the best practices here ?
Should I open a socket connection each time I want to access the service?
Should I keep one open all the time in a separate thread?

Thanks in advance,

Thomas

-- 
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: Best practices for calling an external service in a Django app

2012-05-11 Thread Thomas Orozco
Thanks for the information!

Using celery was my first idea too, but here it is not practical as I'll be
transferring sensitive information through the socket and I'd rather avoid
having hanging around in the Celery queue.

So I guess opening the socket from inside the view code and then closing it
would be OK?
 Le 11 mai 2012 11:17, "Marcin Tustin"  a écrit :

> I use a celery task to make this sort of job asynchronous. The task makes
> a new connection to the "remote" (same server) service each time. This
> proves to be sufficiently fast.
>
> If you are making a lot of requests, the overhead of making new
> connections may prove to be significant. I wouldn't anticipate this unless
> you are making a new request more frequently than perhaps once a second
> (and even then, I would wait and see what performance was like).
>
> On Fri, May 11, 2012 at 9:50 AM, Thomas Orozco 
> wrote:
>
>> Hi,
>>
>> Here's my situation: one of my views needs to call an external service
>> (through a socket ; actually the said service is on the same server).
>>
>> I don't even need to know about the service's response as I'll inquire
>> about it asynchronously in an effort to avoid delay on the user's end.
>>
>> What are the best practices here ?
>> Should I open a socket connection each time I want to access the service?
>> Should I keep one open all the time in a separate thread?
>>
>> Thanks in advance,
>>
>> Thomas
>>
>> --
>> 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.
>>
>
>
>
> --
> Marcin Tustin
> Tel: 07773 787 105
>
>  --
> 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: ForeignKey and Performance

2012-06-08 Thread Thomas Orozco
Why not use a lookup:

TheA = ...
TheCs = C.objects.filter(b__a = TheA)
Le 8 juin 2012 15:01, "bo.schwarzst...@gmail.com" 
a écrit :

> **
> Hi all,
>
> Is there any guideline about SQL performance ?
>
> For example, now we have 3 models,
>
> class A(Model):
> ...
>
> class B(Model):
> a = ForeignKey(A)
> ...
>
> class C(Model):
> b = ForeignKey(B)
> ...
>
> the most database records are instances of C, user need to access C from
> B, B from A under the hierarchical structure, now I collect the instances
> of C like this,
>
> theA = A.objects.get(name = 'theA')
> theBs = theA.b_set.filter(a = theA)
> for theB in theBs:
> theCs = theB.c_set.all()
>
> So should I add a new ForeignKey to C and filter the objects by (a =
> theA, b = theB) ? Is there any performance impact for SQL database ?
> Thanks !
>
> --
> 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: Upload a valid image. The file you uploaded was either not an image or a corrupted image.

2012-07-01 Thread Thomas Orozco
Do you have jpeg support installed for PIL?
Le 1 juil. 2012 18:13, "Nikhil Verma"  a écrit :

>
> Hi All
>
> I am trying to add jpeg image in a ImageField. and it gives this error .
> It is not allowing me to save the image.
>
> I have installed PIL and image other utilities.
>
> Upload a valid image. The file you uploaded was either not an image or a
> corrupted image.
>
> Can anybody point what is missing ?
>
> Thanks in advance
>
>
> --
> 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.
>

-- 
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: Upload a valid image. The file you uploaded was either not an image or a corrupted image.

2012-07-01 Thread Thomas Orozco
Installing the packages through apt-get gave you the error?

Could you please post the full output of the apt-get command?
Le 1 juil. 2012 18:27, "Nikhil Verma"  a écrit :

> HI Thomos
>
>
> I tried what you suggest and i recieved this.
>
> sudo apt-get install libjpeg libjpeg-dev libfreetype6 libfreetype6-dev 
> zlib1g-dev
>
> Traceback (most recent call last):
>   File "/home/nikhil/Citysom/bin/easy_install", line 8, in 
>
> load_entry_point('setuptools==0.6c11', 'console_scripts', 
> 'easy_install')()
>   File 
> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",
>  line 1712, in main
>
>   File 
> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",
>  line 1700, in with_ei_usage
>   File 
> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",
>  line 1716, in 
>
>   File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
> dist.run_commands()
>   File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
> self.run_command(cmd)
>
>   File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
> cmd_obj.run()
>   File 
> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",
>  line 211, in run
>
>   File 
> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",
>  line 434, in easy_install
>   File 
> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/package_index.py",
>  line 475, in fetch_distribution
>
> AttributeError: 'NoneType' object has no attribute 'clone'
>
>
> Thanks for help
>
>
>
>
> On Sun, Jul 1, 2012 at 9:53 PM, Thomas Orozco 
> wrote:
>
>> Do you have jpeg support installed for PIL?
>> Le 1 juil. 2012 18:13, "Nikhil Verma"  a
>> écrit :
>>
>>>
>>> Hi All
>>>
>>> I am trying to add jpeg image in a ImageField. and it gives this error .
>>> It is not allowing me to save the image.
>>>
>>> I have installed PIL and image other utilities.
>>>
>>> Upload a valid image. The file you uploaded was either not an image or a
>>> corrupted image.
>>>
>>> Can anybody point what is missing ?
>>>
>>> Thanks in advance
>>>
>>>
>>> --
>>> 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.
>>>
>>  --
>> 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.
>

-- 
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: Management form in Model Formsets

2012-07-01 Thread Thomas Orozco
You might want to check this snippet out: djangosnippets.org/snippets/1389*/
*
Le 1 juil. 2012 06:27, "Knight Samar"  a écrit :

> Hi,
>
> I am using Django 1.2 and developing using Model formsets. Using
> JavaScript, I am allowing the user to dynamically "Add another" formset on
> the template, but I can't figure out what exactly I have to modify in the
> management forms, for all the formsets to be successfully saved.
>
> The documentation points out to three properties in the management form -
> form-TOTAL_FORMS, form-INITIAL_FORMS and form-MAX_NUM_FORMS. But I don't
> understand, which properties I have to exactly modify and how, when a new
> formset is being added dynamically using JavaScript ?
>
> Thanks :)
>
> Regards,
> Samar
>
> --
> 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/-/Ecs6EVDku_YJ.
> 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: Upload a valid image. The file you uploaded was either not an image or a corrupted image.

2012-07-01 Thread Thomas Orozco
Now that the required packages are installed, could you try removing PIL
and reinstalling?

To remove PIL, find the installation directory and the egg and remove them
from your system. Then, I reinstall using apt, easy install or pip. Don't
forget to sudo.
Le 1 juil. 2012 18:38, "Nikhil Verma"  a écrit :

> HI Thomos
>
> I tried this
>
> nikhil@nikhil-desktop:~$ sudo apt-get install libjpeg libjpeg-dev
> libfreetype6-dev zlib1g-dev
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> Note, selecting 'libjpeg62-dev' instead of 'libjpeg-dev'
> E: Unable to locate package libjpeg
> nikhil@nikhil-desktop:~$ sudo apt-get install libjpeg-dev
> libfreetype6-dev zlib1g-dev
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> Note, selecting 'libjpeg62-dev' instead of 'libjpeg-dev'
> zlib1g-dev is already the newest version.
> zlib1g-dev set to manually installed.
> libfreetype6-dev is already the newest version.
> libfreetype6-dev set to manually installed.
> The following packages were automatically installed and are no longer
> required:
>   libopenraw1 libbabl-0.1-0 libgegl-0.2-0 libgimp2.0 gimp-data
> Use 'apt-get autoremove' to remove them.
> The following NEW packages will be installed:
>   libjpeg62-dev
> 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
> Need to get 192 kB of archives.
> After this operation, 500 kB of additional disk space will be used.
> Do you want to continue [Y/n]? Y
> Get:1 http://archive.ubuntu.com/ubuntu/ oneiric/main libjpeg62-dev amd64
> 6b1-1ubuntu2 [192 kB]
> Fetched 192 kB in 3s (57.9 kB/s)
> Selecting previously deselected package libjpeg62-dev.
> (Reading database ... 302567 files and directories currently installed.)
> Unpacking libjpeg62-dev (from .../libjpeg62-dev_6b1-1ubuntu2_amd64.deb) ...
> Setting up libjpeg62-dev (6b1-1ubuntu2) ...
> nikhil@nikhil-desktop:~$
>
>
> Still the same error.
>
>
>
> On Sun, Jul 1, 2012 at 10:02 PM, Thomas Orozco 
> wrote:
>
>> Installing the packages through apt-get gave you the error?
>>
>> Could you please post the full output of the apt-get command?
>> Le 1 juil. 2012 18:27, "Nikhil Verma"  a
>> écrit :
>>
>>  HI Thomos
>>>
>>>
>>> I tried what you suggest and i recieved this.
>>>
>>> sudo apt-get install libjpeg libjpeg-dev libfreetype6 libfreetype6-dev 
>>> zlib1g-dev
>>>
>>> Traceback (most recent call last):
>>>   File "/home/nikhil/Citysom/bin/easy_install", line 8, in 
>>>
>>>
>>>
>>> load_entry_point('setuptools==0.6c11', 'console_scripts', 
>>> 'easy_install')()
>>>   File 
>>> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",
>>>  line 1712, in main
>>>
>>>
>>>
>>>   File 
>>> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",
>>>  line 1700, in with_ei_usage
>>>   File 
>>> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",
>>>  line 1716, in 
>>>
>>>
>>>
>>>   File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
>>> dist.run_commands()
>>>   File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
>>> self.run_command(cmd)
>>>
>>>
>>>
>>>   File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
>>> cmd_obj.run()
>>>   File 
>>> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",
>>>  line 211, in run
>>>
>>>
>>>
>>>   File 
>>> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",
>>>  line 434, in easy_install
>>>   File 
>>> "/home/nikhil/Citysom/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/package_index.py",
>>>  line 475, in fetch_distribution
>>>
>>>
>>>
>>> AttributeError: 'NoneType' object has no attribute 'clone'
>>>
>>>
>>> Thanks for help
>>>
>>>
>>>
>

Re: Upload a valid image. The file you uploaded was either not an image or a corrupted image.

2012-07-01 Thread Thomas Orozco
Did you get any error messages during the PIL instalation that indicated
why jpeg support was unavailable? Specifically, which files could not be
found?

Maybe you don't have the correct roots included?

I'm not sure Django (that's what you're using, using right?) would use
pillow, especially when PIL is available too.
Le 1 juil. 2012 19:34, "Nikhil Verma"  a écrit :

> HI Thomos
>
> I also installed pillow and now it shows th support but i am having the
> same error.
>
> 
> SETUP SUMMARY (Pillow 1.7.7 / PIL 1.1.7)
> 
> version   1.7.7
> platform  linux2 2.7.2+ (default, Oct  4 2011, 20:06:09)
>   [GCC 4.6.1]
> 
> *** TKINTER support not available (Tcl/Tk 8.5 libraries needed)
> --- JPEG support available
> --- ZLIB (PNG/ZIP) support available
> --- FREETYPE2 support available
> *** LITTLECMS support not available
> 
> To add a missing option, make sure you have the required
> library, and set the corresponding ROOT variable in the
> setup.py script.
>
> To check the build, run the selftest.py script.
> changing mode of build/scripts-2.7/pilfont.py from 664 to 775
> changing mode of build/scripts-2.7/pilfile.py from 664 to 775
> changing mode of build/scripts-2.7/pilprint.py from 664 to 775
> changing mode of build/scripts-2.7/pildriver.py from 664 to 775
> changing mode of build/scripts-2.7/pilconvert.py from 664 to 775
>
> warning: no previously-included files found matching '.hgignore'
> warning: no previously-included files found matching '.hgtags'
> warning: no previously-included files found matching 'BUILDME.bat'
> warning: no previously-included files found matching 'make-manifest.py'
> warning: no previously-included files found matching 'SHIP'
> warning: no previously-included files found matching 'SHIP.bat'
> warning: no previously-included files matching '*' found under
> directory 'Tests'
> changing mode of /home/nikhil/Citysom/bin/pilfont.py to 775
> changing mode of /home/nikhil/Citysom/bin/pilfile.py to 775
> changing mode of /home/nikhil/Citysom/bin/pilprint.py to 775
> changing mode of /home/nikhil/Citysom/bin/pildriver.py to 775
> changing mode of /home/nikhil/Citysom/bin/pilconvert.py to 775
> Successfully installed pillow
> Cleaning up...
> (Citysom)nikhil@nikhil-desktop:~/Citysom/citysom$ python manage.py
> runserver 8080
>
>
> On Sun, Jul 1, 2012 at 10:37 PM, Nikhil Verma wrote:
>
>> Hi Thomos
>>
>> As you said i reinstalled it and in my  virtualenv  i did
>>
>> pip install -I pil
>>
>> It succesfully installed and i get this
>>
>> 
>>
>>
>> PIL 1.1.7 SETUP SUMMARY
>> 
>> version   1.1.7
>> platform  linux2 2.7.2+ (default, Oct  4 2011, 20:06:09)
>>   [GCC 4.6.1]
>>
>>
>> 
>> *** TKINTER support not available (Tcl/Tk 8.5 libraries needed)
>> *** JPEG support not available
>> *** ZLIB (PNG/ZIP) support not available
>>
>>
>> *** FREETYPE2 support not available
>> *** LITTLECMS support not available
>> 
>> To add a missing option, make sure you have the required
>>
>>
>> library, and set the corresponding ROOT variable in the
>> setup.py script.
>>
>> To check the build, run the selftest.py script.
>> changing mode of build/scripts-2.7/pilfont.py from 664 to 775
>> changing mode of build/scripts-2.7/pilfile.py from 664 to 775
>>
>>
>> changing mode of build/scripts-2.7/pilprint.py from 664 to 775
>> changing mode of build/scripts-2.7/pildriver.py from 664 to 775
>> changing mode of build/scripts-2.7/pilconvert.py from 664 to 775
>>
>>
>>
>> Removing 
>> /home/nikhil/Citysom/lib/python2.7/site-packages/PIL/PIL-1.1.7-py2.7.egg-info
>> changing mode of /home/nikhil/Citysom/bin/pilfont.py to 775
>> changing mode of /home/nikhil/Citysom/bin/pilfile.py 

Re: settings and constants on a reusable app

2012-07-01 Thread Thomas Orozco
Have a default settings, that you only use when the required setting is not
found in the actual settings file.
Le 30 juin 2012 20:09, "Bill Freeman"  a écrit :

> Support an additional variable MY_APP_USE_OTHER_CONSTANT (MY and
> MY_APP, are, I hope, not the prefixes you are actually using), which
> defaults to False and which the project settings file can override to
> True.
>
> On Fri, Jun 29, 2012 at 9:06 AM, Marc Aymerich 
> wrote:
> > On Fri, Jun 29, 2012 at 11:08 AM, Thomas Rega  wrote:
> >> Am 28.06.12 17:30, schrieb Marc Aymerich:
> >>
> >>> Hi,
> >>> I'm developing a reusable application and I'm having troubles with
> >>> constant values on settings.
> >>>
> >>> Imagine that the reusable application comes with the following
> settings.py
> >>>
> >>> # MY_APP/settings.py
> >>> from django.conf import settings
> >>> MY_CONSTANT = 'C1'
> >>> MY_OTHER_CONSTANT =  'C2'
> >>> MY_SETTING = getattr(settings, 'MY_SETTING', CONSTANT)
> >>>
> >>>
> >>> But for your project you want to override the default value of
> >>> MY_SETTING by MY_OTHER_CONSTANT. So you edit your project settings.py
> >>> and adds these two lines:
> >>>
> >>> # Project settings.py
> >>> 
> >>> from MY_APP.settings import settings as my_app_settings
> >>> MY_SETTING = my_app_settings.MY_OTHER_SETTING
> >>>
> >>>
> >>> But this is going to fail because of the import order.
> >>>
> >>> Is there any consistent way to handle this situation?
> >>>
> >>> Thanks!
> >>
> >> Hi,
> >>
> >> what about the idea to overwrite these values via a 'local_settings.py'
> >> file?
> >>
> >> An example can be found here:
> >>
> https://bitbucket.org/chris1610/satchmo/src/1255b19295c7/satchmo/projects/skeleton/settings.py
> >
> > Hi thomas, thanks :)
> >
> > Yeah, actually I'm using a local_settings.py file, but at the end it
> > will be the same as using settings.py since local_settings.py is
> > imported by settings.py. :(
> >
> >
> > --
> > Marc
> >
> > --
> > 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.
>
>

-- 
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: Problem with DetailView

2012-07-08 Thread Thomas Orozco
Could you give us the fill error message displaying what ended up being
passed to the view?

Also, are you sure a car exists with the id / pk you're passing?
Le 7 juil. 2012 23:10, "Soviet"  a écrit :

> But the ListView is working fine. And they don't use  in the
> documentation, just this, which I modified to fit my model:
>
> urlpatterns = patterns('',
> (r'^publishers/$', ListView.as_view(
> model=Publisher,
> )),
> )
>
> W dniu sobota, 7 lipca 2012 22:44:23 UTC+2 użytkownik Sam007 napisał:
>>
>> If I am not wrong. The issue is with the List View not Detail View.
>>
>> You need to provide, List View with query set. If you are providing model
>> parameter, you will also need to give it a primary key 'pk', like you did
>> for Detail View.
>>
>> Hope that helps,
>> Smaran
>> On Jul 7, 2012 3:36 PM, "Soviet"  wrote:
>>
>>> Now that I have basic understanding of models, I encountered even more
>>> confusing subjects - views and urls. Now, the class-generic views are quite
>>> easy to grasp at basic level, but I fail to understand what's wrong with
>>> this code:
>>>
>>> urlpatterns = patterns('',
>>> (r'^$', ListView.as_view(
>>> model=Car,
>>> context_object_name="cars_**list",
>>> template_name='data/cars_list.**html',
>>> )),
>>> (r'^(?P\d+)/$', DetailView.as_view(
>>> model=Car,
>>> context_object_name="car_**details",
>>> template_name='data/car_**details.html',
>>> )),
>>> )
>>>
>>> The ListView is working fine, but when I try to get the details about
>>> single car, all I'm getting is error: "No car found matching the query". I
>>> tried adding 'queryset = Car.objects.all()' both in urls.py and in
>>> views.py, creating custom class, but the error persists.
>>>
>>> --
>>> 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/-/**fQZA1sl13VkJ
>>> .
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to django-users+unsubscribe@*
>>> *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 view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/2RYQ-kplLroJ.
> 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: how to use HTTPS with django

2012-07-08 Thread Thomas Orozco
This comes down to a simple middleware that intercepts http requests and
redirects them to https. This is very to do in django.

You can find plenty of such middleware on djangosnippets.

Now, if your app is running behind a reverse proxy (e.g. nginx + gunicorn)
,  things get a little bit more complicated as your proxy needs to tell the
django app whether the request was originally https of http.

This is easy to do, but not very well documented in django. Look at the
settings reference for the appropriate ones.


Alternatively,  you could achieve the same thing at webserver level. But
having worked with both setups, using a middleware is a lot easier to
setup.

Now, you might find doing it at webserver level more appropriate, that's a
matter of personal preference.
Le 7 juil. 2012 11:26, "Timothy Makobu"  a
écrit :

> I would think he would have areas that need to be logged in to all SSL. He
> already has the cert for SSL logins, and its prudent these days to have
> such apps all SSL, with tools making it straight forward to lift
> unencrypted traffic off a network.
>
> On Sat, Jul 7, 2012 at 11:28 AM, Melvyn Sopacua wrote:
>
>> On 7-7-2012 10:27, Timothy Makobu wrote:
>> > " I want to know how to use HTTPS to securely login ..." which satisfies
>> > the first part of the question. This way it wont be possible to login
>> > without HTTPS enabled for the project.
>>
>> What use is logging in if you're logged out the minute the connection
>> becomes unencrypted?
>>
>> --
>> Melvyn Sopacua
>>
>>
>> --
>> 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.
>

-- 
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: Missing 'SITE_ID' breaks first Django app

2012-07-08 Thread Thomas Orozco
What is kills the whole app supposed to mean?

Just pulling this out of thin air, but do you have a record in your
database (sites)  that corresponds to your SITE_ID setting (when you add
it)
Le 6 juil. 2012 13:43, "Melvyn Sopacua"  a écrit :

> On 6-7-2012 7:38, DF wrote:
>
> > Hi. I just delayed my first Django app via Heroku and I'm having an issue
> > that's proving very difficult to resolve. I have django-registration and
> > profiles installed and apparently something runs afoul unless the
> > 'django.contrib.sites', and SITE_ID is removed from settings (this wasn't
> > the case prior to deployment).
>
> But what is the error here? Site doesn't display? server errors?
> --
> Melvyn Sopacua
>
>
> --
> 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: Cacheing and JSON

2012-07-08 Thread Thomas Orozco
I think you're going to need to provide more context here.

Are you telling us that reading from your database takes minutes?

Do your remote clients periodically  poll your api?

What's the overall flow and what's the issue you have?

I hardly believe that caching is useful here,  unless you're telling us
that you actually need several minutes to produce your json output, which I
find even harder to believe.
Le 6 juil. 2012 22:45, "Kevin Anthony"  a écrit :

-- 
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: how to use HTTPS with django

2012-07-08 Thread Thomas Orozco
That's indeed a valid point, if you're going to deploy multiple services
behind a webserver it does make sense to do it at webserver level as you'll
avoid duplicating your efforts.

Now, using middleware that redirects to https does not have to be "a hack",
andif django changes to the point  that your middleware breaks, there will
probably be a lot of other issues :-)
Le 8 juil. 2012 15:39, "John Yeukhon Wong"  a écrit :

> I agree, but I think at the web server level is much better. Middlewares
> can break if Django core changes a lot, and since they are third-party hack
> code, so unless you are confident how to maintain it yourself, don't use
> them. Apache, Nginx configurations are widely used so they are easier to
> get help nowadays. That is not to say that many middlewares I've seen over
> the years are bad. I've used a few of those on snippets :) They are great.
>
> And for many people, there is usually more than one Django site, or
> multiple applications deploy (custom backend, etc) which run as HTTP
> services too. So enabling SSL at server level is a lot easier to maintain.
>
>
>
> On Sunday, July 8, 2012 5:47:01 AM UTC-4, Thomas Orozco wrote:
>>
>> This comes down to a simple middleware that intercepts http requests and
>> redirects them to https. This is very to do in django.
>>
>> You can find plenty of such middleware on djangosnippets.
>>
>> Now, if your app is running behind a reverse proxy (e.g. nginx +
>> gunicorn) ,  things get a little bit more complicated as your proxy needs
>> to tell the django app whether the request was originally https of http.
>>
>> This is easy to do, but not very well documented in django. Look at the
>> settings reference for the appropriate ones.
>>
>>
>> Alternatively,  you could achieve the same thing at webserver level. But
>> having worked with both setups, using a middleware is a lot easier to
>> setup.
>>
>> Now, you might find doing it at webserver level more appropriate, that's
>> a matter of personal preference.
>> Le 7 juil. 2012 11:26, "Timothy Makobu"  a
>> écrit :
>>
>>> I would think he would have areas that need to be logged in to all SSL.
>>> He already has the cert for SSL logins, and its prudent these days to have
>>> such apps all SSL, with tools making it straight forward to lift
>>> unencrypted traffic off a network.
>>>
>>> On Sat, Jul 7, 2012 at 11:28 AM, Melvyn Sopacua 
>>> wrote:
>>>
>>>> On 7-7-2012 10:27, Timothy Makobu wrote:
>>>> > " I want to know how to use HTTPS to securely login ..." which
>>>> satisfies
>>>> > the first part of the question. This way it wont be possible to login
>>>> > without HTTPS enabled for the project.
>>>>
>>>> What use is logging in if you're logged out the minute the connection
>>>> becomes unencrypted?
>>>>
>>>> --
>>>> Melvyn Sopacua
>>>>
>>>>
>>>> --
>>>> 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+unsubscribe@
>>>> **googlegroups.com .
>>>> For more options, visit this group at http://groups.google.com/**
>>>> group/django-users?hl=en<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+unsubscribe@*
>>> *googlegroups.com .
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en<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 view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/SLdmJ-KSqN8J.
> 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: Directory indexes are not allowed here. for Grappilli

2012-07-16 Thread Thomas Orozco
What is your actual problem here?

Do you not understand the message? Do you have a reason for which you'd
want this directory indexed?
Le 16 juil. 2012 13:24, "chhots"  a écrit :

> Page not found (404)  Request Method: GET  Request URL:
> http://localhost:8080/static/grappelli/
>
> Directory indexes are not allowed here.
>
> You're seeing this error because you have DEBUG = True in your Django
> settings file. Change that to False, and Django will display a standard
> 404 page.
>
> Plz help
>
>
>  --
> 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/-/Osk9n9mFErAJ.
> 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: Template Loader Error: (It's been really frustrating till now..!)

2012-07-18 Thread Thomas Orozco
You can also have a "templates"  directory in any app of yours and Django
will pick them up from there.

It's also best practice to start your template path with your app name. For
instance: myapp/templates/myapp/my template.html
Or; mytemplatedir/myapp/mytemplate.html

Indeed  django does not elect to use templates from a given app over
another, so if two apps have a template with the same name, you're in
trouble.
Only the templates from your Template dirs have higher priority.

This also makes overriding templates easier should you decide to
redistribute your app, as one can have a myapp directory in their template
dir to override your templates, as templates from this folder will have
higher priority than those from the App dir.
Le 19 juil. 2012 07:18, "Anoop Thomas Mathew"  a écrit :

>
> On 19 July 2012 04:46, Mark Anderko  wrote:
>
>> I am having similar problems. did you manage to get this fixed?
>>
>>
>> On Wednesday, January 25, 2012 6:51:34 AM UTC-8, leaks wrote:
>>>
>>> Hey all...  i get this error while i have a template directory and my
>>> about.html file It doesn't display the home.html either...
>>>
>>> Environment:
>>>
>>>
>>> Request Method: GET
>>> Request URL: http://127.0.0.1:8000/about/
>>>
>>> Django Version: 1.3.1
>>> Python Version: 2.7.2
>>> Installed Applications:
>>> ['django.contrib.auth',
>>>  'django.contrib.contenttypes'**,
>>>  'django.contrib.sessions',
>>>  'django.contrib.sites',
>>>  'django.contrib.messages',
>>>  'django.contrib.staticfiles']
>>> Installed Middleware:
>>> ('django.middleware.common.**CommonMiddleware',
>>>  'django.contrib.sessions.**middleware.SessionMiddleware',
>>>  'django.middleware.csrf.**CsrfViewMiddleware',
>>>  'django.contrib.auth.**middleware.**AuthenticationMiddleware',
>>>  'django.contrib.messages.**middleware.MessageMiddleware')
>>>
>>> Template Loader Error:
>>> Django tried loading these templates, in this order:
>>> Using loader django.template.loaders.**filesystem.Loader:
>>> /home/tony/Documents/blog/**blog/templates/about.html (File does not
>>> exist)
>>>
>>
>
> make sure that /home/tony/Documents/blog/blog/templates/about.html exist.
> Else, add templates directory to the TEMPLATE_DIRS.
>
>
> Using loader django.template.loaders.app_**directories.Loader:
>>>
>>>
>>>
>>> Traceback:
>>> File "/usr/local/lib/python2.7/**dist-packages/django/core/**handlers/
>>> base.py" in get_response
>>>   111. response = callback(request,
>>> *callback_args, **callback_kwargs)
>>> File "/home/tony/Documents/blog/../**blog/views.py" in about
>>>   9.  return render_to_response('about.**html',)
>>> File "/usr/local/lib/python2.7/**dist-packages/django/**shortcuts/
>>> __init__.py" in render_to_response
>>>   20. return HttpResponse(loader.render_to_**string(*args,
>>> **kwargs), **httpresponse_kwargs)
>>> File "/usr/local/lib/python2.7/**dist-packages/django/template/
>>> loader.py" in render_to_string
>>>   181. t = get_template(template_name)
>>> File "/usr/local/lib/python2.7/**dist-packages/django/template/
>>> loader.py" in get_template
>>>   157. template, origin = find_template(template_name)
>>> File "/usr/local/lib/python2.7/**dist-packages/django/template/
>>> loader.py" in find_template
>>>   138. raise TemplateDoesNotExist(name)
>>>
>>> Exception Type: TemplateDoesNotExist at /about/
>>> Exception Value: about.html
>>
>>  --
>> 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/-/b7u_nPwieJMJ.
>>
>> 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.
>

-- 
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: INSTALLED Grappelli App and getting some error

2012-07-18 Thread Thomas Orozco
Never use grappeli so take this advice for what it's worth, but did you
check the version compatibility of your grappeli install and your django
install?
Le 18 juil. 2012 20:12, "chhots"  a écrit :

> TemplateSyntaxError at /admin/
>
> 'url' is not a valid tag library: Template library url not found, tried 
> django.templatetags.url,element.grappelli.templatetags.url,django.contrib.admin.templatetags.url
>
>
> plz help
>
> --
> 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/-/bB26jUPm6h4J.
> 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: Tutorial question

2012-07-19 Thread Thomas Orozco
A model is just a class, so the methods just "go there", yes.

You could check out apps in django.contrib for styling best practices (the
django doc itself also covers this I think*,* but I can't remember where)
Le 17 juil. 2012 19:49, "jeffsarge"  a écrit :

> Hi,
> I'm learning Django and Python at the same time.  Going through the Django
> tutorial (writing your first Django app)
> Going smooth until I hit the part where I need to add a unicode method to
> both Poll and Choice:
>
> def __unicode__(self):
> return self.question
>
> same with the custom methods that are supposed to be added (def
> was_published_recently(self):
>
> Do these just get stuck onto the end of my class Poll(models.Model):?
>  like this...
>
> class Poll(models.Model):
> question = models.CharField(max_length=200)
> pub_date = models.DateTimeField('date published')
>
> def __unicode__(self):
>
> return self.question
>
> def was_published_recently(self):
> return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
>
> I'm not sure what the correct way is to add this code to the python
> classes I created earlier in the polls/models.py
> Any ideas?
>
> thanks,
> Jeff
>
>
>
>
>
>
>
>  --
> 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/-/2h8gM7CDls8J.
> 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: many "Broken INTERNAL link" with end string "/undefined/"

2012-07-19 Thread Thomas Orozco
Did you visit the page where the broken link exists with the same browser
as your user and searched for :
  + JS warnings
  + JS errors
  + Requests on the broken link
  + The actual broken url somewhere in the DOM tree

Chrome has an integrated full featured debugger, you could use it.

The problem isn't going to automatically go away nor the explanation show
up in your mailbox.

Le 10 juil. 2012 09:21, "ferran"  a écrit :
>
> Hello Melvyn,
>
> I'm found this information
http://stackoverflow.com/questions/11017609/undefined-randomly-appended-in-1-of-requested-urls-on-my-website-since-12-jun
>
> I'm have too:
>
> Referrer: http://www.marquezshop.com/es/catalogo/ofertas/
> Requested URL:
/es/catalogo/ofertas/cache/a8790cb719ffd4424219786bc76da1a4/
> User agent: Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/536.11
(KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11
> IP address: x
>
>
> What is cache/hash?
>
>
> Thanks in advanced
>
>
>
>
>
> On Wednesday, July 4, 2012 2:47:20 PM UTC+2, Melvyn Sopacua wrote:
>>
>> On 4-7-2012 9:55, ferran wrote:
>> > Hello,
>> >
>> > I'm update javascript libraries:
>> > - Jquery from
>> > http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js to
http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
>> > - Jquery ui from
>> > http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.jsto
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js
>> >
>> > But not is a solutions, the problem persist...
>>
>> Upgrades aren't solutions. They only dress up as them in their spare
time.
>>
>> You should:
>> 1) Identify where you generate links via javascript
>> 2) Identify what javascript variable is passed to the link
>> 3) Identify how it can be undefined
>>
>> If you don't see how it can be, undefined, use the appropriate
>> javascript forums / documentation.
>>
>> --
>> Melvyn Sopacua
>>
>>
> --
> 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/-/O8_xSSwcqnUJ.
>
> 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: SuspiciousOperation exception on ImageField upload

2012-07-19 Thread Thomas Orozco
Here you're trying to upload to a directory, whose path starts with a / :
/images.

On *nix,  / means system root. Obviously your django process does not have
permission to write there unless you set that up so.

You should remove the leading slash in your upload to path. Your files will
then upload to your media root.

Then  make sure that your Web process has:

.  write access to the MEDIA_ROOT/images directory (unless the user is the
owner of MEDIA_ROOT, it won't have permission to create a directory.)

.  Execution permission on all the directories (not the files in there)
leading to MEDIA_ROOT: Execution permission on a directory means traversal
permission.

Don't just chmod -R 777 your way out of this kind of problem, you're going
to create major security holes.
Le 18 juil. 2012 17:39, "Sithembewena Lloyd Dube"  a
écrit :

> Hi Binny,
>
> Your problem sounds like one I had months ago. I got this response at the
> time:
>
> You need to make sure that the same process running your python
> interpreter has write permissions to your media directory.
>
> From StackOverflow:
> "The process that is running your Python interpreter doesn't have
> permission to write into the media directory. You'll need to either chgrp
>  or chrown the media directory to the same group as your Python process,
> and ensure you have at least g+rwx on directories and g+rw on files."
>
> http://stackoverflow.com/questions/5543641/django-media-upload-errno-13-permission-denied
>
>
>
> On Wed, Jul 18, 2012 at 9:12 AM, binny  wrote:
>
>> But i want to upload to following path..
>>
>> /usr/local/apache2/htdocs/goibibo/travelibibo/static/refundsReports/%Y%m%d
>>
>> And the first back slash is must. I can't remove that. So please let me
>> know how can i handle this case.
>>
>> Thanks,
>> Binny
>>
>>
>> On Tuesday, August 19, 2008 6:17:16 PM UTC+5:30, Jon Atkinson wrote:
>>>
>>> Hello,
>>>
>>> I'm trying to work with a model which accepts a logo image upload via
>>> an ImageField. My a cut down version of my model is below:
>>>
>>> class Promoter(models.Model):
>>> name = models.CharField(max_length=**100)
>>> logo = models.ImageField(upload_to="/**
>>> images/promoters/%Y/%m/%d/")
>>>
>>> When I try to upload the logo via the built-in admin interface, I get
>>> the following error:
>>>
>>> SuspiciousOperation at /admin/promoters/promoter/add/
>>> Attempted access to '/images/promoters/2008/08/19/**kitten.jpg' denied.
>>>
>>> In settings.py, my MEDIA_ROOT is set to an accessible directory in my
>>> home folder: '/home/username/projectname/**media/', and this folder has
>>> it's permissions set to 777.
>>>
>>> I'm currently using the ./manage.py webserver, which (I assume) runs
>>> as the same user which starts the process; this is the same user as
>>> owns the folder specified above.
>>>
>>> Any ideas what I'm doing wrong here?
>>>
>>> --Jon
>>>
>>>  --
>> 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/-/5DiLmGCf_E0J.
>> 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,
> Sithembewena Lloyd Dube
>
> --
> 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: CachedStaticFilesStorage unavailable in debug mode

2012-07-19 Thread Thomas Orozco
CachedStaticFiledStorage will work, only it will not append the hashes as
it usually does and behave like a standard file storage.

The use case for this storage is to set very long expires dates on the
static files and rely and their url changing (due to the hash changing )
whenever you change them, which causes a cache refresh for thé end user
browser only and systemically when neefed. (which totally rocks)

Now, this means that the webserver (nginx, apache)  must set the
appropriate expires headers on the static files.

These won't be set with the development server, and you probably won't
bother doing it even if you develop with an actual webserver.

So there's no use for hashes. But they still cause a performance drop. So
django just falls back to a standard storage.


I think that if you definitely need it for test just copy it and change it
so it works with debug true.
Le 18 juil. 2012 21:39, "Marwan Al-Sabbagh"  a
écrit :

> Hi,
>   so as explained in the docs CachedStaticFilesStorage will not be applied
> if DEBUG setting is set to False. I just wanted to understand why this is
> the case. I have a development environment and want to use
> CachedStaticFilesStorage. thanks.
>
> cheers,
> Marwan
>
> --
> 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: Query with 3 models

2012-07-19 Thread Thomas Orozco
Shouldn't that be a prefetch related and not select related?
Le 19 juil. 2012 16:52, "Tomas Neme"  a écrit :

>
> > {Empresa1, Sucursal1, Platillo1, Horario1},
> > {Empresa1, Sucursal1, Platillo2, Horario1},
> > {Empresa2, Sucursal1, Platillo1, Horario1}...
>
> I'm guessing the Sucursal1 in the first and third lines are not the same?
> I mean, each Sucursal points to only one Empresa, so I'm guessing you want
> only the related objects
>
> if this is the case, you can do something like this:
>
> [(empresa, sucursal, platillo, horario) for empresa in
> Empresa.objects.all().select_related()
> for sucursal in
> empresa.sucursal_set.all()
> for platillo in
> empresa.platillo_set.all()
> for horario in
> empresa.horario_set.all()]
>
> that if what you want is a list. If you want just to loop through those,
> you can do
>
> for empresa in Empresa.objects.all().select_related():
> for sucursal in empresa.sucursal_set.all():
> for platillo in empresa.platillo_set.all():
> for horario in empresa.horario_set.all():
> do_something(empresa, sucursal, platillo, horario)
>
> and about the same thing if you want to cycle through them in a template,
> in which case you can just pass { 'empresas':
> Empresa.objects.all().select_related() } and then loop like above on the
> template side
>
> --
> "The whole of Japan is pure invention. There is no such country, there are
> no such people" --Oscar Wilde
>
> |_|0|_|
> |_|_|0|
> |0|0|0|
>
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.
>
> --
> 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: Checking if a dynamicallygenerated dropdown has a selected item

2012-07-23 Thread Thomas Orozco
Are you using django forms?

Should be pretty straightforward once you have the input nicely formatted
to just count the number of fields that have been filled in.
Le 23 juil. 2012 19:01, "Babatunde Akinyanmi"  a
écrit :

> Maybe I don't really understand the question but I think if you want
> to check if the user has answered 3 questions, check from the keys in
> request.GET or request.POST as the case may be.
>
> On 7/23/12, Sithembewena Lloyd Dube  wrote:
> > Hi all,
> >
> > I have a dynamically generated dropdown in this fashion (when viewing
> > source):
> >
> > 
> > > selected="selected">
> > > value="question_3_answer_7">a) Spend the majority of time
> indoors
> > > value="question_3_answer_8">b) Value superior darkness and consider
> in-car
> > activation
> > > value="question_3_answer_9">c) Value indoor clarity over outdoor
> > darkness
> > 
> >
> > 
> > > selected="selected">
> > > value="question_3_answer_7">a) Spend the majority of time
> indoors
> > > value="question_3_answer_8">b) Value superior darkness and consider
> in-car
> > activation
> > > value="question_3_answer_9">c) Value indoor clarity over outdoor
> > darkness
> > 
> >
> > How would one check, in a view, whether or not any of the dropdowns have
> a
> > selected item? I basically need to ensure that users answer at least 3
> out
> > of 5 questions?
> >
> > Thanks ...
> > --
> > Regards,
> > Sithembewena Lloyd Dube
> >
> > --
> > 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.
> >
> >
>
> --
> Sent from my mobile device
>
> --
> 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: Adding Button in admin form

2012-08-17 Thread Thomas Orozco
If you're using a ForeignKey for this field, you'll get this behavior by
default in the Django admin.
Le 17 août 2012 08:45, "Madhu"  a écrit :

> Hello,
>
> I want to add the button along with field in admin form.
>
> ex. Field name "URL" with the "Choose Page" button.
> If admin clicks on "Choose Page" button then some list from the database
> table will be display and admin select any one from that list.
>
> Can anybody help me to add the button in admin form?
>
> Thanks,
> Madhu
>
> --
> 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/-/wSJXqEJkYzoJ.
> 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: django makemessages doesn't recognize trans in templates

2012-08-17 Thread Thomas Orozco
You gave us the project layout, but where are the templates?

My guess is that Django is basically not picking them templates *up*, but I
might be off.

There are arguments to the makemessages command that can help you indicate
the directory you want messages created for. You can also use higher
verbosity I think.
I'm sorry I can't name them on the top of my head though.
Le 17 août 2012 04:16, "Jojo"  a écrit :

> Hi, the subject should be a little clear so, this is the project folder
> structure
>
> project folder
>  locale
>   en
> LC_MESSAGES
>   django.po
>   es
> LC_MESSAGES
>   django.po
>   it
> LC_MESSAGES
>   django.po
>   project
> __init__.py
> mochileros
> settings.py
> urls.py
> wsgi.py
>   application folder
> models.py
> views.py
>
>
> I have created a locale folder and after I launched the django-admin.py
> makemessages command as explained in the documentation, but when I open a
> .po file (the command create the files actually), I can't found
> the msgid/msgstr relative to the translation instruction in my template
> files.
> This is my base template.
>
> {% load i18n %}
>
> 
> 
> ...
> 
> {% trans "home" %}
> {% trans "contacts" %}
> {% trans "about_us" %}
> ...
> 
>
>
> I have added the LocaleMiddleware in the settings file so, do I forgot
> something?
> Any suggestions?
>
>
> Thank you in advance
>
> --
> 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/-/QT9zFkTK5zwJ.
> 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: Django Admin doesn't show all fields from model when registered.

2012-08-17 Thread Thomas Orozco
This is not really django specific, several objects bearing the same name
in the same namespace will always lead to trouble ; )
(And this is not even python specific)

Glad you could fix it and thanks for posting your solution in case someone
else has the same issue though. : )
Le 16 août 2012 21:01, "Babatunde Akinyanmi"  a
écrit :

> Ok I fixed it and in case someone else falls into such a trap, here's
> how I fixed it.
>
> My Answer model had a field with name 'is_correct' and had a method
> with name 'is_correct'. This confused django such that:
>
> >>> ans = Answer.objects.get(id=1)
> >>> ans.is_correct
> >
>
> So I changed the name of the 'is_correct' method and running the above
> in the code threw an error: .DatabaseError: column
> examprep_answer.is_correct does not exist.
>
> Drop my database and syncdb-ing got things back to normal.
>
> I think django should be able to detect such things and raise an error
> or there should be a note in the documentation warning people not to
> name their model methods with model field names.
>
> On 8/16/12, Tundebabzy  wrote:
> > Hi guys, here's bit of my code http://dpaste.com/hold/787292/
> >
> > The problem is that my Answer model in admin is missing the 'is_correct',
> > 'date_added' and 'modified' fields.
> >
> >
> > <
> https://lh4.googleusercontent.com/-FuxmFXdGVP4/UC0K_dwpIhI/ADI/deTk9J_tQOE/s1600/Screenshot+from+2012-08-16+15%3A57%3A35.png
> >
> >
> > I tried adding:
> > fieldsets = [
> >
> > (None,   {'fields':
> > ['text','is_correct','explanation']}),
> >
> > ]
> > to my AnswerInLine definition but that throws an ImproperlyConfigured
> error
> > saying:
> > 'AnswerInline.fieldsets[0][1]['fields']' refers to field 'is_correct'
> that
> > is missing from the form.
> >
> > Can anyone help out?
> >
> >
> > --
> > 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/-/qK1kFc-11lQJ.
> > 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.
> >
> >
>
> --
> Sent from my mobile device
>
> --
> 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: Auto login with external cookie from different system

2012-08-17 Thread Thomas Orozco
Huge props for having the python docs on localhost :-D
Le 16 août 2012 20:08, "Melvyn Sopacua"  a écrit :

> On 16-8-2012 6:02, Kurtis Mullins wrote:
>
> > Not all of us host the Python docs, locally, haha.
>
> Lies! But yea, forgot to check that so thanks :)
>
> --
> Melvyn Sopacua
>
> --
> 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: Adding Button in admin form

2012-08-17 Thread Thomas Orozco
Oh, yeah, sorry about that, it's an admin parameter that you must use,
can't recall the exact name, but it's something like id only.
Le 17 août 2012 09:41, "Madhu"  a écrit :

> Thanks for the replay.
>
> Using foreign key it creates dropdown list, but i want the URL as the
> character field and "Choose Page" button which having the function which
> retrieves the database query list.
>
>
> On Friday, August 17, 2012 12:51:35 PM UTC+5:30, Thomas Orozco wrote:
>>
>> If you're using a ForeignKey for this field, you'll get this behavior by
>> default in the Django admin.
>> Le 17 août 2012 08:45, "Madhu"  a écrit :
>>
>>> Hello,
>>>
>>> I want to add the button along with field in admin form.
>>>
>>> ex. Field name "URL" with the "Choose Page" button.
>>> If admin clicks on "Choose Page" button then some list from the database
>>> table will be display and admin select any one from that list.
>>>
>>> Can anybody help me to add the button in admin form?
>>>
>>> Thanks,
>>> Madhu
>>>
>>> --
>>> 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/-/**wSJXqEJkYzoJ<https://groups.google.com/d/msg/django-users/-/wSJXqEJkYzoJ>
>>> .
>>> To post to this group, send email to django...@googlegroups.com.
>>> To unsubscribe from this group, send email to django-users...@**
>>> googlegroups.com.
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en<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 view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/gsOd9uZzCUgJ.
> 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: Adding Button in admin form

2012-08-17 Thread Thomas Orozco
It's raw_id_fields! (see the docs for more detail : ) )

On your modeladmin, set that to a list including the name (as string) of
your field, and you should have what you want.

Let me know if I misunderstood.
Le 17 août 2012 09:47, "Thomas Orozco"  a écrit :

> Oh, yeah, sorry about that, it's an admin parameter that you must use,
> can't recall the exact name, but it's something like id only.
> Le 17 août 2012 09:41, "Madhu"  a écrit :
>
>> Thanks for the replay.
>>
>> Using foreign key it creates dropdown list, but i want the URL as the
>> character field and "Choose Page" button which having the function which
>> retrieves the database query list.
>>
>>
>> On Friday, August 17, 2012 12:51:35 PM UTC+5:30, Thomas Orozco wrote:
>>>
>>> If you're using a ForeignKey for this field, you'll get this behavior by
>>> default in the Django admin.
>>> Le 17 août 2012 08:45, "Madhu"  a écrit :
>>>
>>>> Hello,
>>>>
>>>> I want to add the button along with field in admin form.
>>>>
>>>> ex. Field name "URL" with the "Choose Page" button.
>>>> If admin clicks on "Choose Page" button then some list from the
>>>> database table will be display and admin select any one from that list.
>>>>
>>>> Can anybody help me to add the button in admin form?
>>>>
>>>> Thanks,
>>>> Madhu
>>>>
>>>> --
>>>> 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/-/**wSJXqEJkYzoJ<https://groups.google.com/d/msg/django-users/-/wSJXqEJkYzoJ>
>>>> .
>>>> To post to this group, send email to django...@googlegroups.com.
>>>> To unsubscribe from this group, send email to django-users...@**
>>>> googlegroups.com.
>>>> For more options, visit this group at http://groups.google.com/**
>>>> group/django-users?hl=en<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 view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/gsOd9uZzCUgJ.
>> 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: Adding Button in admin form

2012-08-17 Thread Thomas Orozco
I might be off, but I believe that they want to get a list of objects from
the database, a ForeignKey seems more appropriate here, or am I missing
something?
Le 17 août 2012 09:58, "Amyth Arora"  a écrit :

> Change the ModelField to type "CharField" and you should have a input
> box in the admin.
>
>
> On Fri, Aug 17, 2012 at 12:14 PM, Madhu  wrote:
> > Hello,
> >
> > I want to add the button along with field in admin form.
> >
> > ex. Field name "URL" with the "Choose Page" button.
> > If admin clicks on "Choose Page" button then some list from the database
> > table will be display and admin select any one from that list.
> >
> > Can anybody help me to add the button in admin form?
> >
> > Thanks,
> > Madhu
> >
> > --
> > 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/-/wSJXqEJkYzoJ.
> > 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.
>
>
>
> --
> Best Regards,
>
> Amyth Arora
> +91856363
> +918800212140
>
> --
> 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: Using sessions in Django

2012-08-17 Thread Thomas Orozco
Session key is the session 's primary key. Not the session itself.

What you want to assign to your field is a session, not its key. So use
request.session.

However.

Please very careful when using FK' s to sessions, sessions are meant to be
short lived, and could / should be deleted once they expire (ie. When the
user logs off or after a specific duration), depending on your backend.

I'm not sure what you're trying to achieve, but I think that FKing to
sessions is, at the very list, pretty risky.

Especially given that the default on delete behavior of a ForeignKey is
cascade.
Le 17 août 2012 09:59, "Sandeep kaur"  a écrit :

> I am using session foreign key in my table.
>
> class ClientJob(models.Model): #models.py
>  .
>  sess = models.ForeignKey(Session)
>
> And in order to save its value in database, I used ,.
>
> def add_job(request)  #views.py
>  ...
>  if not request.session.exists(request.session.session_key):
> request.session.create()
>  profile.sess = request.session.session_key
>  profile.save()
>
> But when I execute my form and click on submit button, I get error as :
>
> ```Cannot assign "'b593c61453d7aad199078c66b9ad6b30'":
> "ClientJob.sess" must be a "Session" instance.
>
> I am a bit unclear about using sessions in django, so be a little
> elaborative.
>
> Thank you.
>
>
> --
> 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 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: Using sessions in Django

2012-08-17 Thread Thomas Orozco
I'm sorry, I have some trouble understanding exactly what you need, could
you please try and provide a bit more context ? :-)
Le 17 août 2012 10:27, "Sandeep kaur"  a écrit :

> On Fri, Aug 17, 2012 at 1:42 PM, Thomas Orozco
>  wrote:
> > Session key is the session 's primary key. Not the session itself.
> >
> > What you want to assign to your field is a session, not its key. So use
> > request.session.
> >
> > However.
> >
> > Please very careful when using FK' s to sessions, sessions are meant to
> be
> > short lived, and could / should be deleted once they expire (ie. When the
> > user logs off or after a specific duration), depending on your backend.
> >
> > I'm not sure what you're trying to achieve, but I think that FKing to
> > sessions is, at the very list, pretty risky.
> >
> > Especially given that the default on delete behavior of a ForeignKey is
> > cascade.
>
> You are right.
> Actually, I want a cart like system. Like in my project's case, if a
> client want to test multiple material in one job, it should generate
> one bill and receipt. But for each different material, different jobs
> are created. So, I thought it could be achieved by storing the session
> in which the user logged and then get the bill generated based on that
> session.
> If you find it a vague solution, do tell the most optimum solution.
>
>
> --
> 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 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: Using sessions in Django

2012-08-17 Thread Thomas Orozco
My mistake then, sorry about that!
Le 17 août 2012 10:34, "Tom Evans"  a écrit :

> On Fri, Aug 17, 2012 at 9:12 AM, Thomas Orozco
>  wrote:
> > Session key is the session 's primary key. Not the session itself.
> >
> > What you want to assign to your field is a session, not its key. So use
> > request.session.
> >
>
> This would not work; request.session is a
> django.contrib.sessions.backends,SessionBase subclass, and not a model
> instance.
>
> You would need to use the advice Amyth gave you.
>
> Cheers
>
> Tom
>
> --
> 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: Adding Button in admin form

2012-08-17 Thread Thomas Orozco
(again) did you try using raw_id_fields?
Le 17 août 2012 11:26, "Madhu"  a écrit :

> Can you please tell me how to add the Buttom on admin form in django?
> I want to add the button beside the field.
>
> --
> 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/-/WACTMw1ykxMJ.
> 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: Adding Button in admin form

2012-08-17 Thread Thomas Orozco
Then there must be something I don't understand in what you need, could you
describe a bit more?
Le 17 août 2012 12:02, "Madhu"  a écrit :

>
> I try the row_id_fields, but its not helpful for me.
> I want the button will be display in admin form.
> Using row_id_fields its just the linking of foreign key i don't want that.
> The button functionality will be later before that i want the button tag
> will be display on admin form.
>
>  --
> 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/-/7CrtkDOzAycJ.
> 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: Adding Button in admin form

2012-08-17 Thread Thomas Orozco
So you would want to have a link to the url that was entered?
Le 17 août 2012 12:15, "Madhu"  a écrit :

> Ok. I will explain it in brief.
>
> I want the button like the image field having the Browse button with the
> Image field in admin side i want the same button but the functionality may
> be different. Don't want that the browser button functionality but i want
> the button along with the my URL character field.
> That button should be be display and we i click on that button then some
> functionality.
>
> Right now i didn't understand, how to add that button in admin form.
> Can you please suggest?
>
> --
> 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/-/Ov0QyqEbsCQJ.
> 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: Adding Button in admin form

2012-08-17 Thread Thomas Orozco
I'm sorry, I really have a hard time understanding what you need, but you
might want to try overriding the form template to add your button?

If so, try the change_form_template parameter.
Le 17 août 2012 12:42, "Madhu"  a écrit :

> No. URL linking is not the problem. I have the problem to add the input
> button in admin form.
>
> There will be so many buttons in admin form like save, add, delete. I want
> to add my own button, but in the middle of admin form not at the submit
> line or upper part of the admin form. That button should be display near to
> my character field.
>
> Using html we create  then button tag will be display
> in the html page.
> I want the same input button on the admin form.
>
> --
> 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/-/LVBJArH-RH8J.
> 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: Updating a model instance with extra checks.

2012-08-20 Thread Thomas Orozco
A few suggestions :

Circumvent the problem with smarter design: don't store the money on the
object, make the user's money the sum of all their transactions (credit -
debit).
You get lesser performance, but you also get history!

Maybe you could try (not sure about that):

MyModel.objects.filter(money__gte = value, pk = self.pk).update(F...)

and inspect the return value (number of updated rows!).
Now, you'd need to make sure django does that in a single statement.

If that doesn't work, I think update is the way to go anyway, but it might
get a bit messy.

F... is an F object whose syntax I don't have off the top of my head.
Le 20 août 2012 18:54, "Sebastien Flory"  a écrit :

> Hi everyone,
>
> I'm looking for the proper django way to do an update of an attribute on
> my model instance, but only if the attribute current value is checked
> agains't a condition, in an atomic way, something like this:
>
> def use_money(self, value):
>   begin_transaction()
>   real_money = F('money')
>   if real_money >= value:
> self.money = F('money') - value
> self.save()
>   end_transaction()
>
> I want to make sure that I avoid race condition so money never goes below
> 0.
>
> Can you help me out?
>
> Thanks,
>
> Sebastien
>
> --
> 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/-/hr1fBuAcX3kJ.
> 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: Updating a model instance with extra checks.

2012-08-20 Thread Thomas Orozco
I think I didn't make what I meant clear enough:

What do you think about the following:

. Insert record
. Calculate balance by summing all records before (including) the one you
just inserted (and I think you will agree this is not an extremely complex
query)
. If balance is positive, it's approved (and you'd probably want to change
some status field to reflect that)
. If balance is negative, it's refused - and you can change status (or
delete, though I wouldn't recommend that)

Nothing prevents us from differentiating inserting a record and approving
the transaction, right?

Depending on whether you use a status field or not, and which transactions
you take into account to know whether you will approve, you can get on the
safe side.

Just assuming that a pending transaction (that is, a transaction that has
been inserted but not approved yet) will be approved should prevent
approving a withdrawal you should be refusing (but could lead you to refuse
one you should be approving if your process is too long)

The day performance becomes an issue, you can look into alternate
solutions, such as indeed storing the current balance somewhere.
Le 21 août 2012 01:26, "Melvyn Sopacua"  a écrit :

> On 20-8-2012 19:37, Thomas Orozco wrote:
>
> > Circumvent the problem with smarter design: don't store the money on the
> > object, make the user's money the sum of all their transactions (credit -
> > debit).
> > You get lesser performance, but you also get history!
>
> This does not circumvent the problem but aggravates it. The problem is
> how to determine if a withdrawal is allowed before doing the withdrawal.
> Not having the current balance available but instead having to do
> complex queries on a possibly huge set of rows, increases the chances of
> transactions being OK'd that should not be when multiple withdrawals are
> sent in parallel.
>
> Alexis has mentioned some options, but the real safeguard is to make
> current balance field a positive decimal field and propagate this to the
> database layer by ensuring a constraint is created. Even if two
> transactions in parallel are working with the same initial balance, the
> constraint will deny at least one of them. This is also why you should
> enclose the entire process (add withdrawal to statement, decrease the
> balance) in a single transaction. Possibly the
> @transaction.commit_on_success decorator may prove useful.
>
> --
> Melvyn Sopacua
>
> --
> 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: [ImageField -Upload a valid image]

2012-08-20 Thread Thomas Orozco
I'd you believe PIL is not picking up your libjpeg when it should be, you
could give Pillow a shot ; its basically a PIL installer that makes
installation easier.
Le 20 août 2012 22:30, "Kurtis Mullins"  a écrit :

> Whenever you compile PIL, make sure that libjpeg is available to it. You
> should see a message showing you what is available when you install PIL.
>
> On Mon, Aug 20, 2012 at 3:33 PM, MN TS  wrote:
>
>> Yes.
>>
>> Png and GIF are ok.
>>
>>
>> On Mon, Aug 20, 2012 at 8:00 PM, Amyth Arora 
>> wrote:
>>
>>> did you try uploading any other images ?
>>>
>>>
>>> On Mon, Aug 20, 2012 at 12:58 AM, MN TS  wrote:
>>> > Hello everybody.
>>> >
>>> > I've problem. When i upload image and submit i got follow form error.
>>> >- Upload a valid image. The file you uploaded was either not an
>>> image or
>>> > a corrupted image.
>>> >
>>> > I reinstall PIL (1.1.7) and setup.py file edit like JPEG_ROOT =
>>> > '/usr/lib/i386-linux-gnu/'.
>>> >
>>> > Thanks
>>> >
>>> > --
>>> > 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.
>>>
>>>
>>>
>>> --
>>> Thanks & Regards
>>> 
>>>
>>> Amyth [Admin - Techstricks]
>>> Email - aroras.offic...@gmail.com, ad...@techstricks.com
>>> Twitter - @a_myth_
>>> http://techstricks.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.
>>
>
>  --
> 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: Updating a model instance with extra checks.

2012-08-20 Thread Thomas Orozco
As a followup to the suggestion of MyModel.objects.filter(money__gte =
value, pk = self.pk).update(F...)

Here's an example:

We have testapp/models.py:

from django.db import models
class TestModel(models.Model):
balance =  models.IntegerField()


>>> from django.db.models import F
>>> TestModel.objects.create(balance = 5) #Pk will be 1 I just create one.
>>> import logging
>>> l = logging.getLogger('django.db.backends')
>>> l.setLevel(logging.DEBUG)
>>> l.addHandler(logging.StreamHandler())
>>> TestModel.objects.filter(balance__gte = 4, pk = 1).update(balance =
F('balance') - 4)
(0.001) UPDATE "testapp_testmodel" SET "balance" =
"testapp_testmodel"."balance" - 4 WHERE ("testapp_testmodel"."balance" >= 4
 AND "testapp_testmodel"."id" = 1 ); args=(4, 4, 1)
1
>>> TestModel.objects.filter(balance__gte = 4, pk = 1).update(balance =
F('balance') - 4)
(0.000) UPDATE "testapp_testmodel" SET "balance" =
"testapp_testmodel"."balance" - 4 WHERE ("testapp_testmodel"."balance" >= 4
 AND "testapp_testmodel"."id" = 1 ); args=(4, 4, 1)
0



*So this seems to generate a single SQL statement.*
*
*
*I'm not totally familiar with database administration though, so as** Melvyn
rightly pointed out, it's always better if you can get the extra security
of having an SQL constraint into your dabatase and wrap your queries in a
transaction (as you'll probably be adding a line to the statement if the
withdrawal succeeds).*
*
*

2012/8/20 Thomas Orozco 

> A few suggestions :
>
> Circumvent the problem with smarter design: don't store the money on the
> object, make the user's money the sum of all their transactions (credit -
> debit).
> You get lesser performance, but you also get history!
>
> Maybe you could try (not sure about that):
>
> MyModel.objects.filter(money__gte = value, pk = self.pk).update(F...)
>
> and inspect the return value (number of updated rows!).
> Now, you'd need to make sure django does that in a single statement.
>
> If that doesn't work, I think update is the way to go anyway, but it might
> get a bit messy.
>
> F... is an F object whose syntax I don't have off the top of my head.
> Le 20 août 2012 18:54, "Sebastien Flory"  a écrit :
>
> Hi everyone,
>>
>> I'm looking for the proper django way to do an update of an attribute on
>> my model instance, but only if the attribute current value is checked
>> agains't a condition, in an atomic way, something like this:
>>
>> def use_money(self, value):
>>   begin_transaction()
>>   real_money = F('money')
>>   if real_money >= value:
>> self.money = F('money') - value
>> self.save()
>>   end_transaction()
>>
>> I want to make sure that I avoid race condition so money never goes below
>> 0.
>>
>> Can you help me out?
>>
>> Thanks,
>>
>> Sebastien
>>
>> --
>> 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/-/hr1fBuAcX3kJ.
>> 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: Updating a model instance with extra checks.

2012-08-21 Thread Thomas Orozco
I think  you could always send the signals yourself.

Wrap that along in a model method, and I don't see any issue with using the
manager!
Le 21 août 2012 10:18, "Sebastien Flory"  a écrit :

> That was my idea too, but using this way, the pre_save / post_save signals
> wont be triggered.
> It seems strange to me to be using the objects manager instead of the
> model instance directly, no?
>
> Seb
>
> Le mardi 21 août 2012 02:11:42 UTC+2, Thomas Orozco a écrit :
>>
>> As a followup to the suggestion of MyModel.objects.filter(**money__gte =
>> value, pk = self.pk).update(F...)
>>
>> Here's an example:
>>
>> We have testapp/models.py:
>>
>> from django.db import models
>> class TestModel(models.Model):
>> balance =  models.IntegerField()
>>
>>
>> >>> from django.db.models import F
>> >>> TestModel.objects.create(**balance = 5) #Pk will be 1 I just create
>> one.
>> >>> import logging
>> >>> l = logging.getLogger('django.db.**backends')
>> >>> l.setLevel(logging.DEBUG)
>> >>> l.addHandler(logging.**StreamHandler())
>> >>> TestModel.objects.filter(**balance__gte = 4, pk = 1).update(balance
>> = F('balance') - 4)
>> (0.001) UPDATE "testapp_testmodel" SET "balance" =
>> "testapp_testmodel"."balance" - 4 WHERE ("testapp_testmodel"."balance" >= 4
>>  AND "testapp_testmodel"."id" = 1 ); args=(4, 4, 1)
>> 1
>> >>> TestModel.objects.filter(**balance__gte = 4, pk = 1).update(balance
>> = F('balance') - 4)
>> (0.000) UPDATE "testapp_testmodel" SET "balance" =
>> "testapp_testmodel"."balance" - 4 WHERE ("testapp_testmodel"."balance" >= 4
>>  AND "testapp_testmodel"."id" = 1 ); args=(4, 4, 1)
>> 0
>>
>>
>>
>> *So this seems to generate a single SQL statement.*
>> *
>> *
>> *I'm not totally familiar with database administration though, so as** Melvyn
>> rightly pointed out, it's always better if you can get the extra security
>> of having an SQL constraint into your dabatase and wrap your queries in a
>> transaction (as you'll probably be adding a line to the statement if the
>> withdrawal succeeds).*
>> *
>> *
>>
>> 2012/8/20 Thomas Orozco 
>>
>>> A few suggestions :
>>>
>>> Circumvent the problem with smarter design: don't store the money on the
>>> object, make the user's money the sum of all their transactions (credit -
>>> debit).
>>> You get lesser performance, but you also get history!
>>>
>>> Maybe you could try (not sure about that):
>>>
>>> MyModel.objects.filter(money__**gte = value, pk = self.pk).update(F...)
>>>
>>> and inspect the return value (number of updated rows!).
>>> Now, you'd need to make sure django does that in a single statement.
>>>
>>> If that doesn't work, I think update is the way to go anyway, but it
>>> might get a bit messy.
>>>
>>> F... is an F object whose syntax I don't have off the top of my head.
>>> Le 20 août 2012 18:54, "Sebastien Flory"  a écrit :
>>>
>>> Hi everyone,
>>>>
>>>> I'm looking for the proper django way to do an update of an attribute
>>>> on my model instance, but only if the attribute current value is checked
>>>> agains't a condition, in an atomic way, something like this:
>>>>
>>>> def use_money(self, value):
>>>>   begin_transaction()
>>>>   real_money = F('money')
>>>>   if real_money >= value:
>>>> self.money = F('money') - value
>>>>  self.save()
>>>>   end_transaction()
>>>>
>>>> I want to make sure that I avoid race condition so money never goes
>>>> below 0.
>>>>
>>>> Can you help me out?
>>>>
>>>> Thanks,
>>>>
>>>> Sebastien
>>>>
>>>> --
>>>> 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/-/**hr1fBuAcX3kJ<https://groups.google.com/d/msg/django-users/-/hr1fBuAcX3kJ>
>>>> .
>>>> To post to this group, send email to django...@googlegroups.com.
>>>> To unsubscribe from this group, send email to django-users...@**
>>>> googlegroups.com.
>>>> For more options, visit this group at http://groups.google.com/**
>>>> group/django-users?hl=en<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 view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/x8CZ3-F30PsJ.
> 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: How I do to centralize logins OpenID in django?

2012-08-22 Thread Thomas Orozco
+1 - If you are running both apps using the same database server, this
would probably be the simpler solution!
Le 22 août 2012 04:26, "Kurtis Mullins"  a écrit :

> I've never tried this approach; but maybe you could use the multi-database
> feature of Django to share a database for the Authentication/Sessions
> components? (https://docs.djangoproject.com/en/dev/topics/db/multi-db/)
>
> On Tue, Aug 21, 2012 at 7:39 PM, Mustapha Aoussar <
> mustapha.aous...@gmail.com> wrote:
>
>> Dear sirs,
>> I have split my Django application into two sites with different
>> databases. I use OpenID (python_openid 2.2.5) for
>> authetication/registration but users of ''site A'' are different from
>> ''site B''.
>>
>> How can I do to centralize logins between apps running on different
>> databases?
>>
>> I have seen this article by Joseph Smarr at Plaxo (
>> http://www.netvivs.com/openid-recipe/) and this Stackoverflow question (
>> http://stackoverflow.com/questions/4395190/how-do-stackexchange-sites-associate-user-accounts-and-openid-logins)
>> but i don't know how can I do this with django.
>>
>> Can you help me please?
>> 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/-/oHVzCzIer48J.
>> 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.
>

-- 
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: Any good Open Source Django-Based CRM's ?

2012-09-01 Thread Thomas Orozco
Django crm is pretty good and open source!
On Sep 1, 2012 4:53 PM, "pajju"  wrote:

> HI
>
> I'm looking for Django Powered Open Sourced CRM's which is ready for
> Production use.
> I did not find much help google'ing for the same. :)
>
> And In other Technologies, Open Sourced based CRM's which one is better -
> vTiger or SugarCRM or anything better which is fully Open Sourced ?
>
> --
> 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/-/-VtPeadpBvUJ.
> 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: Any good Open Source Django-Based CRM's ?

2012-09-01 Thread Thomas Orozco
Dismiss what I said, I misread (and miswrote) CRM for CMS -_-

2012/9/1 Thomas Orozco 

> Django crm is pretty good and open source!
> On Sep 1, 2012 4:53 PM, "pajju"  wrote:
>
>> HI
>>
>> I'm looking for Django Powered Open Sourced CRM's which is ready for
>> Production use.
>> I did not find much help google'ing for the same. :)
>>
>> And In other Technologies, Open Sourced based CRM's which one is better -
>> vTiger or SugarCRM or anything better which is fully Open Sourced ?
>>
>> --
>> 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/-/-VtPeadpBvUJ.
>> 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: testing a django package

2012-09-11 Thread Thomas Orozco
Is it a view mix in?

It's a bit difficult to tell you much without more information.

A few you things that you may find useful or not for testing :

.  Test cases can override settings such as the urlconf
.  There's a test client to test views
.  Class based views can sometimes be tested without any of the former by
just testing the methods in them
.   You can always use mocking library
.  Tests are basically just python code with a lot of asserts, you can
always add viewed in them
.  You can use fixtures for test data if you see fit

Hope this helps!

Thomas
On Sep 10, 2012 5:23 PM, "Jonas Geiregat"  wrote:

> Hello,
>
> I've created a simple reusable django package. This package basically
> consists out of a views.py file, with some helper functions.
>
> I want to write some tests for what's in this file. This file contains a
> mixin , so I probably can't test it directly.
>
> What's the best way to test a django package ?
>
> Do I need to include some kind of example project that, uses my mixin and
> has tests files just as one would test a normal django application ?
>
> I've tried googling but, there's little about this. Most of the things
> I've found where related to testing actual django applications.
>
> Any help is appreciated.
>
> Jonas
>
>
> --
> 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: Best free web hosting portal

2012-09-11 Thread Thomas Orozco
You can also try https://www.pythonanywhere.com/
Their free offering, however, doesn't seem as interesting as Anton's appfog

2012/9/10 Anton Popovine 

> Hello,
>
> http://www.appfog.com/  came out of closed beta recently. They support
> python and django.
>
> You get quite alot for free. (2Gb ram, unlimited # of instances, 10
> services)
>
> Anton
>
> On Monday, September 10, 2012 10:51:07 AM UTC+2, Somnath wrote:
>>
>> Hello friends,
>>
>>I want to host my site on free web hosting for testing purpose,
>> so anyone give me suggestion on best free web hosting site for django
>> website.
>>
>  --
> 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/-/wpKvLXGL9gwJ.
>
> 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: Marketplace for Django apps

2012-09-11 Thread Thomas Orozco
You could always use https://www.gittip.com/ to that end,
Basically, it allows you to tip developers that are on github

For instance, you could tip django devs at:
https://www.gittip.com/on/github/django/

You can see that: https://www.gittip.com/aaugustin/ or
https://www.gittip.com/alex/, among other django devs, opted into gittip,

Cheers,

2012/9/11 Kurtis Mullins 

> How about a compromise; just an easier way to donate to Django and Django
> Application developers? It would encourage sharing high quality projects
> and hopefully make it worth our time (financially, not just because we love
> and support libre software) to do so. For that matter, there's all sorts of
> ways to make money around free software (laid out by RMS among others) such
> as Paid Support, selling printed documentation, etc...
>
>
> On Tue, Sep 11, 2012 at 1:36 PM, Jorge Vargas wrote:
>
>> I agree with Jonas here. having a place were you have get apps to solve
>> hard problems no one has done right (ecommerce is a very good example) is a
>> plus.
>>
>> As for it being "cancer" and bad I don't agree there is a market for
>> everything. And that will bring more people in which in the end is what
>> everyone wants.
>> I do agree that it should be clear that said store will be managed by a
>> third party and not Django itself.
>>
>>
>> On Tue, Sep 11, 2012 at 7:11 AM,  wrote:
>>
>>>
>>>
 I want to ask you again, what you think about such service? Would you
 buy or sell apps (or paid support) out there and why?


>>> If the apps are more then good enough and would spare companies time and
>>> there are no better or equal opensource alternatives,
>>> then yes I do believe some people might be willing to buy apps in such a
>>> market place. For example there is no real outstanding e-commerce
>>> application for django.
>>>
>>>
>>> --
>>> 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+unsubscribe@*
>>> *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.
>>
>
>  --
> 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: not picking up new template

2012-09-12 Thread Thomas Orozco
Can you being up a manage.py shell and load the template from there to
identify where's Django is pulling the template from?

You should be able to go step by step and identify where you're pulling the
old template in!

If you don't find anything, it's probably because your template actually
isn't different from the older one.

You should be able to do that using pdb and the Django code base :-)
There might be a quicker way though, I'll have a look at it.

Thomas
On Sep 12, 2012 5:59 PM, "Larry Martell"  wrote:

> On Wed, Sep 12, 2012 at 11:56 AM, Thomas Lockhart
>  wrote:
> > On 9/12/12 8:27 AM, Larry Martell wrote:
> >>
> >> On my Mac, I changed a template, and the change was picked up, no
> >> problem. I checked my change into git, went to another machine, a
> >> CentOS box, pulled the change down, but django is not picking it up.
> >> I've tried everything I can think of - bounced the server, restarted
> >> the browser, cleared the cache and cookies, tried 3 different
> >> browsers, deleted it, re-pulled from git, but when I look at the code
> >> in the debugger, it's clearly using the old template. There are no
> >> errors in the apache log, permissions are fine, I'm tearing my hair
> >> out here. Anyone have any ideas as to what's preventing it from
> >> picking up the new template, or what I can check to figure out what's
> >> going on?
> >>
> > Need to collect static content for your production server?
>
> I had already tried that (even thought this change did not effect the
> static content).
>
> --
> 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: tastypie - some feedback / comments

2012-09-12 Thread Thomas Orozco
After giving it a try for a small personal project / curiosity, I couldn't
agree more that it's great for a REST API with querysets, but whenever
something doesn't exactly tie into this structure, things get complicated.

However, I would say that this can also be a good thing.

This forces you to think and build using Tastypie's principles, which I
think are sane.

Eventually, this means that for an existing project, Tastypie can be a bit
disheartening to use.
 On Sep 12, 2012 5:16 PM, "Kurt Pruhs"  wrote:

>   I've had the same issues. A previous developer used TastyPy for APIs
> and it's a nightmare trying to modify them beyond the simple,
> out-of-the-box functionality. In its current state, it's more trouble than
> it's worth.
>
>  --
>
>   Kurt Pruhs
> Utah State University
> Information Technology Department
> Programming and Design Team
> office: 435.797.9260
> cell: 435.890.0289
>
>   From: "Cal Leeming [Simplicity Media Ltd]" <
> cal.leem...@simplicitymedialtd.co.uk>
> Reply-To: "django-users@googlegroups.com" 
> Date: Wednesday, September 12, 2012 6:27 AM
> To: "django-users@googlegroups.com" 
> Subject: tastypie - some feedback / comments
>
>   Hi all,
>
>  For the last two years whenever an API has been required for a project,
> we have just used our own API wrapper that consists of about 50 lines, then
> added in the bits we needed as we go along.
>
>  So today, I decided to spread my wings a little and give TastyPie a
> try... here is a bit of feedback for anyone considering TastyPie;
>
>  It works quite nicely out of the box, ties directly into the Django user
> models, has fairly good URL path structures, and within 30 minutes you can
> have it spitting out data from your models with as much control as you
> wish.
>
>  However, like the django-admin system, this is where the fun ends. As
> soon as you want to do anything bespoke or actions that involve not
> fetching data (whether it be ORM or not), things start to get
> touchy. Attempting to get tastypie to work without a queryset/qs is damn
> near impossible, the uglyness of override_urls/prepend_urls() alone was
> enough to make me say "eww", and the general feel was overly complex.
>
>  In theory tastypie is perfect, but in practise it seems to
> overcomplicate things in an attempt to keep everything organized, and to
> quote a colleague "it has a bit too much magic". Sure, it claims to give
> you plenty of control to customize it for your specific use case, but the
> complexity of this makes actual time and sanity saved debatable.
>
>  This isn't to say that tastypie should be avoided, as it will work
> beautifully for simple requirements, but I personally feel that it should
> be kept in the same box as django-admin. It's also worth mentioning that
> (imo) anyone thinking about tastypie should still give it a try and see how
> they feel about it. It'd be interesting to hear other thoughts on it.
>
>  There are obviously some others to compare this against, the most
> notable being piston and Django REST framework. Although there's some bad
> press about piston (and I haven't tried it myself), it would probably be
> next in my list to try. Unlike tastypie, it treats resources as completely
> arbitrary objects and lets you create the magic for yourself.. so although
> it doesn't work out of the box quite as easily, it offers so much more
> benefits in the long run.
>
>  Any thoughts?
>
>  Cal
>
> --
> 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.
>

-- 
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: not picking up new template

2012-09-12 Thread Thomas Orozco
Here's an example:

from django.template import loader
l = 
loader.find_template_loader('django.template.loaders.app_directories.Loader')
# Or W/E loader you happen to use
l.load_template_source(somewhere/'your_template.html')

This will return a tuple (template string, template_path).

This way you should be able to troubleshoot your issue.
You could always try wich each loader using:


from django.conf import settings
for loader_name in settings.TEMPLATE_LOADERS:
l = loader.find_template_loader(loader_name)
l.load_template_source(somewhere/'your_template.html')


2012/9/12 Thomas Orozco 
>
> Can you being up a manage.py shell and load the template from there to 
> identify where's Django is pulling the template from?
>
> You should be able to go step by step and identify where you're pulling the 
> old template in!
>
> If you don't find anything, it's probably because your template actually 
> isn't different from the older one.
>
> You should be able to do that using pdb and the Django code base :-)
> There might be a quicker way though, I'll have a look at it.
>
> Thomas
>
> On Sep 12, 2012 5:59 PM, "Larry Martell"  wrote:
>>
>> On Wed, Sep 12, 2012 at 11:56 AM, Thomas Lockhart
>>  wrote:
>> > On 9/12/12 8:27 AM, Larry Martell wrote:
>> >>
>> >> On my Mac, I changed a template, and the change was picked up, no
>> >> problem. I checked my change into git, went to another machine, a
>> >> CentOS box, pulled the change down, but django is not picking it up.
>> >> I've tried everything I can think of - bounced the server, restarted
>> >> the browser, cleared the cache and cookies, tried 3 different
>> >> browsers, deleted it, re-pulled from git, but when I look at the code
>> >> in the debugger, it's clearly using the old template. There are no
>> >> errors in the apache log, permissions are fine, I'm tearing my hair
>> >> out here. Anyone have any ideas as to what's preventing it from
>> >> picking up the new template, or what I can check to figure out what's
>> >> going on?
>> >>
>> > Need to collect static content for your production server?
>>
>> I had already tried that (even thought this change did not effect the
>> static content).
>>
>> --
>> 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: testing a django package

2012-09-12 Thread Thomas Orozco
I think you could create an urls.py file for your tests and attach
your views there. Then use the test client to direct requests to those
test URLs and assert that the response is what you expect.

Now, this is probably not going to be practical to test your jQuery
components, but you might want to ask on a JS-focused list regarding
unittesting JS for this purpose.

Thomas

2012/9/12 Jonas Geiregat :
>
> I can now show you what I really would like to write tests for.
>
> https://github.com/jonasgeiregat/django-ajax-forms
>
> The code I would like to test is in ajax_forms/views.py mainly the
> AjaxFormView and the AjaxModelFormView.
>
> Any help is appreciated!
>
>
> Is it a view mix in?
>
> The package actually already changed from containing a view mix in to actual
> views that should be subclassed by the users using the package.
>
> It's a bit difficult to tell you much without more information.
>
> For example, a view derived from FormView. Like I said the user should
> subclass this view again as you would normally do with CBV.
>
> Currently the package is just a package/directory with views.py, models.py,
> urls.py and of course __init__.py to make it a module.
>
> It's hard to test views without having an actual django project to test it
> again, I think.  Correct me if I'm wrong here.
> So I created an example django project that is using this package in the
> directory below the package, thus the directory containing the README,
> setup.py etc .. files.
>
> The example app will hold a tests.py file which will contain my tests which
> will be testing the actual functionality of my views.
>
> Basically I'm asking do I need an actual django project to test just a
> views.py file or can I just write some tests without a containing django
> project to test a views.py file.
> And if so, I'm kinda lost on how you would start on such a task.
>
> A few you things that you may find useful or not for testing :
>
> .  Test cases can override settings such as the urlconf
> .  There's a test client to test views
> .  Class based views can sometimes be tested without any of the former by
> just testing the methods in them
> .   You can always use mocking library
> .  Tests are basically just python code with a lot of asserts, you can
> always add viewed in them
> .  You can use fixtures for test data if you see fit
>
> Hope this helps!
>
> Thomas
>
> On Sep 10, 2012 5:23 PM, "Jonas Geiregat"  wrote:
>>
>> Hello,
>>
>> I've created a simple reusable django package. This package basically
>> consists out of a views.py file, with some helper functions.
>>
>> I want to write some tests for what's in this file. This file contains a
>> mixin , so I probably can't test it directly.
>>
>> What's the best way to test a django package ?
>>
>> Do I need to include some kind of example project that, uses my mixin and
>> has tests files just as one would test a normal django application ?
>>
>> I've tried googling but, there's little about this. Most of the things
>> I've found where related to testing actual django applications.
>>
>> Any help is appreciated.
>>
>> Jonas
>>
>>
>> --
>> 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.
>
>
>
> --
> 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.

-- 
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: ANN: django-otp and friends: one-time passwords and trusted agents

2012-09-12 Thread Thomas Orozco
This seems to be a *very* promising project! : )

Le mercredi 12 septembre 2012 22:27:26 UTC+2, psagers a écrit :
>
> I recently released a suite of packages to support two-factor 
> authentication in Django by way of one-time passwords.
>
> The core package is django-otp , 
> which defines the framework and provides all of the shared APIs. 
> Integration is possible at several levels, from low-level APIs (
> devices_for_user()
> , 
> match_token(),
>  
> etc.); to an AuthenticationForm 
> subclass;
>  to 
> a replacement for Django's login view and an OTP-enabled admin site. Other 
> niceties include the 
> otp_required
>  decorator, 
> an analog to login_required. This is not an authentication backend: 
> although it depends on django.contrib.auth for modeling purposes, it 
> operates independently of the normal authentication machinery.
>
> A given user may have zero or more OTP devices against which we can verify 
> a one-time password. The core project includes Django apps that implement 
> common devices such as HOTP and TOTP (compatible with Google Authenticator, 
> among others) and static passwords (typically used as backup codes). The 
> former include standard features such as tolerance and drift. Separately, 
> django-otp-yubikey  provides 
> support for YubiKey devices (locally or remotely verified). 
> django-otp-twilio  provides 
> support for Twilio's SMS service for delivering codes by SMS. Implementing 
> support for additional mechanisms is as simple as subclassing an abstract 
> model class and implementing a verification method (and optionally a 
> challenge method). Raw implementations of HOTP and TOTP are provided for 
> convenience along with a few other generally useful utility functions.
>
> As a companion to these, I've also released 
> django-agent-trust, 
> which uses Django 1.4's signed key APIs to tag user-agents that the user 
> has identified as trustworthy. In other words, this implements the "This is 
> a private/shared computer" option one often sees on sensitive sites. 
> Features include revocation and expiration (both absolute and by 
> inactivity; globally, per-user, and per-agent). 
> django-otp-agents is 
> a project that glues together django-otp and django-agent-trust to assign 
> trust to user-agents by way of two-factor authentication (one of the most 
> common scenarios, it seems).
>
> Documentation: django-otp , 
> django-otp-yubikey , 
> django-otp-twilio , 
> django-agent-trust , 
> django-otp-agents 
> Bitbucket: django-otp , 
> django-agent-trust 
>
> As always, the as-is clause in the BSD license isn't kidding. It's early 
> days for these yet and while everything has been carefully documented and 
> unit-tested, not all of the code has had contact with the real world. 
> Feedback is always welcome. The Google group 
> https://groups.google.com/forum/#!forum/django-otp is available for 
> discussion and questions.
>
> Thanks,
> Peter
>

-- 
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/-/eurHYAVF8cEJ.
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: testing a django package

2012-09-12 Thread Thomas Orozco
Actually, Django TestCases can override the URLConf, which allows you to 
have a given URL for a given view in your test:

from django.test import TestCase

class MyTestCase(TestCase):
urls = 'mypackage.tests.urls'

def test_something():
# Do stuff...


>From there, you can *totally* just create a tests/views.py file where you 
add your test view with the actual implementation you're missing, and add 
it in your tests/urls.py file.

And everything will be fine : )

Le mercredi 12 septembre 2012 23:36:03 UTC+2, jonas a écrit :
>
>
>
>
> > I think you could create an urls.py file for your tests and attach 
> > your views there. Then use the test client to direct requests to those 
> > test URLs and assert that the response is what you expect. 
>
> I didn't know that could work. 
> I think I'll also need to create views that extend these views that I want 
> to test. 
> Since they need actual implementation, I think, such as template_name and 
> model etc .. 
>
> How would the test client then now where to look for these views, since 
> there will be some reversing involved I think. 
>
> self.client.get(reverse("ajax_form_view")) 
>
> I don't see how the client will find my urls.py file and without the 
> broader, actual django application as context ? 
>
>
> > 
> > Now, this is probably not going to be practical to test your jQuery 
> > components, but you might want to ask on a JS-focused list regarding 
> > unittesting JS for this purpose. 
> > 
> > Thomas 
> > 
> > 2012/9/12 Jonas Geiregat >: 
> >> 
> >> I can now show you what I really would like to write tests for. 
> >> 
> >> https://github.com/jonasgeiregat/django-ajax-forms 
> >> 
> >> The code I would like to test is in ajax_forms/views.py mainly the 
> >> AjaxFormView and the AjaxModelFormView. 
> >> 
> >> Any help is appreciated! 
> >> 
> >> 
> >> Is it a view mix in? 
> >> 
> >> The package actually already changed from containing a view mix in to 
> actual 
> >> views that should be subclassed by the users using the package. 
> >> 
> >> It's a bit difficult to tell you much without more information. 
> >> 
> >> For example, a view derived from FormView. Like I said the user should 
> >> subclass this view again as you would normally do with CBV. 
> >> 
> >> Currently the package is just a package/directory with views.py, 
> models.py, 
> >> urls.py and of course __init__.py to make it a module. 
> >> 
> >> It's hard to test views without having an actual django project to test 
> it 
> >> again, I think.  Correct me if I'm wrong here. 
> >> So I created an example django project that is using this package in 
> the 
> >> directory below the package, thus the directory containing the README, 
> >> setup.py etc .. files. 
> >> 
> >> The example app will hold a tests.py file which will contain my tests 
> which 
> >> will be testing the actual functionality of my views. 
> >> 
> >> Basically I'm asking do I need an actual django project to test just a 
> >> views.py file or can I just write some tests without a containing 
> django 
> >> project to test a views.py file. 
> >> And if so, I'm kinda lost on how you would start on such a task. 
> >> 
> >> A few you things that you may find useful or not for testing : 
> >> 
> >> .  Test cases can override settings such as the urlconf 
> >> .  There's a test client to test views 
> >> .  Class based views can sometimes be tested without any of the former 
> by 
> >> just testing the methods in them 
> >> .   You can always use mocking library 
> >> .  Tests are basically just python code with a lot of asserts, you can 
> >> always add viewed in them 
> >> .  You can use fixtures for test data if you see fit 
> >> 
> >> Hope this helps! 
> >> 
> >> Thomas 
> >> 
> >> On Sep 10, 2012 5:23 PM, "Jonas Geiregat" 
> >> > 
> wrote: 
> >>> 
> >>> Hello, 
> >>> 
> >>> I've created a simple reusable django package. This package basically 
> >>> consists out of a views.py file, with some helper functions. 
> >>> 
> >>> I want to write some tests for what's in this file. This file contains 
> a 
> >>> mixin , so I probably can't test it directly. 
> >>> 
> >>> What's the best way to test a django package ? 
> >>> 
> >>> Do I need to include some kind of example project that, uses my mixin 
> and 
> >>> has tests files just as one would test a normal django application ? 
> >>> 
> >>> I've tried googling but, there's little about this. Most of the things 
> >>> I've found where related to testing actual django applications. 
> >>> 
> >>> Any help is appreciated. 
> >>> 
> >>> Jonas 
> >>> 
> >>> 
> >>> -- 
> >>> You received this message because you are subscribed to the Google 
> Groups 
> >>> "Django users" group. 
> >>> To post to this group, send email to 
> >>> django...@googlegroups.com. 
>
> >>> To unsubscribe from this group, send email to 
> >>> django-users...@googlegroups.com . 
> >>> For more options, visit this group at 
> >>> http://groups.google.com/group/django-users?hl=en. 
> >>> 
> 

Re: Basic auth struggle

2012-09-13 Thread Thomas Orozco
Could you us the line where you import login?
On Sep 13, 2012 2:06 PM, "Timster"  wrote:

> What does the rest of your views.py file look like?
>
> Do you happen to have a view named login()?
>
> --
> 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/-/ANUnnrLEVB8J.
> 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: Easy question to the Auth System

2012-09-16 Thread Thomas Orozco
Hi,

Use ManyToMany if one event can relate to *several* Users
Use ForeignKey if one event relates to a *single* User

Cheers,

Thomas

2012/9/16 WoHinDu :
> Hey,
>
> sorry for my bad englisch. Englisch is not my nativ language, but i hope
you
> can understand it and sorry for the stupid question but i'm new at Django.
>
> I have a table called "Event" in this Table i store some events with
title,
> date/time an a description.
>
> But how can i "connect" this events with users from the Django Auth
System?
> Is it a good idea to do this with a "ManyToMany" relation or not?
>
> Thanks.
>
> WoHinDu
>
> --
> 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/-/dDvQhsitipgJ.
> 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: Changing table's engine through migration scripts

2012-09-16 Thread Thomas Orozco
I wouldn't recommend that
Migrations are tightly tied to your app as you need them to set you app up.
In that sense, they should be database agnostic, as your app is (because
Django is).

Using a migration that only works for MySQL seems very strange to me.
Indeed, such a migration wouldn't make sense for SQLite or Postgres,

Moreover, the table engine doesn't make any difference from the app's point
of view, so I think it's better to leave that to your database console.

Cheers,

Thomas

2012/9/16 Gurpreet Bhatia 

> corrected the wrong subject :)
>
> On Sun, Sep 16, 2012 at 12:22 PM, Gurpreet Bhatia <
> gurpreetbhatia@gmail.com> wrote:
>
>> Hi Everyone,
>>
>> I have one query:
>>
>> Should we change the database(mySQL) table's engine through migration
>> scripts or not? If not then why?
>>
>> Following were my proposal:
>>
>> def forwards(self, orm):
>>
>> # Change engine from MYISAM to INNODB
>> db.execute('alter table abc ENGINE=INNODB;')
>>
>> def backwards(self, orm):
>>
>># Revert Engine to MYISAM
>> db.execute('alter table abc ENGINE=MYISAM;')
>>
>> - gurpreet
>>
>
>
>
> --
>
> Gurpreet Bhatia,
> If u feel like doin some work...,
> sit down n..
> .wait until that feeling goes away.
>
>  --
> 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: Django testing strategy

2012-10-04 Thread Thomas Orozco
You can use `fixtures` for this purpose! You can have several of them to
have exactly the data you need for a test.

Have a look there:
https://docs.djangoproject.com/en/dev/topics/testing/#django.test.TestCase.fixtures


Cheers,

Thomas

2012/10/4 Daniele Procida 

> I have started writing my first tests, for a project that has become
> pretty large (several thousand lines of source code).
>
> What needs the most testing - where most of the bugs or incorrect appear
> emerge - are the very complex interactions between objects in the system.
>
> To me, the intuitive way of testing would be this:
>
> * to set up all the objects, in effect creating a complete working database
> * run all the tests on this database
>
> That's pretty much the way I test things without automated tests: is the
> output of the system, running a huge database of objects, correct?
>
> However, I keep reading that I should isolate all my tests. So I have had
> a go at creating tests that do that, but it can mean setting up a dozen
> objects sometimes for a single tiny test, then doing exactly the same thing
> with one small difference for another test.
>
> Often I have to run save() on these objects, because otherwise tests that
> depend on many-to-many and other database relations won't work.
>
> That seems very inefficient, to create a succession of complex and
> nearly-identical test conditions for dozens if not hundreds of tests.
>
> I'd appreciate any advice.
>
> Daniele
>
> --
> 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: Creating an alternative change_list view for a specific app/model, not extending or overriding

2011-08-24 Thread Thomas Orozco
What about calling your admin view with a GET "alternate=1" parameter ?

An if statement in a template override would then allow you to render
properly depending on the aforementioned attribute provided you're passing
the request in the Context.

This event allows you to fine tune which bits you want to change.
Le 24 août 2011 23:38, "Thomas Weholt"  a écrit :
> I want to create a view looking and working just like the admin
> change_list, but using my own template ( based on the admin
> change_list template ) so that all the filtering you get from
> specifiying filtering in your adminmodel still works in my new view. I
> DO NOT want to extend or override the existing one but provide an
> additional/alternative view to the existing change_list for a specific
> app/model. I need to change how the elements in the change_list are
> presented. I'm listing photos, and want a layout like googles image
> search, not the table-based you get by default in the admin. I need to
> do this as well in my alternative view. I want to use the
> date-hierarchy, filtering, pagination, admin actions etc you get for
> free in the admin in my alternative view.
>
> Is this possible? How do I reuse most of the existing admin code to
> achieve this?
>
>
> --
> Mvh/Best regards,
> Thomas Weholt
> http://www.weholt.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.
>

-- 
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: AssertEquals __unicode__

2011-08-25 Thread Thomas Orozco
Well, call unicode(MyObject) and assert equals u'myRepr'
Le 25 août 2011 12:34, "Torsten"  a écrit :
> Hi
>
> How do I do that right ?
>
> I have a class like:
>
> class Invoice
> ...
> def __unicode__(self):
> return unicode(str(self.created_at.year)+'/'+str(self.id))
>
> and an test here:
>
>
> def test_invoice_number(self):
> invoice = Invoice.objects.create(created_at="2011-07-28",
> customer_id=1, payable_at='2012-12-12')
> invoice.save()
> self.assertEqual("Invoice: 2011/1", invoice)
>
>
> with the follwoing result:
>
> File "/Users/torsten/PycharmProjects/invoiz/invoice/tests.py", line
> 22, in test_invoice_number
> self.assertEqual("2011/1", invoice)
> AssertionError: '2011/1' != 
>
>
> Thanks for help
>
> Torsten
>
> --
> 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: Integrity Error

2011-08-26 Thread Thomas Orozco
Your invoice items have no invoice attribute, as the error says.

By the way, although I'm not sure of what you're trying to achieve, let me
point out that there is not really a need for a sum field in your invoice as
you can just sum all the invoice items' amount (and respect the DRY
principle - you use a few other similar issues).
Le 26 août 2011 11:35, "Torsten"  a écrit :
> Hi
>
> I have the following model:
>
> class Invoice(models.Model):
> customer = models.ForeignKey(Customer)
> project = models.ForeignKey(Project, blank=True, null=True)
> sum = models.FloatField(default=0)
> tax = models.IntegerField(default=16)
> payed_at = models.DateField(blank=True, null=True)
> payable_at = models.DateField('payable at')
> created_at = models.DateTimeField(auto_now_add=True)
>
> def invoice_number(self):
> invoice_number = str(self.created_at.year) + '/' +
> str(self.id)
> return invoice_number
>
> def __unicode__(self):
> return unicode(str(self.created_at.year) + '/' + str(self.id))
>
> class InvoiceItem(models.Model):
> invoice = models.ForeignKey(Invoice)
> text = models.TextField()
> unit = models.CharField(max_length=255)
> amount = models.IntegerField()
> sum = models.FloatField()
>
> and try to run this test
>
> def test_save_invoice(self):
> InvoiceItem.objects.create(sum=12, unit='Stunde', amount=100)
> InvoiceItem.objects.create(sum=10, unit='Stunde', amount=120)
> invoice = Invoice.objects.create(created_at="2011-07-28",
> customer_id=1, payable_at='2012-12-12')
> invoice.invoiceitem_set.all()
> self.assertEqual(240, invoice.sum)
>
> with this error:
> IntegrityError: invoice_invoiceitem.invoice_id may not be NULL
>
> since it is the relation id Django should take care for the
> invoice_invoiceitem.invoice_id
>
> Or is there anything wrong with the code ?
>
> Torsten
>
> --
> 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: Integrity Error

2011-08-26 Thread Thomas Orozco
That would be blank = True
Le 26 août 2011 11:58, "Kejun He"  a écrit :
> Sometime, set null = true would allow a field to be empty
>
> On Fri, Aug 26, 2011 at 5:41 PM, Thomas Orozco wrote:
>
>> Your invoice items have no invoice attribute, as the error says.
>>
>> By the way, although I'm not sure of what you're trying to achieve, let
me
>> point out that there is not really a need for a sum field in your invoice
as
>> you can just sum all the invoice items' amount (and respect the DRY
>> principle - you use a few other similar issues).
>> Le 26 août 2011 11:35, "Torsten"  a écrit :
>>
>> > Hi
>> >
>> > I have the following model:
>> >
>> > class Invoice(models.Model):
>> > customer = models.ForeignKey(Customer)
>> > project = models.ForeignKey(Project, blank=True, null=True)
>> > sum = models.FloatField(default=0)
>> > tax = models.IntegerField(default=16)
>> > payed_at = models.DateField(blank=True, null=True)
>> > payable_at = models.DateField('payable at')
>> > created_at = models.DateTimeField(auto_now_add=True)
>> >
>> > def invoice_number(self):
>> > invoice_number = str(self.created_at.year) + '/' +
>> > str(self.id)
>> > return invoice_number
>> >
>> > def __unicode__(self):
>> > return unicode(str(self.created_at.year) + '/' + str(self.id))
>> >
>> > class InvoiceItem(models.Model):
>> > invoice = models.ForeignKey(Invoice)
>> > text = models.TextField()
>> > unit = models.CharField(max_length=255)
>> > amount = models.IntegerField()
>> > sum = models.FloatField()
>> >
>> > and try to run this test
>> >
>> > def test_save_invoice(self):
>> > InvoiceItem.objects.create(sum=12, unit='Stunde', amount=100)
>> > InvoiceItem.objects.create(sum=10, unit='Stunde', amount=120)
>> > invoice = Invoice.objects.create(created_at="2011-07-28",
>> > customer_id=1, payable_at='2012-12-12')
>> > invoice.invoiceitem_set.all()
>> > self.assertEqual(240, invoice.sum)
>> >
>> > with this error:
>> > IntegrityError: invoice_invoiceitem.invoice_id may not be NULL
>> >
>> > since it is the relation id Django should take care for the
>> > invoice_invoiceitem.invoice_id
>> >
>> > Or is there anything wrong with the code ?
>> >
>> > Torsten
>> >
>> > --
>> > 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.
>>
>
> --
> 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: Integrity Error

2011-08-26 Thread Thomas Orozco
Actually, the line "invoice = models.ForeignKey(Invoice)" tells Django "An
invoice item should always be attached to an invoince".

You must realize that models are what they claim to be... models. They are
not items of their own, they just define how you would model a particular
item in your database.

The problem in your test scenario is that the actual invoice items that you
are creating are attached to no actual invoice :
InvoiceItem.objects.create(sum=12, unit='Stunde', amount=100)
InvoiceItem.objects.create(sum=10, unit='Stunde', amount=120)

You would actually need to do it the other way around.
First, create the invoice,
my_test_invoice = Invoice.objects.create(created_at="2011-07-28",
customer_id=1, payable_at='2012-12-12')
Then, create the items.
InvoiceItem.objects.create(sum=12, unit='Stunde', amount=100, *invoice =
my_test_invoice*)
InvoiceItem.objects.create(sum=10, unit='Stunde', amount=120, *invoice =
my_test_invoice*)

I actually don't use the create syntax, so you might need to call
my_test_invoice's save method before creating the invoice items (In a
foreign key relationship, you will *always* need to save the foreign key
item before the item that has a foreign key to it, else it has no id and you
get an integrity error).


Thomas

2011/8/26 Torsten 

> Thanks Thomas
>
> your are right concerning the sum there is no need for that.
> But you say:
> Your invoice items have no invoice attribute, as the error says.
>
> Isn't this line which defines the attribute ?
> invoice = models.ForeignKey(Invoice)
>
> Thanks
> Torsten
>
> On 26 Aug., 11:41, Thomas Orozco  wrote:
> > Your invoice items have no invoice attribute, as the error says.
> >
> > By the way, although I'm not sure of what you're trying to achieve, let
> me
> > point out that there is not really a need for a sum field in your invoice
> as
> > you can just sum all the invoice items' amount (and respect the DRY
> > principle - you use a few other similar issues).
> > Le 26 août 2011 11:35, "Torsten"  a écrit
> :
> >
> >
> >
> >
> >
> >
> >
> > > Hi
> >
> > > I have the following model:
> >
> > > class Invoice(models.Model):
> > > customer = models.ForeignKey(Customer)
> > > project = models.ForeignKey(Project, blank=True, null=True)
> > > sum = models.FloatField(default=0)
> > > tax = models.IntegerField(default=16)
> > > payed_at = models.DateField(blank=True, null=True)
> > > payable_at = models.DateField('payable at')
> > > created_at = models.DateTimeField(auto_now_add=True)
> >
> > > def invoice_number(self):
> > > invoice_number = str(self.created_at.year) + '/' +
> > > str(self.id)
> > > return invoice_number
> >
> > > def __unicode__(self):
> > > return unicode(str(self.created_at.year) + '/' + str(self.id))
> >
> > > class InvoiceItem(models.Model):
> > > invoice = models.ForeignKey(Invoice)
> > > text = models.TextField()
> > > unit = models.CharField(max_length=255)
> > > amount = models.IntegerField()
> > > sum = models.FloatField()
> >
> > > and try to run this test
> >
> > > def test_save_invoice(self):
> > > InvoiceItem.objects.create(sum=12, unit='Stunde', amount=100)
> > > InvoiceItem.objects.create(sum=10, unit='Stunde', amount=120)
> > > invoice = Invoice.objects.create(created_at="2011-07-28",
> > > customer_id=1, payable_at='2012-12-12')
> > > invoice.invoiceitem_set.all()
> > > self.assertEqual(240, invoice.sum)
> >
> > > with this error:
> > > IntegrityError: invoice_invoiceitem.invoice_id may not be NULL
> >
> > > since it is the relation id Django should take care for the
> > > invoice_invoiceitem.invoice_id
> >
> > > Or is there anything wrong with the code ?
> >
> > > Torsten
> >
> > > --
> > > 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.
>
>

-- 
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: Integrity Error

2011-08-26 Thread Thomas Orozco
While we're at it, here are a few suggestions.
So long as you can, you should use unicode inside python code. The main
logic would be that input should be converted to unicode as soon as
possible, and that output should be encoded (likely to UTF-8) as late as
possible.

Consequently, you might want to rewrite your invoice methods so that they do
the following.
invoice_number = unicode(self.created_at.year) + u'/' + unicode(self.id)
You could also write this the following way:
return u'{0}/{1}'.format( self.created_at.year, self.id ), which would be
more elegant (if you use format with a unicode string it calls your object's
__unicode__ method, and if you use format with a string, it calls the
__str__ method.).

By the way, your __unicode__ method actually returns your invoice's
invoice_number, so you might want to have __unicode__ return
self.invoice_number().
You could even use a single method for both in your code, but that might not
be a very good idea: if one day you want to change your display, if you have
__unicode__ return self.invoice_number() you can change it.


Regarding your test code, you will need to add a few details I didn't point
out first.
None of your fields have "blank = True", so you're going to have to either
give them default values or give them actual values in your tests.

Hope this helps.

Thomas

2011/8/26 Torsten 

> Hi
>
> I have the following model:
>
> class Invoice(models.Model):
>customer = models.ForeignKey(Customer)
>project = models.ForeignKey(Project, blank=True, null=True)
>sum = models.FloatField(default=0)
>tax = models.IntegerField(default=16)
>payed_at = models.DateField(blank=True, null=True)
>payable_at = models.DateField('payable at')
>created_at = models.DateTimeField(auto_now_add=True)
>
>def invoice_number(self):
>invoice_number = str(self.created_at.year) + '/' +
> str(self.id)
>return invoice_number
>
>def __unicode__(self):
>return unicode(str(self.created_at.year) + '/' + str(self.id))
>
> class InvoiceItem(models.Model):
>invoice = models.ForeignKey(Invoice)
>text = models.TextField()
>unit = models.CharField(max_length=255)
>amount = models.IntegerField()
>sum = models.FloatField()
>
> and try to run this test
>
>  def test_save_invoice(self):
>InvoiceItem.objects.create(sum=12, unit='Stunde', amount=100)
>InvoiceItem.objects.create(sum=10, unit='Stunde', amount=120)
>invoice = Invoice.objects.create(created_at="2011-07-28",
> customer_id=1, payable_at='2012-12-12')
>invoice.invoiceitem_set.all()
>self.assertEqual(240, invoice.sum)
>
> with this error:
> IntegrityError: invoice_invoiceitem.invoice_id may not be NULL
>
> since it is the relation id Django should take care for the
> invoice_invoiceitem.invoice_id
>
> Or is there anything wrong with the code ?
>
> Torsten
>
> --
> 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: Integrity Error

2011-08-26 Thread Thomas Orozco
Glad I could help!
Le 26 août 2011 12:53, "Torsten"  a écrit :
> Thanks Thomas you helped me a lot these are my first step in python
> and django.
> And I really starting to like it
>
> Torsten
>
> On 26 Aug., 12:23, Thomas Orozco  wrote:
>> While we're at it, here are a few suggestions.
>> So long as you can, you should use unicode inside python code. The main
>> logic would be that input should be converted to unicode as soon as
>> possible, and that output should be encoded (likely to UTF-8) as late as
>> possible.
>>
>> Consequently, you might want to rewrite your invoice methods so that they
do
>> the following.
>> invoice_number = unicode(self.created_at.year) + u'/' + unicode(self.id)
>> You could also write this the following way:
>> return u'{0}/{1}'.format( self.created_at.year, self.id ), which would be
>> more elegant (if you use format with a unicode string it calls your
object's
>> __unicode__ method, and if you use format with a string, it calls the
>> __str__ method.).
>>
>> By the way, your __unicode__ method actually returns your invoice's
>> invoice_number, so you might want to have __unicode__ return
>> self.invoice_number().
>> You could even use a single method for both in your code, but that might
not
>> be a very good idea: if one day you want to change your display, if you
have
>> __unicode__ return self.invoice_number() you can change it.
>>
>> Regarding your test code, you will need to add a few details I didn't
point
>> out first.
>> None of your fields have "blank = True", so you're going to have to
either
>> give them default values or give them actual values in your tests.
>>
>> Hope this helps.
>>
>> Thomas
>>
>> 2011/8/26 Torsten 
>>
>>
>>
>>
>>
>>
>>
>> > Hi
>>
>> > I have the following model:
>>
>> > class Invoice(models.Model):
>> >customer = models.ForeignKey(Customer)
>> >project = models.ForeignKey(Project, blank=True, null=True)
>> >sum = models.FloatField(default=0)
>> >tax = models.IntegerField(default=16)
>> >payed_at = models.DateField(blank=True, null=True)
>> >payable_at = models.DateField('payable at')
>> >created_at = models.DateTimeField(auto_now_add=True)
>>
>> >def invoice_number(self):
>> >invoice_number = str(self.created_at.year) + '/' +
>> > str(self.id)
>> >return invoice_number
>>
>> >def __unicode__(self):
>> >return unicode(str(self.created_at.year) + '/' + str(self.id))
>>
>> > class InvoiceItem(models.Model):
>> >invoice = models.ForeignKey(Invoice)
>> >text = models.TextField()
>> >unit = models.CharField(max_length=255)
>> >amount = models.IntegerField()
>> >sum = models.FloatField()
>>
>> > and try to run this test
>>
>> >  def test_save_invoice(self):
>> >InvoiceItem.objects.create(sum=12, unit='Stunde', amount=100)
>> >InvoiceItem.objects.create(sum=10, unit='Stunde', amount=120)
>> >invoice = Invoice.objects.create(created_at="2011-07-28",
>> > customer_id=1, payable_at='2012-12-12')
>> >invoice.invoiceitem_set.all()
>> >self.assertEqual(240, invoice.sum)
>>
>> > with this error:
>> > IntegrityError: invoice_invoiceitem.invoice_id may not be NULL
>>
>> > since it is the relation id Django should take care for the
>> > invoice_invoiceitem.invoice_id
>>
>> > Or is there anything wrong with the code ?
>>
>> > Torsten
>>
>> > --
>> > 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.
>

-- 
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: Installation

2011-08-26 Thread Thomas Orozco
You needn't have Django in your path but the parent directory so you can
import it.
Le 26 août 2011 14:07, "prem"  a écrit :
> Hi,
>
> Im trying to install Django but Im not succcessfull.
>
> The python has been installed properly.
>
> This is my python shell,
>
> Python 3.2.1 (default, Jul 10 2011, 21:51:15) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
>
> When I try import django command, I get the following error,
>
> Traceback (most recent call last):
> File "", line 1, in 
> import django
> ImportError: No module named django
>
>
> Python is located & installed in C:/python32 folder
> Django is located in C:/Django-1.0.4 folder
>
> This is how my path variable looks like, If you notice you can see
> Python & Django folder at the last.
>
> C:\Hyperion\AnalyticServices\bin;C:\Hyperion\AnalyticServices\bin;C:
> \Hyperion\AnalyticServices\bin;C:\app\PremVidya\product
> \11.2.0\dbhome_1\bin;C:\Hyperion\AnalyticServices\bin;C:\Hyperion
> \AnalyticServices\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%
> \System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:
> \Program Files\Dell\Dell Wireless WLAN Card;C:\Program Files\Common
> Files\Roxio Shared\10.0\DLLShared\;C:\Program Files\Microsoft SQL
> Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS
> \Binn\;%HYPERION_HOME%\common\ODBC\Merant\5.2\Drivers;C:\Hyperion/
> common/EssbaseRTC/9.3.1/bin;C:\Hyperion\BIPlus\bin;C:\Hyperion\BIPlus
> \lib;C:\Hyperion\common\SAP\bin;C:\Hyperion\common\CLS\9.3.1\bin
> \windows;C:\Program Files\QuickTime\QTSystem\;C:\Python32;c:
> \Django-1.0.4
>
> Please help me out,
>
> Thanks,
> Prem
>
> --
> 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: Create socket server in django

2011-09-20 Thread Thomas Orozco
You just have to run your server as a daemon and use Django's
setup_environment so you can use the ORM to interact with your Django DB.

I can try and find the lines you need to do that if you can't find them.
Le 20 sept. 2011 09:08, "Micke"  a écrit :

-- 
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: changes to .py file is not reflected until server is restarted.

2011-09-22 Thread Thomas Orozco
Sightly off topic, but your .py files seem to be exposed by your webserver -
you shouldn't do this or anyone could download them!
Le 22 sept. 2011 08:02, "kenneth gonsalves"  a
écrit :
> On Wed, 2011-09-21 at 19:37 +0100, Cal Leeming [Simplicity Media Ltd]
> wrote:
>> Oh jeez - modpython, I've nfi how to make that work with the same
>> approach. Maybe check mod_python docs??
>
> apachectl graceful - no other way.
> --
> regards
> Kenneth Gonsalves
>
> --
> 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: Parellel request from the same user in very short time

2011-09-24 Thread Thomas Orozco
Well, depends on what you're going to do with this data and what it
represents, but maybe the simpler solution is to use a small javascript in
your page that prevents the user from posting the same data twice.
I actually had the same issue running a site of mine, and a double POST is
mostly detrimental to the user, so there's no risk of having anyone changing
the JS just to be able to post twice.

You however have to consider users with noscript then.

Or you could try and speed up the process of answering the request so the
user does go like "Oh maybe I didn't click!" using, for example,
asynchronous work.

It's up to you!

Thomas

2011/9/24 Martin Tiršel 

> Hello,
>
> I am using Apache with mod_wsgi and following setting:
>
> WSGIDaemonProcess dev.xyz.com processes=1 threads=5 user=xyz group=xyz
> display-name=dev.xyz.com
>
> I am observing some situations where a user sends the same request multiple
> times (double click?) where the time between these requests is very low -
> 80-100ms. Then I got these situations (bot request from the same user):
>
> 1. request A - SELECT ...
> 2. request B - SELECT ...
> 3. request A - INSERT ... (insert is based on select result from step 1)
> 4. request B - INSERT ... (insert is based on select result from step 2)
>
> Because 1. and 2. gets the same data, I end with doubled (or sometimes
> trippled) inserts what breaks my application. How do you prevent such
> behaviour? I am using Django 1.2.x
>
> I am just applying memcached to prevent these situations:
>
> lock_id = "construction_view-%s" % context['active_base'].id
> acquire_lock = lambda: cache.add(lock_id, "true", LOCK_EXPIRE)
> release_lock = lambda: cache.delete(lock_id)
>
> while not acquire_lock() and lock_attempt < 3:
>time.sleep(1)
>lock_attempt += 1
> else:
>raise ...
> ...
> release_lock()
>
>
> But I am not sure if this is the right way. If there is no better solution,
> the second question is, should I time.sleep(1) until previous request
> releases lock or return some 5xx or 4xx error on such request?
>
> Thanks,
> Martin
>
> --
> 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+unsubscribe@**
> 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: Problem on user profile

2011-09-28 Thread Thomas Orozco
You might be importing your models.py file multiple time, thus registering
the signals multiple times.

You should look into the signals documentation - you can avoid duplicate
signal handlers and this is covered there.
Le 28 sept. 2011 14:44, "Lingfeng Xiong"  a écrit :

-- 
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: View decorator for common navigation elements?

2011-10-03 Thread Thomas Orozco
Maybe you can use template inheritance and have the base template access the
data through, alternatively, template filters or instance methods?

To make those work, you can take advantage of the existing template
processors (notably the auth one).

If you want to not have the topnav on a particular page, you can put it in a
block and replace the block with nothing.
Le 3 oct. 2011 01:07, "Victor Hooi"  a écrit :
> heya,
>
> This SO post seems to suggest that data and template tags shouldn't mix...
>
>
http://stackoverflow.com/questions/5046046/where-put-database-interaction-in-django-templatetags
>
> Not sure how I feel about that myself - I see the philosophical argument
> behind it, but I don't see another more efficiently creating common page
> elements (like my category dropdowns).
>
> Also, if you look at James Bennett's posts here:
>
>
http://www.b-list.org/weblog/2006/jun/07/django-tips-write-better-template-tags/
>
> His code actually *does* interact with the database, as does the blog post

> here
> (
http://www.webmonkey.com/2010/02/use_templates_in_django/#Roll_your_own_template_tags
).
>
> Also, as an aside, each link on our category dropdown is bound to a JS
click
> event - not sure how this would tie in with the custom template tag -
> separate tag for that part of it?
>
> Cheers,
> Victor
>
> --
> 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/-/9cYeQwELEYsJ.
> 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: effective adding records in Django site admin

2011-10-04 Thread Thomas Orozco
Regarding your first question, the admin save_as field does exactly this.
Le 4 oct. 2011 07:01, "veva...@yandex.ru"  a écrit :

-- 
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: Don't understand still

2011-10-15 Thread Thomas Orozco
Just don't assign anything to objects and leave that line out of your code ;
use the default manager.
Le 15 oct. 2011 17:54, "Piotr Hosowicz"  a écrit :

> On 15 Paź, 17:40, Piotr Hosowicz  wrote:
> > Carlos, of course I have data in the DB. Babatunde, the managers is
> > the thing that my friend, local Django guru, didn't answer me. I
> > believe you are right, I just copied the manager with empty body from
> > previous pieces of code that worked. I'll try it, thanks a lot.
>
> Babatunde, now I have objects = models.Manager()  but it did not
> help. :-(
>
> Regards,
>
> Piotr Hosowicz
>
> --
> 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: trouble with pre_delete signal method

2012-12-18 Thread Thomas Orozco
Hi,


Could you provide the following information?
- What's the relationship between A and B (model code of the field, if
there is, would be great)
- The code of your pre_delete signal handler / the method it calls.

I think you have a ForeignKey field that is required or limited and that is
causing the ValidationError.
Indeed, that line 988 is in the code for ModelChoiceField


Best,

Thomas

2012/12/17 Mike Dewhirst 

> I'm getting a baffling ValidationError.
>
> Request URL:
> http://127.0.0.1:8000/admin/**assembly/item/4/
> Django Version: 1.4.3
> Exception Type: ValidationError
> Exception Value:[u'Select a valid choice. That choice is not one
> of the available choices.']
>
> Exception Location: C:\usr\bin\lib\site-packages\**django\forms\models.py
> in to_python, line 988
> Python Version: 2.7.3
>
> Background ...
>
> I have an Item model which has two one-to-many relationships with other
> types of child records (call them A and B models).
>
> In the Admin, when the user adds an A record, some B records get added
> automatically.
>
> The next A record to get added does much the same but if there are any B
> duplicates it doesn't try to add those but instead just adds its mark to a
> special field in the B record which is already there.
>
> My code - which from embedded print statements appears to be doing exactly
> what I want - will either delete the B record or just remove the mark
> previously added. Eventually when the last A record is deleted the idea is
> that the last B records will go at the same time.
>
> Unfortunately, at the final hurdle we get the ValidationError at line 988
> in to_python.
>
> The local vars nominate ...
>
> self
> value   u'251'
> key 'pk'
>
> ... and that is the pk of the A record which triggers the Item code via a
> pre_delete signal.
>
> Summarising:
>
> - the deletion/mark removal method lives in the Item model
> - the pre-delete signal is detected in the A record
> - the signal connects a stub method in the A record
> - the stub method in the A record calls the Item method
> - the Item method iterates over a filtered queryset of B records and uses
> the passed value (the aforesaid mark from the A record) to decide whether
> to delete the B record or just remove the mark and save it
>
> None of my code appears in the TraceBack so I assume the Admin is trying
> to delete the A record. I've tried both pre_delete and post_delete signals
> in the A record.
>
> Why is it so?
>
> Thanks for any hints
>
> Mike
>
>
> --
> 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+unsubscribe@**
> 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: 【HELP】AttributeError: 'AdminSite' object has no attribute 'urls'

2012-12-18 Thread Thomas Orozco
What version of django are you using?

admin.site.urls was introducd four years ago (
https://github.com/django/django/commit/1f84630c87f8032b0167e6db41acaf50ab710879),
but maybe you're running an older version?

Best,

Thomas


2012/12/15 向浩 

> Environment:
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/admin/
> Django Version: 1.0.4
> Python Version: 2.7.3
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.admin',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'mysite.books']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
>
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
> in get_response
>   82. request.path_info)
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
> in resolve
>   181. for pattern in self.urlconf_module.urlpatterns:
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
> in _get_urlconf_module
>   205. self._urlconf_module = __import__(self.urlconf_name,
> {}, {}, [''])
> File "/home/xhao/djcode/mysite/../mysite/urls.py" in 
>   16. (r'^admin/', include(admin.site.urls)),
>
> Exception Type: AttributeError at /admin/
> Exception Value: 'AdminSite' object has no attribute 'urls'
>
>  --
> 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/-/SdlHuLExd9YJ.
> 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: 【HELP】AttributeError: 'AdminSite' object has no attribute 'urls'

2012-12-18 Thread Thomas Orozco
Haha indeed, silly me!

Well I think that's the error cause then : the urls property apparently
didn't exist in Django 1.0!

Cheers,

Thomas
On Dec 18, 2012 3:14 PM, "Ramiro Morales"  wrote:

> On Tue, Dec 18, 2012 at 10:12 AM, Thomas Orozco  wrote:
> > What version of django are you using?
> >
> > admin.site.urls was introducd four years ago
> > (
> https://github.com/django/django/commit/1f84630c87f8032b0167e6db41acaf50ab710879
> ),
> > but maybe you're running an older version?
>
> On Fri, Dec 14, 2012 at 11:06 PM, 向浩  wrote:
> > Environment:
> >
> > Request Method: GET
> > Request URL: http://127.0.0.1:8000/admin/
> > Django Version: 1.0.4
> > Python Version: 2.7.3
>
> --
> Ramiro Morales
>
> --
> 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: trouble with pre_delete signal method

2012-12-19 Thread Thomas Orozco
Hi,

If you have no relationship, I'm a bit at a loss. I think the easier
way would be to use a debugger if possible.

I think we need to know what field is causing the ValidationError.
The line that's causing an error is in the to_python method of the
ModelChoiceField object.

Basically, you'll need to use a debugger to extract as much
information from that object to be able to tell which field it is.
(ModelChoiceField.queryset will give you the list of objects that can
fit in that field. It could help).

(See https://github.com/django/django/blob/master/django/forms/models.py#L988)



On a side note, I can't see how your delete_bparts method would work:

When you don't want to delete, you join using '' ( bpart.a_partcodes =
' '.join(acodes) )
But you split using split(), which splits on whitespace: acodes =
bpart.a_partcodes.split()

Am I missing something here?



Last, would you mind sharing the bpart.a_partcodes code ?


Cheers,


Thomas

2012/12/19 Mike Dewhirst :
> Thomas
>
> Thanks for replying
>
>
> On 19/12/2012 12:06am, Thomas Orozco wrote:
>>
>> Hi,
>>
>>
>> Could you provide the following information?
>>  - What's the relationship between A and B (model code of the field,
>> if there is, would be great)
>
>
> There is no relationship at all. A and B are separately and independently
> related to Item.
>
> A and B are actually copied from 'a' and 'b' which *are* related but exist
> purely as a stand-alone reference. When Item gets an A record (and it can
> have many) it is copied from its 'a' reference record. Item then
> automatically gets copies of all the corresponding 'b' reference records as
> B records - except duplicates are semi-skipped.
>
> Where a duplicate would have occurred, I append the A_code into a special
> field on the B record to indicate which A records were/are "interested" in
> that B record. When A records are deleted, it is necessary to delete their
> corresponding B records - unless another A record is still interested in
> which case we just remove the deleted A_code from the special field.
>
> I could send you the model code off-list if you wish.
>
>
>>  - The code of your pre_delete signal handler / the method it calls.
>
>
> #  this lives in models.A_Part.py   #   #   #
>
> from django.db.models.signals import pre_delete, post_delete
>
> def cleanup_bparts(sender, instance, **kwargs):
> instance.item.delete_bparts(a_code=instance.a_code)
>
> pre_delete.connect(cleanup_bparts, sender=A_Part, weak=False)
> #post_delete.connect(cleanup_bparts, sender=A_Part, weak=False)
>
> #   #   #   #   #   #   #   #   #   #   #   #
>
> ... and the item.delete_bparts() code ...
>
>
> def delete_bparts(self, a_code):
> qs_bpart = B_Part.objects.filter(item=self,
>  a_partcodes__contains=a_code)
> for bpart in qs_bpart:
> acodes = bpart.a_partcodes.split()
> if len(acodes) == 1:
> bpart.delete()
> else:
> acodes.remove(a_code)
> bpart.a_partcodes = ' '.join(acodes)
> bpart.save()
>
>
>>
>> I think you have a ForeignKey field that is required or limited and that
>> is causing the ValidationError.
>> Indeed, that line 988 is in the code for ModelChoiceField
>
>
> I have been through all the fk fields and they are all null=True, blank=True
> and in Postgress each _id column is nullable.
>
> I also had an ordering sequence on some of the models and I removed all that
> as well.
>
> As mentioned earlier, embedded print statements seem to prove the
> delete_bparts() code is working nicely.
>
> When I comment out the pre-delete connection, the A_Part record gets delete
> as expected - but obviously it doesn't clean up the B records.
>
> Thanks 
>
> Mike
>
>>
>>
>> Best,
>>
>> Thomas
>>
>> 2012/12/17 Mike Dewhirst > <mailto:mi...@dewhirst.com.au>>
>>
>>
>> I'm getting a baffling ValidationError.
>>
>> Request URL: http://127.0.0.1:8000/admin/__assembly/item/4/
>>
>> <http://127.0.0.1:8000/admin/assembly/item/4/>
>> Django Version: 1.4.3
>> Exception Type: ValidationError
>> Exception Value:[u'Select a valid choice. That choice is not
>> one of the available choices.']
>>
>> Exception Location:
>> C:\usr\bin\lib\site-packages\__django\forms\models.py in to_python,
>>
>> line 988
>> Python Version: 2.7.3
>>
&g

Re: trouble with pre_delete signal method

2012-12-19 Thread Thomas Orozco
Hi Mike,

Could you try using a debugger as suggested?

Otherwise and if that's OK with you / your job, could you send me minimal
model code off-list so I can have a look at it?

I'm pretty sure we're just missing something obvious! : )

Cheers,

Thomas


2012/12/19 Mike Dewhirst 

> On 19/12/2012 12:06am, Thomas Orozco wrote:
>
>>
>> I think you have a ForeignKey field that is required or limited and that
>> is causing the ValidationError.
>> Indeed, that line 988 is in the code for ModelChoiceField
>>
>
> I have now been through the entire application and adjusted *ALL* foreign
> keys to be nullable in Postgres and null=True, blank=True throughout all
> models.
>
> I have also commented out all the save() and clean() methods of all models
> involved.
>
> In the Admin, I check the "Delete" check-box for the A record - which is
> displayed in-line on the Item page - and click [Save].
>
> There is no change in the error. The A record won't delete and the entire
> transaction rolls back.
>
> I'm stumped.
>
> Do you think this is an edge case?
>
>
> Mike
>
> --
> 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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en<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: trouble with pre_delete signal method

2012-12-20 Thread Thomas Orozco
It's great that you could find where the issue is coming from!

Cheers,

Thomas


2012/12/20 Mike Dewhirst 

> On 19/12/2012 11:58pm, Thomas Orozco wrote:
>
>> Hi,
>>
>> If you have no relationship, I'm a bit at a loss. I think the easier
>> way would be to use a debugger if possible.
>>
>> I think we need to know what field is causing the ValidationError.
>> The line that's causing an error is in the to_python method of the
>> ModelChoiceField object.
>>
>> Basically, you'll need to use a debugger to extract as much
>> information from that object to be able to tell which field it is.
>> (ModelChoiceField.queryset will give you the list of objects that can
>> fit in that field. It could help).
>>
>
> Thomas
>
> I adjusted the error message in ModelChoiceField to include the key, value
> and the actual error raised. This revealed the problem. Thanks for pointing
> me in the right direction.
>
> It is raising DoesNotExist and nominating the first B record which would
> be deleted according to my code.
>
> This says it is already deleted. Which leads me to believe my code is
> deleting it unexpectedly as far as the Admin is concerned.
>
> I believe the Admin is built to delete records itself and won't cope with
> records being deleted behind its back. It must be designed to consider such
> a thing as an integrity error.
>
> If I adjust my code to simply null the item_id then everything looks good
> and I end up with a bunch of orphaned records in the database. Lucky its
> just a prototype :)
>
> I don't think I can do anything about this. It would need an Admin dev to
> figure out what to do. My inclination would be a meta option to signal that
> ModelChoiceField needn't worry if the record does not exist.
>
> Thanks for all your effort
>
> Much appreciated
>
> Mike
>
>
>
>> (See https://github.com/django/**django/blob/master/django/**
>> forms/models.py#L988<https://github.com/django/django/blob/master/django/forms/models.py#L988>
>> )
>>
>>
>>
>> On a side note, I can't see how your delete_bparts method would work:
>>
>> When you don't want to delete, you join using '' ( bpart.a_partcodes =
>> ' '.join(acodes) )
>> But you split using split(), which splits on whitespace: acodes =
>> bpart.a_partcodes.split()
>>
>> Am I missing something here?
>>
>
> It must be a typo because I actually join using a space.
>
>
>
>>
>>
>> Last, would you mind sharing the bpart.a_partcodes code ?
>>
>>
>> Cheers,
>>
>>
>> Thomas
>>
>> 2012/12/19 Mike Dewhirst :
>>
>>> Thomas
>>>
>>> Thanks for replying
>>>
>>>
>>> On 19/12/2012 12:06am, Thomas Orozco wrote:
>>>
>>>>
>>>> Hi,
>>>>
>>>>
>>>> Could you provide the following information?
>>>>   - What's the relationship between A and B (model code of the
>>>> field,
>>>> if there is, would be great)
>>>>
>>>
>>>
>>> There is no relationship at all. A and B are separately and independently
>>> related to Item.
>>>
>>> A and B are actually copied from 'a' and 'b' which *are* related but
>>> exist
>>> purely as a stand-alone reference. When Item gets an A record (and it can
>>> have many) it is copied from its 'a' reference record. Item then
>>> automatically gets copies of all the corresponding 'b' reference records
>>> as
>>> B records - except duplicates are semi-skipped.
>>>
>>> Where a duplicate would have occurred, I append the A_code into a special
>>> field on the B record to indicate which A records were/are "interested"
>>> in
>>> that B record. When A records are deleted, it is necessary to delete
>>> their
>>> corresponding B records - unless another A record is still interested in
>>> which case we just remove the deleted A_code from the special field.
>>>
>>> I could send you the model code off-list if you wish.
>>>
>>>
>>>- The code of your pre_delete signal handler / the method it
>>>> calls.
>>>>
>>>
>>>
>>> #  this lives in models.A_Part.py   #   #   #
>>>
>>> from django.db.models.signals import pre_delete, post_delete
>>>
>>> def cleanup_bparts(sender, instance, **kwargs):
>>>  in

Re: Form validation number and text only no space mac 4 numbers

2013-08-31 Thread Thomas Orozco
Change you regex to: r'^[a-zA-Z0-9]{1,4}'


On Sat, Aug 31, 2013 at 5:41 PM, Gerd Koetje wrote:

> Hi all,
>
> How do i valididate for this?
>
> - numbers and text only , no spaces
> - max 4 number
>
>
>
>
> def clean_profielnaam(self):
> data = self.cleaned_data['profielnaam']
> if not re.match(r'^[a-z][0-9]+', data):
> raise forms.ValidationError("Je mag alleen tekst en cijfers
> gebruiken en geen spaties")
>
> return data
>
>  --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Form validation number and text only no space mac 4 numbers

2013-08-31 Thread Thomas Orozco
Oh, yes, we need to search for the end of the string:

r'^[a-zA-Z0-9]{1,4}$'


On Sat, Aug 31, 2013 at 6:03 PM, Gerd Koetje wrote:

> that still allows space,weird chars and more then 4 numbers
>
> input:
> dfdfdf565665&^^^ 
> got saved
>
>
>
> def clean_profielnaam(self):
> data = self.cleaned_data['profielnaam']
> if not re.match(r'^[a-zA-Z0-9]{1,4}', data):
> raise forms.ValidationError("Je mag alleen tekst en cijfers
> gebruiken en geen spaties")
>
> return data
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Form validation number and text only no space mac 4 numbers

2013-08-31 Thread Thomas Orozco
Oh, I thought you needed only 4 total chars.


Using a regex probably is a bit overkill here:

>>> import string
>>> accepted = string.letters + string.digits
>>> max_numbers = 4
>>>
>>> def test(word):
... numbers = 0
... for c in word:
... if c.isdigit():
... numbers += 1
... if not c in accepted or numbers > max_numbers:
... return False
... return True
...
>>>
>>> test('gerd12')
True
>>> test('gerd1234')
True
>>> test('gerd 1234 ')
False
>>> test('gerd 1234')
False
>>> test('%$$%%#$')
False
>>> test('gerd123456')
False



On Sat, Aug 31, 2013 at 6:11 PM, Gerd Koetje wrote:

> to explain myself a bit more:
>
> gerd12 = should be valid
> gerd1234   = should be valid
> gerd 1234 = should not be valid
> %$$%%#$ = should not be valid
> gerd123456 - should not be valid
>
> etc etc
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Form validation number and text only no space mac 4 numbers

2013-08-31 Thread Thomas Orozco
Because the indentation is not correct, and doesn't correspond to what I
sent you.

`return True` should be 4 chars left of where it currently is.


On Sat, Aug 31, 2013 at 7:23 PM, Gerd Koetje wrote:

> it somehow keeps returning True on everything
>
> accepted = string.letters + string.digits
> max_numbers = 4
>
>
> def test(word):
> numbers = 0
> for c in word:
> if c.isdigit():
> numbers += 1
> if not c in accepted or numbers > max_numbers:
>return False
> return True
>
> # profielnaam
> class ProfielenForm(forms.ModelForm):
>
>
> def clean_profielnaam(self):
>
> logger.debug('>>>FORMS< %s', accepted)
>
>
> data = self.cleaned_data['profielnaam']
> testdata = test(data)
> logger.debug('>>>FORMS<< >DATA< %s',
> testdata)
>
> if testdata is "False":
> raise forms.ValidationError("Je mag alleen tekst en cijfers
> gebruiken en geen spaties")
>
> return data
>
> class Meta:
> model = Profielen
> fields = ('profielnaam',)
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Form validation number and text only no space mac 4 numbers

2013-08-31 Thread Thomas Orozco
test(data) returns True if the string is acceptable, and False if it's not.

But False is an object, it's not the the string "False" - I'd strongly
recommend you start with a Python tutorial before moving on to your Django
project.

Cheers;


On Sat, Aug 31, 2013 at 7:27 PM, Gerd Koetje wrote:

> think i fixed the true/false thing, return True was on the wrong indent
>
> it still doesnt trow the error , so i gues my if testdata us False:  is
> wrong?
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Passing initial values to a form

2013-09-01 Thread Thomas Orozco
The URL parameter (iid) is accessible in your view in self.kwargs["iid"].

You can pass it to the form by overriding your view's `get_initial` method (
https://github.com/django/django/blob/1.6b2/django/views/generic/edit.py#L22
)


`get_initial` should return a dict, and you should use:

{
'name_of_the_model_field': self.kwargs["iid"]
}


On Sun, Sep 1, 2013 at 6:37 PM, Drew Ferguson wrote:

> Hi
>
> I have gotten myself badly confused today trying to figure this out.
>
> If I have these elements
>
> # urls.py
> url(r'^banker/(?P\d+)/iac$', view = IacCreateView.as_view())
>
> # views.py
> class IacCreateView(LoginRequiredMixin, CreateView):
> template_name = 'iaccount_form.html'
> model = Iaccount
> form_class = IaccountForm
>
> # forms.py
> class IaccountForm(forms.ModelForm):
> class Meta(object):
> model = Iaccount
>
> How can I use a value (iid) from the url to set a field's initial
> value in the form
>
> or more generally pass initial values into the form from a previous page
> --
> Drew
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: error

2013-09-13 Thread Thomas Orozco
If the request is a GET (and not a POST), you never return and HTTPResponse
(or anything, for that matter, so you're returning None)


On Fri, Sep 13, 2013 at 4:39 PM, Harjot Mann wrote:

> I am making an app to add time schedule and while making view. I ma
> getting this error
>
> The view time_schedule.views.category_choice didn't return an
> HttpResponse object.
> Here is the code:
> http://tny.cz/46777400
> Please help me fast
>
>
>
> --
> Harjot Kaur Mann
> Blog: http://harjotmann.wordpress.com/
> Daily Dairy: http://harjotmann.wordpress.com/daily-diary/
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Where to put code that adds additional data to the model object?

2013-09-13 Thread Thomas Orozco
You can define it in the Model. Models are still "regular" Python objects
that you can add methods to.

Be wary of performance though, if you don't cache the results or something.


On Fri, Sep 13, 2013 at 4:33 PM, Ladislav P  wrote:

> Hi,
>
> I have started working with django just couple of days ago and I am
> already quite familiar with it, but I still do not understand clearly the
> models.
>
> I have some model class, but after retrieving it with .objects.all I want
> to add some other data to these objects got from XMLRPC services.
>
> I know I can add it dynamically to the queryset, but should I do it in
> model or view? Does model define just data and is exclusively for database
> operations / abstract classes?
>
> LP
>
>
>  --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Possible documentation/implementation bug for unique_together

2013-10-11 Thread Thomas Orozco
Those two tuples are stricly equivalent from Python's point of view, so the
problem must be somewhere else,

Did you change anything else? What's the error message like?

Cheers,


On Fri, Oct 11, 2013 at 11:46 PM, puff  wrote:

> I'm relatively new to Django and used unique_together in 1.5 per the
> development documentation:
>
> unique_together = ("driver", "restaurant")
>
>
> This appears to cause run time errors leading to a transaction abort.
>  However,
>
> unique_together = ("driver", "restaurant",)
>
> seems to work.
>
> Is this a documentation bug or implementation bug?  If so how to determine
> which and best report it?
>
> Regards,
> Richard
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/dd8fef08-4486-4827-af62-fc92604aafcb%40googlegroups.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMuNovSFKHzoXgV_ffWFAy3BBi5kN4orVzp6akppaQ8GZCRthg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Ubuntu, Postgres, and psycopg2.

2013-10-17 Thread Thomas Orozco
You need the Postgres client C headers to build psycopg2. Before running
pip install psycopg2, run:

sudo apt-get install libpq-dev




On Thu, Oct 17, 2013 at 10:51 AM, Nigel Legg  wrote:

> I am not sure whether this is really a postgres issue or a python / Django
> issue - please let me know if I should be posting this elsewhere.
> I have installed Ubuntu 13.04, Postgres 9.1 and Django. (strangely, the
> Ubuntu software centre says I have Python 3.3, but when I go into the
> Python shell it says 2.7.4).
> I followed the instructions on configuring Postgres from
> http://blog.iiilx.com/programming/how-to-install-postgres-on-ubuntu-for-django/,
> up to the point of adding a line to the pg_hba.conf file - Ubuntu would not
> let me write to this.
> When I tried to install psycopg2 (pip install psycopg2),  I got the
> following error:
>
> ERROR: you need to install postgresql-server-dev-X.Y for building a server
> side extension or libpq-dev for building a client-side application.
>
> What does this mean?  How do I proceed?
>
> Many thanks in advance for your 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3b3fa90f-7602-40ff-ab79-55d70c3074f1%40googlegroups.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMuNovQyS1jhWLieeZ-Etb%2Bfpp1%2B6iaSRTuf5hNxVFJQpC4fWw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Ubuntu, Postgres, and psycopg2.

2013-10-17 Thread Thomas Orozco
You're missing:

sudo apt-get install python-dev


On Thu, Oct 17, 2013 at 11:31 AM, Nigel Legg  wrote:

> Thanks Thomas, that worked, so some progress, but now when I do sudo pip
> psycopg2, I get an error: Python.h not found -
> In file included from psycopg/psycopgmodule.c:27:0:
> ./psycopg/psycopg.h:30:20: fatal error: Python.h: no such file or
> directory.
> Should I be downloading and building the source?
>
> Cheers, Nigel
> 07914 740972
>
>
>
> On 17 October 2013 09:57, Thomas Orozco  wrote:
>
>>  You need the Postgres client C headers to build psycopg2. Before
>> running pip install psycopg2, run:
>>
>> sudo apt-get install libpq-dev
>>
>>
>>
>>
>>  On Thu, Oct 17, 2013 at 10:51 AM, Nigel Legg wrote:
>>
>>> I am not sure whether this is really a postgres issue or a python /
>>> Django issue - please let me know if I should be posting this elsewhere.
>>> I have installed Ubuntu 13.04, Postgres 9.1 and Django. (strangely, the
>>> Ubuntu software centre says I have Python 3.3, but when I go into the
>>> Python shell it says 2.7.4).
>>> I followed the instructions on configuring Postgres from
>>> http://blog.iiilx.com/programming/how-to-install-postgres-on-ubuntu-for-django/,
>>> up to the point of adding a line to the pg_hba.conf file - Ubuntu would not
>>> let me write to this.
>>> When I tried to install psycopg2 (pip install psycopg2),  I got the
>>> following error:
>>>
>>> ERROR: you need to install postgresql-server-dev-X.Y for building a
>>> server side extension or libpq-dev for building a client-side application.
>>>
>>> What does this mean?  How do I proceed?
>>>
>>> Many thanks in advance for your 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/3b3fa90f-7602-40ff-ab79-55d70c3074f1%40googlegroups.com
>>> .
>>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMuNovQyS1jhWLieeZ-Etb%2Bfpp1%2B6iaSRTuf5hNxVFJQpC4fWw%40mail.gmail.com
>> .
>>
>> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CADeX7vwToyt8ze989WhUkmQ2nx0TwTqt8L7ibC3sHrGjZeRjBA%40mail.gmail.com
> .
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMuNovTGg84%2BLefLWV93CyDncbBpyzg0%2BvtnTgcsuo8M-fscuQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Can not connect to MySQL

2013-10-17 Thread Thomas Orozco
Most likely it's the MySQLdb package (
https://pypi.python.org/pypi/MySQL-python) that's not installed.

Installing it *will* require installing libmysql-client first, though.


On Thu, Oct 17, 2013 at 10:05 PM, François Schiettecatte <
fschietteca...@gmail.com> wrote:

> Could be a number of things:
>
> - mysql may not be installed.
>
> - mysql is installed but in a non-standard location.
>
> - mysql is the wrong version.
>
> You can start tracking down these issues by running mysql_config
>
> François
>
> On Oct 17, 2013, at 3:47 PM, timdang2...@yahoo.com wrote:
>
> > Hi, I am new to Django and try to connect to database MySQL I get this
> message: Can anyone help? thanks in advance.
> >
> > Unhandled exception in thread started by  of  at 0x3026810>>
> > Traceback (most recent call last):
> >   File
> "/home/tee/django-tee/local/lib/python2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/commands/runserver.py",
> line 92, in inner_run
> > self.validate(display_num_errors=True)
> >   File
> "/home/tee/django-tee/local/lib/python2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/base.py",
> line 280, in validate
> > num_errors = get_validation_errors(s, app)
> >   File
> "/home/tee/django-tee/local/lib/python2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/validation.py",
> line 28, in get_validation_errors
> > from django.db import models, connection
> >   File
> "/home/tee/django-tee/local/lib/python2.7/site-packages/Django-1.5.4-py2.7.egg/django/db/__init__.py",
> line 40, in 
> > backend = load_backend(connection.settings_dict['ENGINE'])
> >   File
> "/home/tee/django-tee/local/lib/python2.7/site-packages/Django-1.5.4-py2.7.egg/django/db/__init__.py",
> line 34, in __getattr__
> > return getattr(connections[DEFAULT_DB_ALIAS], item)
> >   File
> "/home/tee/django-tee/local/lib/python2.7/site-packages/Django-1.5.4-py2.7.egg/django/db/utils.py",
> line 93, in __getitem__
> > backend = load_backend(db['ENGINE'])
> >   File
> "/home/tee/django-tee/local/lib/python2.7/site-packages/Django-1.5.4-py2.7.egg/django/db/utils.py",
> line 27, in load_backend
> > return import_module('.base', backend_name)
> >   File
> "/home/tee/django-tee/local/lib/python2.7/site-packages/Django-1.5.4-py2.7.egg/django/utils/importlib.py",
> line 35, in import_module
> > __import__(name)
> >   File
> "/home/tee/django-tee/local/lib/python2.7/site-packages/Django-1.5.4-py2.7.egg/django/db/backends/mysql/base.py",
> line 17, in 
> > raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> > django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> module: No module named MySQLdb
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/86dad6e4-ba16-489c-9fa8-d1722c089d11%40googlegroups.com
> .
> > 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5BB2B165-8731-48CB-BC75-D36551EA1C7C%40gmail.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMuNovRmGjYi2LV%2BVzjiFt2qax05KtGcSy5NNVm8zxUGQjc7aw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django traffic control

2013-10-25 Thread Thomas Orozco
You could use middleware, or a view decorator
On Oct 25, 2013 5:33 PM, "Nuno Lopes"  wrote:

> Hi guys/girls,
>
> I have a project in Django and I want to control the access to an API.
> Basically just know and register who is using it.
> I could go to each controller and do this by hand using the api key. But I
> am hoping that there is a better solution.
>
> Do you have some suggestion to give me? There's already some app doing
> this kind of site/url statistics?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/04451e5d-ad4e-411e-85b5-9986c77687d7%40googlegroups.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMuNovRO%3DgrVv4RbfFBG6a4HJZFnE-MpAAdrHimDY5UXOVagQg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Deploying Django apps with nginx

2013-11-10 Thread Thomas Orozco
Using Nginx, you don't tun the django app "inside" Nginx like you would
using mod_wsgi.

Instead, you use Nginx for reverse proxying (see the proxy_pass directive),
and use a Python webserver for your app(s), e.g. uwsgi, gunicorn.

Serving multiple apps is easy. Just use multiple location blocks and
proxy_pass directives.

Cheers,


On Sun, Nov 10, 2013 at 1:20 PM, Sandeep kaur  wrote:

> Hi,
> I want to deploy multiple django apps on a server with nginx. When we do
> it on apache
> we do it in /etc/apache2/httpd.conf and following content :
>
>  WSGIScriptAlias /django /home/sandy/django_app/apache/django.wsgi
>
>  
>
>  Order allow,deny
>  Allow from all
>  
>
> Thus this app can be accessed by example.com/django or if any other app
> on same server then with example.com/django2. How can we do this with
> nginx?
>
> Your help will be appreciated. :)
> Thank you.
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAF66xG3e34QLWBHvpPO%2B72JAA9FbK3Oo%3DRNO-YuyLvb2LU-aFw%40mail.gmail.com
> .
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMuNovQmSdzTqbrYmoSGJonvpHcS0tc0FvxtgNBpMppbUv%2BW5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: lost admin on upgrade to django 1.3

2011-07-30 Thread Thomas Orozco
Django 1.3 shipped with staticfiles for static documents, maybe you could
look that way.
Le 30 juil. 2011 02:10, "zignorp"  a écrit :
> Hello,
> I just upgraded to 1.3 and thought all was well until I tried to access
> LOCALHOST/admin/
> Can anyone tell me why I'm getting this exception
>
> Exception Type: TemplateDoesNotExist Exception Value:
>
> admin/login.html
>
> ?
>
> Was working fine in the older version.
>
> --
> 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/-/2iEDmZQCEtYJ.
> 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: Django can't see my static files

2011-08-01 Thread Thomas Orozco
If your css file is locatedr in your staticfiles dir, you should use
something such as {{ STATIC_URL }}main.css, assuming your CSS file is called
main and is located in one of the STATIC_DIRS.

Using staticfiles_dirs in a template makes no sense. Not only your are
passing a parameter that has to do with your system configuration and not
your urls, but you are also using a directory instead of a file.

In short, it is the static_url parameter that should be passed to form a
URL.
Le 1 août 2011 12:17, "Gchorn"  a écrit :
> Hello All,
>
> I'm using Django to develop a website, and I'm having trouble getting
> it to see my static files. I've looked through Django's static file
> documentation and the steps I've taken to get Django to see my files
> (using a CSS file as an example) are as follows:
>
> First, I created a folder called "static" inside the main app folder
> for this project. Then, I added "/static/" to the STATIC_URLS section
> of the settings.py file, and I also added the full path to my CSS file
> under the STATICFILES_DIRS section of settings.py.
>
> Then I added the line:
>
> from django.template import RequestContext, loader
>
> As well as "context_instance= RequestContext(request)" as a third
> argument to the "return render_to_response()" call.
>
> Finally, in my url.py file, I added this line at the top:
>
> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
>
> And this line at the bottom (separate from the initial "urlpatterns =
> patterns()" call):
>
> urlpatterns += staticfiles_urlpatterns()
>
> In my HTML/Django template, I added the following link to my CSS file:
>
> 
>
> But then after all of this, when I perform a "python manage.py
> runserver" to preview the website, Django still does not appear to
> find the external CSS file. I must still be missing something but I'm
> not sure what--does anyone know???
>
> I'm sure I'm missing something very basic but I'm a total beginner so
> please be patient with me, I probably need a lot of very specific
> instructions...
>
> thanks,
> Guillaume
>
> --
> 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: Django can't see my static files

2011-08-02 Thread Thomas Orozco
Could you show us the following:

Your staticfiles settings.
The link where your browser fetches the css file (see rendered source head
when browsing) to gets 404'ed.

If you are using a local server, you could try using a STATIC URL of
127.0.0.1:8000/static/.
Note that this will not work if you use runserver on 0.0.0.0, on which case
you should use your local IP address.

On a production server you can do the same, just use your server address.

Finally, you probably did but, have you activated staticfiles in your apps ?


Off Topic: media and static are supposed to be two different things, static
is for your actual static files, and media for user-uploaded files, both
work  pretty much the same way, so it's not a fix to use one in place of the
other.

Le 2 août 2011 10:28, "Guillaume Chorn"  a écrit :
>
> Thomas and Lokesh,
>
> Thanks very much for your help.  I've modified the link in my HTML file to
be:
>
> 
>
> where "stylesheet" is the name of the CSS file, and this file is located
inside the directory listed under STATIC_DIRS in my settings.py file.  As
mentioned in my prior email, I also already have STATIC_URL = '/static/' in
my settings.py file, and I have the correct methods listed under
STATICFILES_FINDERS.
>
> But it is still not working.  Do I have a syntax error somewhere?  Or am I
still missing something in another file?
>
> thanks,
> Guillaume
>
>
> On Mon, Aug 1, 2011 at 6:45 PM, Thomas Orozco 
wrote:
>>
>> If your css file is locatedr in your staticfiles dir, you should use
something such as {{ STATIC_URL }}main.css, assuming your CSS file is called
main and is located in one of the STATIC_DIRS.
>>
>> Using staticfiles_dirs in a template makes no sense. Not only your are
passing a parameter that has to do with your system configuration and not
your urls, but you are also using a directory instead of a file.
>>
>> In short, it is the static_url parameter that should be passed to form a
URL.
>>
>> Le 1 août 2011 12:17, "Gchorn"  a écrit :
>>
>> > Hello All,
>> >
>> > I'm using Django to develop a website, and I'm having trouble getting
>> > it to see my static files. I've looked through Django's static file
>> > documentation and the steps I've taken to get Django to see my files
>> > (using a CSS file as an example) are as follows:
>> >
>> > First, I created a folder called "static" inside the main app folder
>> > for this project. Then, I added "/static/" to the STATIC_URLS section
>> > of the settings.py file, and I also added the full path to my CSS file
>> > under the STATICFILES_DIRS section of settings.py.
>> >
>> > Then I added the line:
>> >
>> > from django.template import RequestContext, loader
>> >
>> > As well as "context_instance= RequestContext(request)" as a third
>> > argument to the "return render_to_response()" call.
>> >
>> > Finally, in my url.py file, I added this line at the top:
>> >
>> > from django.contrib.staticfiles.urls import staticfiles_urlpatterns
>> >
>> > And this line at the bottom (separate from the initial "urlpatterns =
>> > patterns()" call):
>> >
>> > urlpatterns += staticfiles_urlpatterns()
>> >
>> > In my HTML/Django template, I added the following link to my CSS file:
>> >
>> > 
>> >
>> > But then after all of this, when I perform a "python manage.py
>> > runserver" to preview the website, Django still does not appear to
>> > find the external CSS file. I must still be missing something but I'm
>> > not sure what--does anyone know???
>> >
>> > I'm sure I'm missing something very basic but I'm a total beginner so
>> > please be patient with me, I probably need a lot of very specific
>> > instructions...
>> >
>> > thanks,
>> > Guillaume
>> >
>> > --
>> > 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 unsu

Re: Django can't see my static files

2011-08-02 Thread Thomas Orozco
A little detail, but you never know: you should put some ' ' in your link.
Like this :




If there are spaces in your path, this could cause the lookup to fail.

And even if that's not the case, don't rely on the user's browser to fix
coding mistakes.
Le 2 août 2011 10:28, "Guillaume Chorn"  a écrit :
> Thomas and Lokesh,
>
> Thanks very much for your help. I've modified the link in my HTML file to
> be:
>
>  />
>
> where "stylesheet" is the name of the CSS file, and this file is located
> inside the directory listed under STATIC_DIRS in my settings.py file. As
> mentioned in my prior email, I also already have STATIC_URL = '/static/'
in
> my settings.py file, and I have the correct methods listed under
> STATICFILES_FINDERS.
>
> But it is still not working. Do I have a syntax error somewhere? Or am I
> still missing something in another file?
>
> thanks,
> Guillaume
>
> On Mon, Aug 1, 2011 at 6:45 PM, Thomas Orozco wrote:
>
>> If your css file is locatedr in your staticfiles dir, you should use
>> something such as {{ STATIC_URL }}main.css, assuming your CSS file is
called
>> main and is located in one of the STATIC_DIRS.
>>
>> Using staticfiles_dirs in a template makes no sense. Not only your are
>> passing a parameter that has to do with your system configuration and not
>> your urls, but you are also using a directory instead of a file.
>>
>> In short, it is the static_url parameter that should be passed to form a
>> URL.
>> Le 1 août 2011 12:17, "Gchorn"  a écrit :
>>
>> > Hello All,
>> >
>> > I'm using Django to develop a website, and I'm having trouble getting
>> > it to see my static files. I've looked through Django's static file
>> > documentation and the steps I've taken to get Django to see my files
>> > (using a CSS file as an example) are as follows:
>> >
>> > First, I created a folder called "static" inside the main app folder
>> > for this project. Then, I added "/static/" to the STATIC_URLS section
>> > of the settings.py file, and I also added the full path to my CSS file
>> > under the STATICFILES_DIRS section of settings.py.
>> >
>> > Then I added the line:
>> >
>> > from django.template import RequestContext, loader
>> >
>> > As well as "context_instance= RequestContext(request)" as a third
>> > argument to the "return render_to_response()" call.
>> >
>> > Finally, in my url.py file, I added this line at the top:
>> >
>> > from django.contrib.staticfiles.urls import staticfiles_urlpatterns
>> >
>> > And this line at the bottom (separate from the initial "urlpatterns =
>> > patterns()" call):
>> >
>> > urlpatterns += staticfiles_urlpatterns()
>> >
>> > In my HTML/Django template, I added the following link to my CSS file:
>> >
>> > 
>> >
>> > But then after all of this, when I perform a "python manage.py
>> > runserver" to preview the website, Django still does not appear to
>> > find the external CSS file. I must still be missing something but I'm
>> > not sure what--does anyone know???
>> >
>> > I'm sure I'm missing something very basic but I'm a total beginner so
>> > please be patient with me, I probably need a lot of very specific
>> > instructions...
>> >
>> > thanks,
>> > Guillaume
>> >
>> > --
>> > 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.
>>
>
> --
> 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.



  1   2   >