Re: Channels with django signals

2018-02-03 Thread John Wayne
Oh I saw that you fixed it recently. Thank you anyway :)

On Sunday, February 4, 2018 at 1:22:58 AM UTC+1, Andrew Godwin wrote:
>
> Hi John,
>
> This is fixed in the asgiref master branch, I should be releasing it soon.
>
> Andrew
>
> On Sat, Feb 3, 2018 at 4:14 PM, John Wayne <nrftes...@gmail.com 
> > wrote:
>
>> Hi everyone,
>>
>> I am trying to send a channels message from a django signal. The problem 
>> ist that the signal function is not async. So I tried to use the 
>> AsyncToSync wrapper.
>> But it seems this is not possible as the signal handler is run by a 
>> thread and has no event loop.
>>
>> ...
>> self.main_event_loop = asyncio.get_event_loop()
>>   File "/usr/lib/python3.5/asyncio/events.py", line 632, in get_event_loop
>> return get_event_loop_policy().get_event_loop()
>>   File "/usr/lib/python3.5/asyncio/events.py", line 578, in get_event_loop
>> % threading.current_thread().name)
>> RuntimeError: There is no current event loop in thread 'Thread-2'.
>>
>> So I tried to create the AsyncToSync inside the app.py as this gets 
>> executed by the main thread. By passing this instance I tried to execute 
>> the wrapper inside
>> the signal handler. But this also doesn't work and the website is stuck 
>> loading. How can I get around this issue?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/ddda3ff6-79f9-43b8-a201-5792512564d7%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/ddda3ff6-79f9-43b8-a201-5792512564d7%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6fcca1b6-a336-41a0-b7e6-e9024adf560e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Channels with django signals

2018-02-03 Thread John Wayne
Hi everyone,

I am trying to send a channels message from a django signal. The problem 
ist that the signal function is not async. So I tried to use the 
AsyncToSync wrapper.
But it seems this is not possible as the signal handler is run by a thread 
and has no event loop.

...
self.main_event_loop = asyncio.get_event_loop()
  File "/usr/lib/python3.5/asyncio/events.py", line 632, in get_event_loop
return get_event_loop_policy().get_event_loop()
  File "/usr/lib/python3.5/asyncio/events.py", line 578, in get_event_loop
% threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Thread-2'.

So I tried to create the AsyncToSync inside the app.py as this gets 
executed by the main thread. By passing this instance I tried to execute 
the wrapper inside
the signal handler. But this also doesn't work and the website is stuck 
loading. How can I get around this issue?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ddda3ff6-79f9-43b8-a201-5792512564d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting channels 2 to work

2017-12-04 Thread John Wayne
Hi Andrew,

first of all thanks for your reply. With your answer and the information 
from your blog I was able to get my asgi application running. 

Now I want to route all http traffic to django's viewsystem back as i dont 
need channel's http handling. On your blog you posted this snippet

application = ProtocolTypeRouter({
"http": URLRouter([
url("^", DjangoViewSystem),
]),

But how should the DjangoViewSystem class look like? There is no such file 
included.


John

On Friday, December 1, 2017 at 6:22:06 PM UTC+1, Andrew Godwin wrote:
>
> Hi John,
>
> It's not in an end-user-useable state quite yet, so apologies for it being 
> hard to install. Crucially, the docs on ASGI_APPLICATION aren't written yet 
> as I'm still working on authentication stuff!
>
> A brief guide is:
>
>  - Make an asgi.py as specified in 
> http://channels.readthedocs.io/en/2.0/deploying.html
>  - Make a channels.routing.ProtocolTypeRouter in your project's routing.py 
> and configure this as needed (you'll have to read the code for now)
>  - Point ASGI_APPLICATION to that root router.
>
> I'll have a lot more docs and stuff coming soon as I start prepping 
> Channels 2 for a beta release, which will include routing and setup 
> examples.
>
> Andrew
>
> On Fri, Dec 1, 2017 at 6:03 AM, John Wayne <nrftes...@gmail.com 
> > wrote:
>
>> Hi everyone,
>>
>> I am stuck getting the new channels 2 to a working state. I installed 
>> django==2.0rc1,  and channels==2.0.x, daphne==2.0.x, asgiref==2.0.x from 
>> the git repo
>> channels is enabled inside the settings.py. I also created the asgi.py 
>> file in the direcotry of the wsgi.py file acording to the docs. But still i 
>> get this error
>>
>> raise ImproperlyConfigured("Cannot find ASGI_APPLICATION setting.")
>> django.core.exceptions.ImproperlyConfigured: Cannot find ASGI_APPLICATION 
>> setting.
>>
>> So it seems that ASGI_APPLICATION has to be specified. So after adding 
>> the following line:
>> ASGI_APPLICATION='mytestproject.asgi.application'
>> and starting ./manage.py runserver it now complains again. So which value 
>> is supposed to be there?
>>
>>   raise ImproperlyConfigured("Cannot find %r in ASGI_APPLICATION 
>> module %s" % (name, path))
>> django.core.exceptions.ImproperlyConfigured: Cannot find 'application' in 
>> ASGI_APPLICATION module mytestproject.asgi
>>
>> I need to stick to version 2 as i want to try out asgigram (
>> https://github.com/andrewgodwin/asgigram).
>>
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/3c426628-13da-4ad3-8e4c-3e8938ab0c8d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/3c426628-13da-4ad3-8e4c-3e8938ab0c8d%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/22ceb8b4-e28e-4301-857a-3fffb211e5a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Getting channels 2 to work

2017-12-01 Thread John Wayne
Hi everyone,

I am stuck getting the new channels 2 to a working state. I installed 
django==2.0rc1,  and channels==2.0.x, daphne==2.0.x, asgiref==2.0.x from 
the git repo
channels is enabled inside the settings.py. I also created the asgi.py file 
in the direcotry of the wsgi.py file acording to the docs. But still i get 
this error

raise ImproperlyConfigured("Cannot find ASGI_APPLICATION setting.")
django.core.exceptions.ImproperlyConfigured: Cannot find ASGI_APPLICATION 
setting.

So it seems that ASGI_APPLICATION has to be specified. So after adding the 
following line:
ASGI_APPLICATION='mytestproject.asgi.application'
and starting ./manage.py runserver it now complains again. So which value 
is supposed to be there?

  raise ImproperlyConfigured("Cannot find %r in ASGI_APPLICATION module 
%s" % (name, path))
django.core.exceptions.ImproperlyConfigured: Cannot find 'application' in 
ASGI_APPLICATION module mytestproject.asgi

I need to stick to version 2 as i want to try out asgigram 
(https://github.com/andrewgodwin/asgigram).

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3c426628-13da-4ad3-8e4c-3e8938ab0c8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template Not Applying - Django Polls Tutorial (Newbie Question)

2014-12-29 Thread Ken Wayne
That was it...

On Friday, December 26, 2014 4:45:13 PM UTC-6, Collin Anderson wrote:
>
> Hi,
>
> This one comes up a lot. It's confusing because {% block title %} is the 
> _html_ , the title of the browser tab.
>
> You want to change {% block branding %}.
>
> Collin
>
> On Tuesday, December 23, 2014 5:18:49 PM UTC-6, Ken Wayne wrote:
>>
>>  Hmmm, that is one of the directories I tried, 
>> C:\Python34\Scripts\mysite\templates\admin with the file base_site.html 
>>
>> On 12/23/2014 5:07 PM, Néstor wrote:
>>  
>>  You might need to make for admin
>>  mysite/templates/admin/base_site.html
>>  
>> for regular html files for the polls only
>>  mysite/polls/templates/polls/index.html
>>
>>  That is how I got it to work.  Good luck!!!
>>
>> :-)
>>  
>> On Tue, Dec 23, 2014 at 2:13 PM, Ken Wayne <ecom...@gmail.com> wrote:
>>
>>>  Windows 8
>>>  Django 1.7.1
>>> Python 3.4.2
>>>  Google Chrome Version 39.0.2171.95 m
>>>
>>>  Bottom of part 2 of the the tutorial 
>>> https://docs.djangoproject.com/en/1.7/intro/tutorial02/ it indicates 
>>> how to customize the admin template but when I follow the directions it 
>>> doesn't show any change in my browser.  I've restarted the development 
>>> server and refreshed my browser. 
>>>
>>>  *File Snip base_site.html:*
>>>  {% block title %}{{ title }} | Polls Administration {% endblock %}
>>>  
>>>  *File Snip settings.py:*
>>>  import os
>>> BASE_DIR = os.path.dirname(os.path.dirname(__file__))
>>> # TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
>>> TEMPLATE_DIRS = ['C:\Python34\Scripts\mysite\templates']
>>>  
>>>  I tried the environment path, and hard coding the path.  Since the 
>>> tutorial didn't indicate the BASE_DIR path I made a copy of the file in 
>>> each of the following directories:
>>> C:\Python34\Scripts\mysite\templates\admin
>>>  C:\Python34\Scripts\mysite\mysite\templates\admin
>>>  C:\Python34\Scripts\mysite\polls\templates\admin
>>>  
>>>  Any thoughts on what I might be doing 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/0a7c4e30-ba26-418b-b217-72936c72975f%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/0a7c4e30-ba26-418b-b217-72936c72975f%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>  
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>> To post to this group, send email to django...@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAON-vCPcGEhk3%2B0wO4RXSnuQWqW5H6H4ZbiHoo1h5yRx36GbBQ%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/django-users/CAON-vCPcGEhk3%2B0wO4RXSnuQWqW5H6H4ZbiHoo1h5yRx36GbBQ%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c710aea-10a9-4f45-9c1e-29fc78db0476%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template Not Applying - Django Polls Tutorial (Newbie Question)

2014-12-23 Thread Ken Wayne
Hmmm, that is one of the directories I tried, 
C:\Python34\Scripts\mysite\templates\admin with the file base_site.html


On 12/23/2014 5:07 PM, Néstor wrote:

You might need to make for admin
mysite/templates/admin/base_site.html

for regular html files for the polls only
mysite/polls/templates/polls/index.html

That is how I got it to work.  Good luck!!!

:-)

On Tue, Dec 23, 2014 at 2:13 PM, Ken Wayne <ecommg...@gmail.com 
<mailto:ecommg...@gmail.com>> wrote:


Windows 8
Django 1.7.1
Python 3.4.2
Google Chrome Version 39.0.2171.95 m

Bottom of part 2 of the the tutorial
https://docs.djangoproject.com/en/1.7/intro/tutorial02/ it
indicates how to customize the admin template but when I follow
the directions it doesn't show any change in my browser.  I've
restarted the development server and refreshed my browser.

*File Snip base_site.html:*
{% block title %}{{ title }} | Polls Administration {% endblock %}

*File Snip settings.py:*
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
TEMPLATE_DIRS = ['C:\Python34\Scripts\mysite\templates']

I tried the environment path, and hard coding the path.  Since the
tutorial didn't indicate the BASE_DIR path I made a copy of the
file in each of the following directories:
C:\Python34\Scripts\mysite\templates\admin
C:\Python34\Scripts\mysite\mysite\templates\admin
C:\Python34\Scripts\mysite\polls\templates\admin

Any thoughts on what I might be doing 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
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto: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/0a7c4e30-ba26-418b-b217-72936c72975f%40googlegroups.com

<https://groups.google.com/d/msgid/django-users/0a7c4e30-ba26-418b-b217-72936c72975f%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto: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/CAON-vCPcGEhk3%2B0wO4RXSnuQWqW5H6H4ZbiHoo1h5yRx36GbBQ%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CAON-vCPcGEhk3%2B0wO4RXSnuQWqW5H6H4ZbiHoo1h5yRx36GbBQ%40mail.gmail.com?utm_medium=email_source=footer>.

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


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5499F84E.1060109%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Template Not Applying - Django Polls Tutorial (Newbie Question)

2014-12-23 Thread Ken Wayne
Windows 8
Django 1.7.1
Python 3.4.2
Google Chrome Version 39.0.2171.95 m

Bottom of part 2 of the the 
tutorial https://docs.djangoproject.com/en/1.7/intro/tutorial02/ it 
indicates how to customize the admin template but when I follow the 
directions it doesn't show any change in my browser.  I've restarted the 
development server and refreshed my browser.

*File Snip base_site.html:*
{% block title %}{{ title }} | Polls Administration {% endblock %}

*File Snip settings.py:*
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
TEMPLATE_DIRS = ['C:\Python34\Scripts\mysite\templates']

I tried the environment path, and hard coding the path.  Since the tutorial 
didn't indicate the BASE_DIR path I made a copy of the file in each of the 
following directories:
C:\Python34\Scripts\mysite\templates\admin
C:\Python34\Scripts\mysite\mysite\templates\admin
C:\Python34\Scripts\mysite\polls\templates\admin

Any thoughts on what I might be doing 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0a7c4e30-ba26-418b-b217-72936c72975f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Poll Tutorial (for Django 1.7) Files Available?

2014-12-22 Thread Ken Wayne
I'm trying to work through the Poll Tutorial and I've run into some 
problems.  I'd like to compare the code I've written to a working file.  Is 
there any place to download the entire working project?

-- 
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/26f1c16c-865c-43a6-910e-5dd90beb22bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Loading fixtures in Django 1.7

2014-11-11 Thread Leonard Wayne
Fred,

Got it!!  Thank you!!

- Leonard

On Sunday, November 9, 2014 5:46:30 PM UTC-5, Leonard Wayne wrote:
>
> I am in the process of upgrading from
> Django 1.6 to 1.7.
>
> I have three fixtures.  I am trying to figure
> out how I should load them.
>
> One fixture is `initial_data.json`, and I know
> that starting with Django 1.7 this special
> fixture no longer gets automatically loaded
> as it did when we used to run `syncdb` (i.e.,
> prior to deprecation in Django 1.7).
>
> So I know all three fixtures should be loaded
> the same way as each other, whatever way that
> may be.
>
> My main question is:
>
> Should I keep using `loaddata`, as in:
>
> python manage.py loaddata .json
>
> Reading the documentation I get the sense
> (though I am not sure) that now the preferred
> approach to load fixtures is to create a
> migration to perform the loading.  But I
> don't see an example of how to do this
> process from beginning to end.  It looks
> like the process starts with creating an
> empty migration, then manually editing the
> migration file to define a function like:
>
> def load_data(apps, schema_editor):
>
> But I don't know how to write this function
> (`load_data`), and I can't find an example.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dc8052d9-7be2-4a96-b9f0-8d4c0cd3f734%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Loading fixtures in Django 1.7

2014-11-09 Thread Leonard Wayne
I am in the process of upgrading from
Django 1.6 to 1.7.

I have three fixtures.  I am trying to figure
out how I should load them.

One fixture is `initial_data.json`, and I know
that starting with Django 1.7 this special
fixture no longer gets automatically loaded
as it did when we used to run `syncdb` (i.e.,
prior to deprecation in Django 1.7).

So I know all three fixtures should be loaded
the same way as each other, whatever way that
may be.

My main question is:

Should I keep using `loaddata`, as in:

python manage.py loaddata .json

Reading the documentation I get the sense
(though I am not sure) that now the preferred
approach to load fixtures is to create a
migration to perform the loading.  But I
don't see an example of how to do this
process from beginning to end.  It looks
like the process starts with creating an
empty migration, then manually editing the
migration file to define a function like:

def load_data(apps, schema_editor):

But I don't know how to write this function
(`load_data`), and I can't find an example.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e39e44eb-66c5-4e23-89a5-c2abfae9a6ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What editor do you use for .po files?

2012-08-08 Thread wayne


A neat new tool to edit .po files ( gettext ) is http://poeditor.com/. It’s 
online, free and very easy to use.  It also permits collaborative work and 
imports from multiple files.

On Saturday, June 20, 2009 12:05:08 AM UTC+3, Joshua Russo wrote:
>
> I started using PoEdit but it seems to thing that the .po files 
> created by makemessages are malformed, or at least don't have all the 
> right headers. Is there a better editor for Windows?

-- 
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/-/NzFfaxd0TcsJ.
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 filename

2012-01-27 Thread wayne

This is the same as the FileField. The UploadedFile class has a name
property, which can be used..

https://docs.djangoproject.com/en/dev/topics/http/file-uploads/#handling-uploaded-files



On Jan 19, 9:56 am, Mike Dewhirst  wrote:
> How do I get the actual filename of the uploaded image?
>
> The docs mention ...
>
> FileField.upload_to
> A local filesystem path that will be appended to your MEDIA_ROOT setting
> to determine the value of the url attribute.
>
> ... and presumably the widget which uploads the image knows the filename
> to tack onto the end of upload_to when the webserver gets the request to
> store the image.
>
> But how can I get access to that filename in the model so I can parse it
> and give it a meaningful (to humans) name when being saved?
>
> The docs go on to mention upload_to as a callable but I'm sticking to a
> fixed directory in MEDIA_ROOT for these images.
>
> 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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Storing data from frequently changing forms

2011-10-11 Thread Michael Wayne Goodman
Hi all, I'm new to this and could use some help,

I'm implementing a large-ish form-based application for an ongoing
academic project. As students come and go, the form fields change
frequently, so I'm wary to have form fields map to database entries.
Does anyone have a good idea of how to store the form data? Currently
the data is serialized and the user can download/upload it from/to the
form. Perhaps I could store the serialized data in the database as one
large CharField, or I could do something more robust to change like
RDF triples?

Any ideas or comments would be appreciated.

-- 
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: modelformset partial save and AttributeErrors

2011-09-29 Thread Michael Wayne Goodman
Ahem... turned out to be quite a small problem.

number.qsession = request.qsession

should be

number.qsession = request.session['qsession']

Sorry for the list noise. But if anybody has a better idea for how to
tie data from multiple forms together with a common "session" (not
necessarily a Django session), besides putting all the data in the
session dictionary, then I'd be happy to hear them. Thanks

On Sep 28, 10:46 pm, Michael Wayne Goodman <goodman@gmail.com>
wrote:
> Hi, I'm getting the following error when I try to assign a value to a
> model attribute in a modelformset:
>
> AttributeError at /number/
> 'WSGIRequest' object has no attribute 'qsession'
>
> which occurs in the following snippet:
>
>             numbers = formset.save(commit=False)
>             for number in numbers:
>                 number.qsession = request.qsession
>                 number.save()
>
> If I dir(number) I can see qsession as an attribute, which is
> puzzling. I'm really bad at this stuff, so I'll put all the relevant
> code below. Any help appreciated.
>
> Here are the models:
>
> class QuestionnaireSession(models.Model):
>     user = models.ForeignKey(User,blank=True,null=True)
>     name = models.CharField(max_length=100,blank=True,null=True)
>
> class Number(models.Model):
>     qsession = models.ForeignKey(QuestionnaireSession)
>     name = models.CharField(max_length=100)
>     supertype = models.ForeignKey('self',blank=True,null=True)
>
> And the formset:
>
> NumberFormSet = modelformset_factory(Number, exclude=('qsession',))
>
> And the relevant views.py code:
>
> def get_qsession(request):
>     if 'qsession' not in request.session:
>         qsession = QuestionnaireSession()
>         qsession.save()
>         request.session['qsession'] = qsession
>     else:
>         qsession = request.session['qsession']
>     return qsession
>
> def number(request):
>     qsession = get_qsession(request)
>     queryset = Number.objects.filter(qsession=qsession)
>     if request.method == 'POST': # form was submitted
>         formset = NumberFormSet(request.POST, queryset=queryset)
>         if formset.is_valid():
>             numbers = formset.save(commit=False)
>             for number in numbers:
>                 number.qsession = request.qsession
>                 number.save()
>             return HttpResponseRedirect('/top/')
>     else:
>         formset = NumberFormSet(queryset=queryset)
>     return render_to_response('questionnaire/questionnaire.html',
>                               {'numberformset': formset},
>
> context_instance=RequestContext(request))
>
> Thank you

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



modelformset partial save and AttributeErrors

2011-09-28 Thread Michael Wayne Goodman
Hi, I'm getting the following error when I try to assign a value to a
model attribute in a modelformset:

AttributeError at /number/
'WSGIRequest' object has no attribute 'qsession'

which occurs in the following snippet:

numbers = formset.save(commit=False)
for number in numbers:
number.qsession = request.qsession
number.save()

If I dir(number) I can see qsession as an attribute, which is
puzzling. I'm really bad at this stuff, so I'll put all the relevant
code below. Any help appreciated.

Here are the models:

class QuestionnaireSession(models.Model):
user = models.ForeignKey(User,blank=True,null=True)
name = models.CharField(max_length=100,blank=True,null=True)

class Number(models.Model):
qsession = models.ForeignKey(QuestionnaireSession)
name = models.CharField(max_length=100)
supertype = models.ForeignKey('self',blank=True,null=True)

And the formset:

NumberFormSet = modelformset_factory(Number, exclude=('qsession',))

And the relevant views.py code:

def get_qsession(request):
if 'qsession' not in request.session:
qsession = QuestionnaireSession()
qsession.save()
request.session['qsession'] = qsession
else:
qsession = request.session['qsession']
return qsession

def number(request):
qsession = get_qsession(request)
queryset = Number.objects.filter(qsession=qsession)
if request.method == 'POST': # form was submitted
formset = NumberFormSet(request.POST, queryset=queryset)
if formset.is_valid():
numbers = formset.save(commit=False)
for number in numbers:
number.qsession = request.qsession
number.save()
return HttpResponseRedirect('/top/')
else:
formset = NumberFormSet(queryset=queryset)
return render_to_response('questionnaire/questionnaire.html',
  {'numberformset': formset},
 
context_instance=RequestContext(request))

Thank you

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



Re: Dynamic Forms with Varying init Arguments

2011-08-19 Thread wayne
On Aug 19, 1:58 pm, SixDegrees <paulcarli...@comcast.net> wrote:
> I'm no longer at the computer where my code resides. But "you are wanting to
> call formset_factory
> and have it pass along a parameter to the Form that the formset
> contains" is pretty much what I want to know how to do.

Well, the short answer is that you can't do that--formset_factory()
does not accept kwargs.

Your other option is to basically write your own formset_factory().
If you look at the source, you will see that it really doesn't do
anything special--it's more of a convenience method that creates a
basic FormSet.  You could also write your own Formset, with its own
custom __init__ method, inherit from BaseFormSet, and pass that to the
formset_factory() method.  Yeah, that's probably what I would do.

A good rule of thumb that I have found is that if you are trying to do
something with Django, and it is either not possible or requires a
good bit of hackery, then you are probably (although not always)
"doing it wrong".  Most of Django is very flexible, but sometimes you
just need to know where to look for the answer.  That's why I was
inquiring about exactly what your code is doing and such--your use of
a primary key makes me think (but doesn't guarantee) that you are
using a form to represent an instance of a model, and if so, you want
to be looking there.

Wayne

-- 
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: Dynamic Forms with Varying init Arguments

2011-08-19 Thread wayne
On Aug 19, 12:41 pm, SixDegrees <paulcarli...@comcast.net> wrote:
> The parameter in question is a primary key that is used to generate a series
> of fields within the form. It is passed to the form __init__ routine, and
> can vary from one form to another. So, given a formset, I want to tell the
> formset "This is the parameter you should use when creating the next form
> you create."

I think it might help if you could post a code snippet showing how you
are creating the formset (not the __init__, but where you call the
formset creation method) and the formset creation method itself (or
just its name if you are using formset_factory or something else from
Django).

If I understand you correctly, you are wanting to call formset_factory
and have it pass along a parameter to the Form that the formset
contains.  However, you talk about the parameter being a primary key,
which would indicate to me that you are dealing with existing objects
from models, in which case we should be talking about a ModelFormset.

Wayne

-- 
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: Dynamic Forms with Varying init Arguments

2011-08-19 Thread wayne
On Aug 19, 10:44 am, SixDegrees <paulcarli...@comcast.net> wrote:
> I'm using formsets to implement a dynamic form as 
> describedhttp://www.mancoosi.org/~abate/dynamic-forms-with-djangohere . 
> However, the
> forms created by the formset want a parameter passed that determines the
> contents of the form during initialization.

What parameter is that?  You should be able to accomplish what you
describe without any Javascript, just like the code does at the link
you provide.

Wayne

-- 
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: Form label is same as first RadioSelect item

2011-08-15 Thread wayne
On Aug 15, 7:56 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> I found your post confusing; I think you have used the word "form" in
> several places where you really mean "field".

Sorry, I can see the confusion.  You are correct, I am referring to a
field.  In this particular case, the entire form was made up of one
field, and I made the mistake when writing the post, mixing up the
two.

> Yes, the rendering of a form
> field with choices as a radio input, by default, sets the overall label for
> the field to be "for" the first choice in the list.

This is what I would like to be able to set dynamically.  I know I can
pass the auto_id or the prefix, but those seem to affect the label and
all the  options.

>
> >  This breaks
> > accessibility for us (viewable at wave.webaim.org), and html
> > validation (at validator.w3.org).
>
> Breaks accessibility how? Clicking on the overall field label is the same as
> clicking on the label for the first choice...is that breaking accessibility?
> I can see how that behavior might be non-obvious but I don't see that it is
> "broken".
>
> What HTML validation errors are you getting, and what HTML doctype are you
> using? In a brief test of HTML from a page that uses a Django radio select
> field rendered in this way I am not getting any validation errors from
> validator.w3.org.
>

The doctype is XHTML Transitional, and the validation error I am
getting on each of the options for the field is: "document type does
not allow element "ul" here; missing one of "object", "applet", "map",
"iframe", "button", "ins", "del" start-tag"

That error might have something to do with what I am doing, although
it appears to be entirely contained in the outputted code from
form.as_ul.  The more pressing and pertinent question (for me) is the
accessibility error from wave.webaim.org:

"ERROR: Multiple form labels.  A form element has two labels
associated with it."

> You haven't said what you would like to see instead. If you want no label at
> all for the overall field you can pass an empty string as label on the form
> field definition. If you do want the text of the label, but you don't want
> it to be wrapped in the html label tag, then maybe you want a custom
> RadioFieldRenderer. This is possible but not currently documented, ticket
> #15244 has a patch with some how-to doc that you may find useful.

What I would like the ability to set the field label to a value of my
choosing, as that is what allows the validator at webaim to "pass" my
html.  If this is not something that seems to affect anyone else, it
might be the best for me to write a custom renderer.  I appreciate the
response and the pointer to the ticket with some info, as I was poking
around this morning trying to see what piece of code (field, widget,
etc.?) to do on my own in order to enable this functionality.  I still
would appreciate it if you could try the validator at webaim and see
if you can replicate the error I see there (multiple lables for an
input; the default as you describe it), as I am most interested in
learning if this is a real problem, and I trust the community to
educate me ;)

Thanks,

Wayne

-- 
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: Successfully Running Command Line Application from Django

2011-08-15 Thread wayne
On Aug 15, 2:40 pm, octopusgrabbus  wrote:
> I get a file permissions error, and this is running on Apache.
>
> It's dying on the retrbinary line. However, it's logging in using
> valid user names and passwords, so I'm confused as to why it's dying.

Yes, but it looks as though you are passing a callback command to your
ftp retrbinary() method that saves the file on your local filesystem
(as expected).  I would bet that your django instance does not have
permission to write to the directory that your server is trying to
save the file to.  If the command line program is working outside of
django, then the ftp setup is fine.  Test by setting the permissions
of the directory you are saving to to something like 777.  If it
works, that is your problem.

-- 
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: Successfully Running Command Line Application from Django

2011-08-15 Thread wayne
What error exactly do you get?  Do you encounter this error while
using runserver, or is it live on a web server (Apache et al)?

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



Form label is same as first RadioSelect item

2011-08-15 Thread wayne
I have noticed that when I use one of the "shortcut" template
rendering calls (eg, as_ul) that the resulting form gets a label that
is the same as the first item in a selection list--in this case, a
RadioSelect.  For example, I get something akin to the following:


Membership
level: 
 Benefactor
Membership - $5000 / year10% off
all classes3 Free Indian Taco Meals1 Free House
RentalFree Parking Space During OU Football Games

Note that the form itself has the same identifier (id_1_MembershipForm-
membership_level_0) as the first RadioSelect option.  This breaks
accessibility for us (viewable at wave.webaim.org), and html
validation (at validator.w3.org).  I am well aware that I can take
care of this by writing my own html in the template, and that as_p,
as_ul, and as_table are really just for simple forms and/or
prototyping.  However, what I'm wondering is if there is a
"better" (read: solution that doesn't require me writing the html)
solution or a specific class/method to override that will correct this
behavior.  Or am I missing something else about this entirely?

Thanks,

Wayne

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



multi-page, non-sequential, dynamic forms with serialization/deserialization

2011-06-14 Thread Michael Wayne Goodman
Hi all,

I looked into Django for a specific task, but before I get too deep I
want to make sure it is possible. We already have a site that does
what we need (http://depts.washington.edu/uwcl/matrix/customize/
matrix.cgi), but it is written entirely in custom, proprietary code,
and it is getting difficult to maintain.

We need the following features:
  * large, multi-page form (too many fields to fit on one page)
  * dynamic forms (ability to add more fields on demand)
  * non-sequential entry (users can jump back and forth filling it in)
  * serialization (the serialized output is sent to our existing
backend, or the user can download it)
  * deserialization (the user can upload a file that fills in field
values)

We don't currently use a database backend, as longterm storage of
entered data is not a high priority. It mostly takes the form input,
produces output, and is done.

It seems Form Wizards allow multi-page forms, but are geared towards
sequential entry (fill out page 1, submit, fill out page 2, etc). Is
it possible to jump from one subpage to another, allowing data from
each page to affect other pages? I also found some tutorials on
serialization, but I didn't see much on deserializing a file back to
form field values. Is this possible?

Thanks for any help!

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



Pages not showing up in Django admin

2011-05-22 Thread Wayne


Hi,

I'm running into an issue (I think) with the SVN development version of 
Django. I followed  
these<http://docs.djangoproject.com/en/dev/topics/install/#installing-development-version>
 instructions 
to install the Django development version, running Ubuntu 10.10, Apache 
2.2.16, and libapache2-mod-wsgi 3.2-2 (as output by dpkg -l | grep wsgi).

As I'm going through the tutorial, everything worked fine until I reached 
the admin page in part 2. Initially, testing using

python manage.py runserver

would show the styles, while testing using Apache would not. I resolved that 
by adding:

Alias /static/admin/ 
/home/wayne/programming/build/django-trunk/django/contrib/admin/media/

To my apache conf. However, when I logged into the admin interface after 
registering polls, all I saw were: [image: 
http://docs.djangoproject.com/en/dev/_images/admin02t.png]<http://docs.djangoproject.com/en/dev/_images/admin02t.png>
.

After reloading the page a few times, the Polls page showed up. However, 
when I clicked on it I was presented with a 404 error. After going back in 
and reloading a few times, it finally worked. I went on to adding the 
Choices part, and during this time the Polls and Choices would only 
intermittently appear in the Admin list. And randomly when I would do an 
action, I would be met with something of this nature:

Page not found (404)
Request Method: GET 
Request URL:http://localhost/admin/polls/choice/add/
Using the URLconf defined in waynesdomain.urls, Django tried these URL 
patterns, in this order:
^admin/ ^$ [name='index']
^admin/ ^logout/$ [name='logout']
^admin/ ^password_change/$ [name='password_change']
^admin/ ^password_change/done/$ [name='password_change_done']
^admin/ ^jsi18n/$ [name='jsi18n']
^admin/ ^r/(?P\d+)/(?P.+)/$
^admin/ ^(?P\w+)/$ [name='app_list']
^admin/ ^auth/user/
^admin/ ^sites/site/
^admin/ ^auth/group/
^admin/ ^polls/poll/
The current URL, admin/polls/choice/add/, didn't match any of these.
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.

This type of error is intermittent - Sometimes I can add choices perfectly 
fine, other times it won't let me add anything, at least when using Apache. 
If I use the Django testing server, I haven't had a single problem.

I'm not sure if this is an issue with my paths, but I don't think it's an 
Apache or mod_wsgi error, as using the version of Django in the Ubuntu 
repositories worked just fine.

The only real clue I have is that the errors seem to coincide with this 
message in /var/log/apache2/error.log:

[Sat May 21 19:53:52 2011] [error] Exception 
KeyError?<http://code.djangoproject.com/wiki/KeyError>
: KeyError? <http://code.djangoproject.com/wiki/KeyError>(-1216001392,) in 
 ignored

Any clues?

-- 
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 format a datetime in a webpage?

2011-01-29 Thread Wayne Young
Thank you very much! I misunderstood the meaning of "date" and "the time of
day"...

On Fri, Jan 28, 2011 at 8:53 PM, Jirka Vejrazka wrote:

> > {{record.ComplaintTime|time:"Y-m-d
> > H:i"}}
>
> From the documentation:
>
> "The time filter will only accept parameters in the format string that
> relate to the time of day, not the date (for obvious reasons). If you
> need to format a date, use the date filter."
>
>  So, you need to use:
>{{record.ComplaintTime|date:"Y-m-d
> H:i"}}
>
>  instead of:
> {{record.ComplaintTime|time:"Y-m-d
> H:i"}}
>
>   Cheers
>
>Jirka
>
> --
> 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.



How to format a datetime in a webpage?

2011-01-28 Thread Wayne Young
Hi all,

I have come across an error when I tried to format a datetime in a webpage.
This the part of webpage:

{% for record in records.object_list %}
  
{{record.ComplaintPhone}}
{{record.CustomerName}}
{{record.ComplaintTime|time:"Y-m-d
H:i"}}
{{record.ComplaintService}}
{{record.ComplaintDetail}}
{{record.CustomerArea}}
{{record.IsSolved}}
{{record.SolveTime|time:"Y-m-d H:i"}}
{{record.SolveMethod}}
{{record.Username}}
{{record.Remark}}
{{record.Intime|time:"Y-m-d
H:i"}}
   
{% endfor %}

The "records" here  is a QuerySet came from view:

 records = Report.objects.order_by('-Intime').all()



I tested in shell:

>>>record = Report.objects.get(pk=1)
>>>record.ComplaintTime.strftime('%Y-%m-%d %H:%M')
'2011-01-28 15:29'

It showed correctly. Also the attribution of "SolveTime" and "Intime". But
when I used "record.ComplaintTime.strftime('%Y-%m-%d %H:%M')" in webpage, it
said "Could not parse". So I changed to use "time" filter as above. But now
it shows nothing in those three time fields. I do not know why. Would
someone pleased to tell where I am wrong?

-- 
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 move inline into or above fieldsets in django admin?

2010-12-14 Thread wayne


On Dec 12, 1:30 am, mongoose <darrenma1...@gmail.com> wrote:
> mind giving a short example?
> From what I see in the template
>
> {% for fieldset in adminform %}
>   {% include "admin/includes/fieldset.html" %}
> {% endfor %}
>
> {% for inline_admin_formset in inline_admin_formsets %}
>     {% include inline_admin_formset.opts.template %}
> {% endfor %}
>
> I can either have it appear before or after the fieldsets. Not in
> between.

Sorry I haven't gotten back to you.  I simply haven't had much time
lately; work and finals.

I am still not entirely sure what you want, but you can move that code
around in your overridden template to get what you want.

For example, if I understand you correctly, something like:

 {% for fieldset in adminform %}
   {% include "admin/includes/fieldset.html" %}
   {% if fieldset_I_want_for_inlines %}
   {% include fieldset inline %}
   {% endif %}
 {% endfor %}

 {% for inline_admin_formset in inline_admin_formsets %}
     {% include inline_admin_formset.opts.template %}
 {% endfor %}

HTH,

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 move inline into or above fieldsets in django admin?

2010-12-11 Thread Wayne Smith
Well, the template is what controls the ordering of fields.  You can create
your own template that Django will then use in the admin interface.  From
there you can control exactly how things are displayed.
On Dec 11, 2010 1:30 PM, "mongoose" <darrenma1...@gmail.com> wrote:
> Hi wayne,
>
> to be honest I've no idea how i'd do that by overriding a template.
>
> On Dec 11, 7:20 pm, wayne <wayne.tuxro...@gmail.com> wrote:
>> On Dec 11, 8:05 am, mongoose <darrenma1...@gmail.com> wrote:
>>
>>
>>
>> > Hi there,
>>
>> > Currently I've got a recipe application like this:
>>
>> > class RecipeAdmin(admin.ModelAdmin):
>> > fieldsets = (
>> > ('Recipe Details',{
>> > 'fields': (
>> > ('title', 'slug'),'description',
'difficulty', 'vegetarian',
>> > 'serves', ('prep_time', 'cooking_time'), 'categories','tags'
>> > )
>> > }),
>> > ('Cooking Instructions', {'fields': ['instructions']}),
>> > )
>> > inlines = [IngredientInline, PhotoInline]
>>
>> > The problem here is that the Ingredients are being listed after the
>> > Cooking Instruction which doesn't really fit. The best would be to
>> > have something like this:
>>
>> > class RecipeAdmin(admin.ModelAdmin):
>> > fieldsets = (
>> > ('Recipe Details',{
>> > 'fields': (
>> > ('title', 'slug'),'description',
'difficulty', 'vegetarian',
>> > 'serves', ('prep_time', 'cooking_time'), 'categories','tags'
>> > )
>> > }),
>>
>> > inlines = [IngredientInline, PhotoInline]
>>
>> > ('Cooking Instructions', {'fields': ['instructions']}),
>> > )
>>
>> > Thanks a lot!
>>
>> I'm not sure if there is an admin setting that will allow you to
>> specify this ordering.  Either way, you can always override the admin
>> template for this particular class.
>>
>> Read about it here:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-ad...
>>
>> Wayne
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: Rendering a field value in a custom way

2010-12-11 Thread wayne
On Dec 11, 5:49 am, Scoox <stephan.f.mul...@gmail.com> wrote:
> Okay, I *think* I figured out a way to fix this.
>
> I can add methods such as get_stars to the relevant model.
>
> Then in that method I can do whatever I like with the string (e.g.
> convert it to star symbols).
>
> Would that be the recommended way to do this?
>
> Kind Regards
> Stephan

The "recommended" way would be to use a custom template tag (filter),
which you said you did not wish to do.

If I understand what you want (and I'm not sure that I do), then you
_should_ use a custom filter.  It really is not much different--it's
simply a Python function that returns rendered content.  You can pass
strings or objects as the args.  It would be better in the long run,
because:

1.  There is probably less overhead--you are rendering and doing some
logic inside the same function call, not separate ones.
2.  You can have more specific control over the rendering.
3.  You only have to write one method.  You can put the logic inside
of it that determines what field/object sent it.  If you go the model
method route, you will have to write the same basic logic for each
model.  It's just more code to write/upkeep.

That said, you can use the model method plan, and do the same thing.
I did it before when starting out, but now try to keep model methods
strictly those which modify the model, and rendering/display methods
in filters, since that is where the rendering happens.

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 Form ChoiceField, initial not working

2010-12-11 Thread wayne

On Dec 11, 5:08 am, Sævar Öfjörð <saeva...@gmail.com> wrote:
> I think you should provide your choices in the form field, not when
> creating an instance of the form.

Agreed.  To create a dynamic form such as this, the best way would
probably be to use a custom __init__ function.  In your view, when you
create your form, you can pass in a 'queryset=' argument that will do
this for you.

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 move inline into or above fieldsets in django admin?

2010-12-11 Thread wayne


On Dec 11, 8:05 am, mongoose <darrenma1...@gmail.com> wrote:
> Hi there,
>
> Currently I've got a recipe application like this:
>
> class RecipeAdmin(admin.ModelAdmin):
>         fieldsets = (
>                 ('Recipe Details',{
>                         'fields': (
>                                 ('title', 'slug'),'description', 
> 'difficulty', 'vegetarian',
> 'serves', ('prep_time', 'cooking_time'), 'categories','tags'
>                                 )
>                         }),
>                 ('Cooking Instructions', {'fields': ['instructions']}),
>                 )
>         inlines = [IngredientInline, PhotoInline]
>
> The problem here is that the Ingredients are being listed after the
> Cooking Instruction which doesn't really fit. The best would be to
> have something like this:
>
> class RecipeAdmin(admin.ModelAdmin):
>         fieldsets = (
>                 ('Recipe Details',{
>                         'fields': (
>                                 ('title', 'slug'),'description', 
> 'difficulty', 'vegetarian',
> 'serves', ('prep_time', 'cooking_time'), 'categories','tags'
>                                 )
>                         }),
>
>         inlines = [IngredientInline, PhotoInline]
>
>                 ('Cooking Instructions', {'fields': ['instructions']}),
>                 )
>
> Thanks a lot!

I'm not sure if there is an admin setting that will allow you to
specify this ordering.  Either way, you can always override the admin
template for this particular class.

Read about it here:  
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: can't add via admin, get django template error

2010-12-08 Thread Wayne Smith
On Wed, Dec 8, 2010 at 10:49 AM, JeffH  wrote:

> So I'm working along, everything's humming fine. Then I try to add a
> record via the admin, and get the following:
>
> TemplateSyntaxError at /admin/expert/expertresponse/add/
> Caught AttributeError while rendering: 'unicode' object has no
> attribute 'date'
>
> [snip]
>
> Template error
>
> In template c:\python26\lib\site-packages\django\contrib\admin
> \templates\admin\includes\fieldset.html, error at line 12
> Caught AttributeError while rendering: 'unicode' object has no
> attribute 'date'
> 2   {% if fieldset.name %}{{ fieldset.name }}{% endif %}
> 3   {% if fieldset.description %} class="description">{{ fieldset.description|safe }}{% endif %}
> 4   {% for line in fieldset %}
> 5   
> 6   {{ line.errors }}
> 7   {% for field in line %}
> 8    endif %}>
> 9   {% if field.is_checkbox %}
> 10  {{ field.field }}{{ field.label_tag }}
> 11  {% else %}
> 12  {{ field.label_tag }}{{ field.field }}
>
> I can add records via a ModelForm without problem, it just doesn't
> work in the admin.
>
> As you probably surmised from the error, the admin is expecting a field
attribute of type date on your  model object (line?).  Anyway, what is
getting passed is an Unicode object, which obviously does not have the
attribute (field) it is looking for.

I would guess that the problem lies somewhere in your admin file
(admin.py).  What are the contents of it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: When to use Form API

2010-12-08 Thread Wayne Smith
It is important to distinguish between display and functionality with
forms.  What I mean is, using the forms does not mean you have to render
(display) them the way Django has it set up by default.  I always use the
Form API, and if I need custom validation on a field or the entire form, I
override the appropriate clean method.  I pass the widget argument if I want
a different widget.

IMO, one of the best things about Django is the ease in which I can
customize its parts but still leverage its functionality.

On Wed, Dec 8, 2010 at 10:36 AM, christian.posta
wrote:

> Do django developers use the Form API any time form elements need to
> be displayed to users? Or do you just code the form yourself in the
> templates and manually process them for smaller forms?
>
> In general, is it always better to use the Form API for any form you
> display, regardless how simple, because of the built-in functionality
> provided by django, or is it overkill?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: sum() of Model field or DB field

2010-12-07 Thread Wayne Smith
You want to use an aggregation function:
http://docs.djangoproject.com/en/dev/ref/models/querysets/#aggregation-functions

On Tue, Dec 7, 2010 at 11:14 AM, Jagdeep Singh Malhi <
singh.malh...@gmail.com> wrote:

> hi
>
> I want to use mysql Query :
>   Select sum(field_name) FROM table_name  WHERE some condition.
>
> Is it possible without using raw queries in Django ?
> if yes, please help.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: General question about NOT EXISTS...

2010-12-07 Thread Wayne Smith
>
> How does that look when you are building an object list in the Q( )...
> style format? Where I am hung up is finding syntax examples of how to
> do the functional equivalent of a sql where not exists clause.
>
> Is there a way to do this without using .extra() and using just normal
> django?
>
>
Look here:
http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects

Basically, you specify the keywords just as you would in regular field
lookups, and you can use &, |, and ~ to AND, OR, or COMPLEMENT (negate) your
results.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: admin view

2010-12-07 Thread Wayne Smith
To fire off an action (method) after an object is saved, you want to listen
for its signal.

Check out http://docs.djangoproject.com/en/dev/topics/signals/

On Mon, Dec 6, 2010 at 11:28 PM, commonzenpython
wrote:

> hey guys, im trying to get a script to  run, like a view after a user
> in the admin interface checks a box and saves the object, is there any
> way of accomplishing this without having to rewrite the add_view, and
> edit_view ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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 save data in the model in the second step of a 2-step form?

2010-12-06 Thread Wayne Smith
>
> Thanks, that's fine, but I was wondering if there was a more scalable
> way. I have more fields than just "description", so it would be nice
> if they could be all saved with one method call, so I don't have to
> maintain this code in case I change the model.
>
>
If you have multiple fields describing your image, and you are concerned
that more fields will be added/removed at a later time and don't want to
fiddle with your Image model fields, then it would probably be prudent to
factor out these fields to their own model, and hold a relationship (1-to-1,
probably) from the image model to the description model.


> > By the way, your overridden save() method looks a bit odd.  It needs to
> call
> > save() on its superclass as well.
>
> But I do:
> models.Model.save(self)
>
> Isn't that what you meant?
>

You're correct in that you call the superclass, I looked over it too
quickly.  However, the way you are doing it won't pass any of the args or
kwargs up to the superclass, and will probably give you problems.  Look here
http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-model-methodsto
get an example.


> And how do I get that information provided by the user?
> Something like:
> Image i = ImageUploadDetailsForm.save(commit=False)
> ?
>

You get the info from the user by accessing the values in request.POST,
which is a dictionary-like object with all the POST parameters.  If you are
using a ModelForm, you might be able to get some things "automagically", but
you can always access them in request.POST no matter how the form is set
up.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 auth for existing cgi

2010-12-06 Thread Wayne Smith
On Mon, Dec 6, 2010 at 4:42 PM, bc  wrote:

> Is there any simple way to use django authentication/authorization to
> control access to an existing (not django) cgi?
>
> I could use subprocess.Popen to invoke the cgi after checking
> authorization, but the environment needs to be set up to look like a
> cgi call (setting QUERY_STRING, etc.). Is there a better way?
>
>
I don't know if you could do some special trick with an HttpRequest or some
kind of redirect from one view to hit the cgi script with the automatically
created (HttpRequest) data.  I'm guessing the answer is no or more trouble
than it would be worth, but that's just a guess.

I would say you really have two options.

1.  Implement the script in Python, and bring it in under Django.

2.  Craft your own Http Request header with Python's libraries and point it
to the cgi script.


> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: doing validation in admin form

2010-12-06 Thread Wayne Smith
Then yes, in the clean() method of your Galeria form, you could check the
number of fotos present and then raise a ValidationError if it is too many,
along with a custom message for the user.

Is that what you wish to do?

On Mon, Dec 6, 2010 at 5:18 AM, Daniel Carvalho <idn...@gmail.com> wrote:

> On 12/06/2010 03:05 AM, Wayne Smith wrote:
> > It's hard to say, because I don't know what kind of "validation" or
> business
> > logic regarding it you are trying to accomplish/employ.
> >
>
>
> suppose I want a validation like this:
>
> the number of fotos in a galeria should be limited to a number, which
> depends on the user that created it (OR, depends on some values that are
> in the galeria object)
>
>
>
> > However, if you are wanting to ensure you validate a foto during a
> gallery
> > save, why not call an overridden fotos.save() from your custom
> > galeria.save()?
> >
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Beginner question on admin interface

2010-12-06 Thread Wayne Smith
>
> Okay, honestly I believe it will be easier to go from scratch. However
> I'd still like to ask, since the idea of having an almost-done admin
> interface is very neat.
>
>
>
As the other reply indicates, that is a very tall order for a beginner.  The
admin interface is functional for editing, but not necessarily the
prettiest.  The beauty of the admin interface lies in the heavy lifting it
does for you, and the fact that it is easily extendable--you can override
any of its templates to provide extra functionality and/or your own look and
feel, without having to re-invent the wheel.

I would advise to use it and learn to tweak it.  Once you finish and look
back, I think you will find you are glad you did.


> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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 save data in the model in the second step of a 2-step form?

2010-12-06 Thread Wayne Smith
> After the second form is done and valid, I would like to save the
> information that comes to it to Image, in the same row that has the id
> I was passing.
>
> How can I do this?
>
>
>
image.description = information user provided
image.save()

By the way, your overridden save() method looks a bit odd.  It needs to call
save() on its superclass 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-us...@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-us...@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 redirect

2010-12-06 Thread Wayne Smith
On Mon, Dec 6, 2010 at 7:00 AM, Quetzacotl  wrote:

> Hello, i want to make function that wraps all things related to
> comments, so there should be part that gets comments from database and
> part that checks if comment was added. Then i can simply write just
> one line of code in view where i want comments. Problem is that after
> successful comment post, view should make redirect, and as we know to
> redirect you need to return response instance. That one thing doesnt
> let me make wrap function for my comments, because i cant return
> response after post. thought I can make IF statement that checks if
> return value is response instance or not. But this is 4 lines of code
> instead of one, is there any other way?
>
> --
>

I must be missing something; why can't you return a response after a post?

When I run into a problem that doesn't appear to be easily solved, I often
check to make sure that I am not trying to combine separate pieces of logic
that shouldn't be combined.  If you have 2 different things that need to
happen that cannot normally happen together, then maybe they shouldn't be
combined.  Generally speaking, Django discourages the implementation of
business logic in the template.

Just a thought...



> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: doing validation in admin form

2010-12-05 Thread Wayne Smith
It's hard to say, because I don't know what kind of "validation" or business
logic regarding it you are trying to accomplish/employ.

However, if you are wanting to ensure you validate a foto during a gallery
save, why not call an overridden fotos.save() from your custom
galeria.save()?

On Sun, Dec 5, 2010 at 1:25 PM, Daniel Carvalho  wrote:

> hi
>
> I have this models:
>
>
> models.py:
>
> class Galeria(models.Model):
>...
> class Foto(models.Model):
>...
>galeria = models.ForeignKey(Galeria, null=False)
>
>
> admin.py:
>
> class FotoInline(admin.StackedInline):
>model = Foto
> class GaleriaAdmin(admin.ModelAdmin):
>inlines = [FotoInline, VideoInline]
> admin.site.register(Galeria, GaleriaAdmin)
>
>
>
> When a galeria is saved in the django administration, I want to perform
> a validation that involves his fotos. ..
>
> They are edited at the same time because I use inline in the admin.
>
>
> But cannot do that in Galeria.save, nor GaleriaAdmin.save_model, nor in
> a postsave event from galeria, because at the time it is called the
> fotos have not been saved yet.
>
> Where should I do it the validation?
> Have to define a GaleriaForm and do something there?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Comments by guest and foreign key in model

2010-12-05 Thread Wayne Smith
You might want to use some logic involving anonymous users.  See here:
http://docs.djangoproject.com/en/dev/topics/auth/#anonymous-users

On Sun, Dec 5, 2010 at 2:29 PM, andy  wrote:

> Well you don't have to make the foreign key field required, that way
> comments belonging to guest users can have a blank foreign key
>
> Possibly you could also create a default guest user that is assign to
> comments made by guest users. I generally having my application
> depending on the creation of some default record so I would probably
> go for the first option.
>
> On Dec 5, 3:14 pm, robos85  wrote:
> > Hi,
> > I need to create comments system. Either guests and logged users can
> > comment. How can I do that?
> > I want to make a Foreign Key to User model but then, how to add gust's
> > comemnts? I could make it in 2 separate tables, but it would be nice
> > to have it in 1 table.
> >
> > Any ideas?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: I'm trying to get this code http://paste.pocoo.org/show/300846/ to print a newline *before* each heading, what's the best way to do this?

2010-12-05 Thread wayne
You can just add the html to your template (like ).

On Dec 5, 9:01 am, jc  wrote:
> I need this codehttp://paste.pocoo.org/show/300846/to print a
> newline *before* each  heading (essentially, wrapping it to the
> next line).
> Create another loop to do this or is there an easier way?
> Thanks,
> J.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 can I clean a form field before the clean method?

2010-12-04 Thread Wayne Smith
Sure.  Just override the clean method for the field, or the whole form if
you wish.  The built-in "default" validation done by Django doesn't handle
any logic; it just makes sure the format and type of each field is
appropriate.
On Dec 4, 2010 1:44 PM, "refreegrata"  wrote:
> ok, thanks for the answer. I have a final question. The other way is
> in the __init__ set initial values in hidden fields, but if the user
> (malicious) edit the value in some of this fields the form is invalid,
> and the form comeback, but with the values edited for the user and the
> error messages. Can I reset the initial values for the hidden fields
> before of return the form?
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-us...@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-us...@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 able to see models.DecimalField in template

2010-12-04 Thread Wayne Smith
You shouldn't need to.  How are you rendering your fields in your template?

On Dec 4, 2010 1:21 PM, "Patrick"  wrote:
> I have 2 fields in my model:
> listing.name and listing.amount
>
> listing.name shows up in the template but listing.amount does not. Do
> I have to convert it to unicode first?
>
> Thanks,
> Patrick
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-us...@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-us...@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: main categories in menu

2010-12-04 Thread wayne

> So if a user enters mydomain.com/main1/page1 --> check if main1 exists
> in the database --> render a menu of all pages which are linked to
> main1 --> show page1

So, I take it that if the user enters the above, and main1 does not
exist in the db, then you will raise an error (probably 404)?

If so, then like I mentioned, it should suffice to do something like:

r'^(?P\w+)/(?P\w+)$', 'view_to_pass_to'

to match against.  It will then call the view you specify, and pass
the kwargs main_obj and page_obj.  You can then look up these two
slugs in your db, check if they exist, find all page_objs that link to
main_obj, etc.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 can I clean a form field before the clean method?

2010-12-04 Thread wayne

> I want to do something like:
>
> .default = MyModel.objects.get(field=True)
>
> and raise an exception if don't find in the table a row with a field =
> True, but I don't have idea if something like this can be done.
>

I'm not always real good at understanding what someone wants.
However, it sounds as though you want to build a dynamic form (some
fields set dynamically, in response to certain conditions), but NOT
have the user mess with these things.  The ways you mention to keep
the fields out of the form are the normal ways, but if you are going
to build a dynamic form without doing it in the POST view, etc., you
would normally do it with a custom __init__ method for the form.  But
since the fields have been excluded, I think this would put you back
into the problem of marking form fields as hidden or something.

This kinda gets to be a circular problem primarily because the
function of a form is to accept user input, not hide it.  I'm sure you
can do it, but it really just becomes  a case (in my opinion) of
trying to pound a square peg into a round hole.

If I understand you correctly, my advice would be to validate the data
in clean(), and then to handle the object lookup in a pre_save()
signal catcher (in the model) and bail from there if the value isn't
found.

> Thanks for read and sorry for my newbies questions.

No apologies; we're all just talking and learning here ;)  I hope I've
been able to contribute to the overall conversation.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Named URLs and class-based generic views

2010-12-03 Thread wayne

> I think the only thing that's bugging me is that you have to include
> the whole views.py in your url conf.  Just feels less graceful than
> having the dispatcher nab what it needs on demand.  I'll get over it.
>

Yeah, it does feel less graceful, doesn't it?  That said, there might
be a way, I just don't know it.

I wouldn't see why you couldn't do it, just like before (specify the
string name)--I just didn't recall seeing that example in the docs for
class based views.  Then again, I'm just trying to get my boss to move
us over to 1.2, so I haven't really looked at trunk or projected 1.3
stuff yet (like the new views).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Named URLs and class-based generic views

2010-12-03 Thread wayne
On Dec 3, 2:47 pm, Andrew Willey  wrote:
> Forgot to in mention the actual question from the subject.
>
> Is there a "blessed" way to use class-based views with named urls in
> the
>
> > url(r'^location/$', view='WouldLoveToHaveClassBasedView.as_view', 
> > name='name_for_convenience')
>

Oh, I see ( I think ;) ).  I don't know, but I am guessing no.
However, you could decorate the view and use the decorator as some
sort of dispatcher, although I am not sure that would really give you
what you want.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Named URLs and class-based generic views

2010-12-03 Thread wayne


On Dec 3, 1:46 pm, Andrew Willey  wrote:
> Can someone point me in the right direction here?
>
> How does one use class-based generic views and named URLs?
>
> Example (doesn't work):
>
> > urls.py
> > urlpatterns += patterns('myapp.views',
> >    (r'^location/$', MyGenericView.as_view()),
> > )
> > views.py
> > class MyGenericView(TemplateView):
> >    template_name = 'example.html'
>
> Now, I can make that work if I did this instead in
>
> > urls.py
> > from myapp.views import *
> > urlpatterns += patterns('',
> >     (r'^location/$', MyGenericView.as_view()),
> > )
>
> That approach just feels weird, am I doing it wrong or is that the new
> normal?

No, that looks right to me.  You import the view in the second case,
which means you can pass it like an object, as you do.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 can I clean a form field before the clean method?

2010-12-03 Thread wayne
On Dec 3, 11:59 am, refreegrata  wrote:
> Ok, with hidden fields. But if the user manually, with some tool,
> change the value, thats will be a problem. For my safety I must to use
> the hidden fields and still keep the clean methods to overwrite any
> possible editing over the fields value. Originally the idea of this
> post was search a way to prevent the double assign(in the init and the
> clean methods), but apparently isn't possible.
>
> Thanks for the answer.

It isn't possible because you are, in actuality, asking two questions:

1.  How can I set the value of a field on the server w/o client
interaction, and
2.  Ensure that the client doesn't do something malicious

Number one is something that you should take care of in your view or
model (__init__, perhaps), and number 2 is a validation issue.

Since you said you didn't want to handle it in your POST processing,
which is the only way you can set it once and take care of both issues
(because you're doing it at the end of the chain), you will have to do
it twice, no matter what method/idea/framework you use.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 date by string

2010-12-03 Thread wayne


On Dec 3, 11:13 am, oscar widjaya  wrote:
> It's for mysql
> it still does not work. I tried it with the following sql statement
> "SELECT * FROM project_project WHERE start_date LIKE '%s'" % '2010%%'

Well, I assume that the double % at the end of your query is
unintentional, as I don't think it should be there, but I'm not an sql
guru.

I just know that when I was having to craft some custom sql a couple
of months ago (using Postgres) I had to toy with the formatting a bit
to get it working.  I also had to make sure I passed everything as a
str, and not unicode.

Maybe someone else how knows sql better will come along.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: models don't show in tamplate

2010-12-03 Thread wayne
Are you seeing anything?  I mean, is the rest of the template
rendering fine?

There are only two things that I notice:  the extra dict you pass with
the template_object_name (why not put it in info_dict?), and while I'm
not fluent in spanish, are you iterating through the variable
'object_list'?  That is the name of the list that will have your
queryset objects after the generic view is executed.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 date by string

2010-12-03 Thread wayne


On Dec 3, 10:47 am, owidjaya  wrote:
> It says incorrect date value.
>

What database are you using?  I'm wondering if this is an issue of
formatting the sql correctly.  Did you read the snippet near the
bottom of the page I linked to?  Try:

SELECT * FROM some_table WHERE some_date LIKE "%s" % '2010%'

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: main categories in menu

2010-12-03 Thread wayne
On Dec 3, 2:11 am, Rob  wrote:
> I want to make main categories on my site like:
> /main1/page1
> /main2/page2
> /main3/page3

It sounds like you have 3 views, and each one can pick from a pool of
categories.  If this is correct, all you need to do is enter a line
for each view (main#), and pass the category (page#) as a variable to
the view, which can then do the lookup.  You will use something like:

r'^main1/\w+/$'

which will pass all characters matching the regex (here, alphanumeric
chars) to the view you specify as a positional arg.  You can also pass
them as a kwarg.  Read here:  
http://docs.djangoproject.com/en/dev/topics/http/urls/

>
> Is there a way to do something like: (r'^(.*)/(.*)/$', view), (I know
> this doesn't work)

To do something like that, instead of wildcarding everything greedily,
just pass a range of characters and symbols you will not accept
(whitespace, etc.) by using [^don't_accept_these] in your regex.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: weird template escaping

2010-12-03 Thread wayne
Turn autoescape off (http://docs.djangoproject.com/en/dev/ref/
templates/builtins/?from=olddocs#autoescape) or mark it as safe by
using the "safe" template filter tag (lower on the page).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 date by string

2010-12-03 Thread wayne
You should be able to do it just as you mention, passing the query
string to cursor.execute().

See 
http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly

Have you tried this?  Are you getting an error?  If so, what is it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 can I clean a form field before the clean method?

2010-12-03 Thread wayne
Well, it depends on how sensitive and dynamic my_field needs to be.
You could always pre-populate the form with my_field set to a value,
and mark its input type as hidden (if it is not sensitive).

If you are working with a ModelForm, you could use one of the methods
here:  
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form.

Lastly, you could do it in the view during your processing of
request.POST, as you mention.  Doing it in one of the validation
methods like you mention _should_ work, but I usually like to keep my
clean methods validation-only (and not use them to manipulate data).

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Load ForeignKey label instead of ID in Charfield

2010-12-02 Thread wayne
Well, I'm guessing that what is displayed is what the unicode method
returns for the model that the ForeignKey points to (can't remember
for sure offhand, but I know that the admin interface works that
way).  Of course, it might also be changing the display because you're
putting it in a TextField instead of a ChoiceField.

The whole point of a ForeignKey is to store a relationship between two
objects from different models.  I really don't see how you would be
gaining anything by having users edit this data via a TextField.  If
you don't like the widget that a form uses by default to select the
other model instance, you can change that fairly easily.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Process UploadedFile with PIL on-the-fly

2010-12-02 Thread wayne
On Dec 2, 4:40 am, muzhig  wrote:
> Hi! I need to resize and make a stamp on uploaded images and only then
> save a model.
> I have a procedure, that processes incoming File:
>
> def processUploadedImage(file):
>         img = Image.open(file)
>         downsampleUploadedimage(img)
>         stampUploadedImage(img)
>         img.save(file, "JPEG")
>
> I tried to process UploadedFile directly from request.FILES, before
> constructing and validating form:
>
>         ...
>         processUploadedImage(request.FILES['file'])
>         form = ImageUpload(request.POST, request.FILES)
>         if form.is_valid():     #it always fails here, is_valid returns 
> False, if
> I process UploadedFile
>                 ...
>         else:
>                 redirect('/failed')
>         ...
>
> After it failed, I also tried to process it in my ImageUpload.save()
> method:
> class ImageUpload(forms.ModelForm):
>         class Meta:
>                 model = Image
>                 fields = ["title", "file"]
>
>         def save(self,user,commit=True,**params):
>                 image = forms.ModelForm.save(self,commit=False)#construct an
> instance from form fields
>                 processUploadedImage(image.file)
>
>                 ...another fields initialization, such as user, 
> publication_date and
> so on...
>
>                 #save into db(if commit is True) and return model instance
>                 return forms.models.save_instance(self, image,
> commit,construct=False)
> but it fails, when processUploadedImage tries to save image into file.
> It trows IOError "Bad file descriptor"..
>
> I know that I can process image after it saved into db, but I dont
> want server to do unnecessary work:
> read full sized file, copy it into storage, then again open file in
> starage, process it, save...
>
> I want beautyfull solution :)
> Upload -> Process ->Construct model -> Save

This, to me, is a perfect use case for a signal, most likely
pre_save.  I am still not sure if you wish to save the original or the
processed image in your model, but you can do either by moving any
processing code to a method that gets triggered right before Django
tries to save your model.  You don't need to override the save()
method of your model, but you could do it there, too, if you wish.

However, it looks like you are trying to do it by overriding the
save() method of your ModelForm, which I would not do in this case,
although you could make it work.  The data you are trying to
manipulate has nothing to do with the form itself, or other fields in
the form, and thus (I think) would be better to do in one of the other
places I mentioned above.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Records detected by admin site, but not displayed?

2010-12-02 Thread wayne
On Dec 2, 8:15 am, Sithembewena Lloyd Dube  wrote:
> Hi all,
>
> I have an admin site enabled for my Django project. For some reason, some
> records are no longer displayed (they were displayed just fine before).
>
> Tried restarting the dev server to no avail.
>
> Please see the attached screen dump? What could be causing this?

Have you made any recent changes?  Have you overridden any admin
templates?  Did you specify anything in a Blog Admin class?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Load ForeignKey label instead of ID in Charfield

2010-12-02 Thread wayne
On Dec 2, 10:03 am, bnabilos <bnabi...@gmail.com> wrote:
> Hello,
>
> I'm using a ForeignKey in my model and a Charfield in my form, when I
> save data everything works well but when I try to edit something, I
> get the ForeignKey ID in the Charfield.
>
> There is a way to display the label instead of the ID when editing an
> entry ?
>
> Thank you

So, let me get this straight--you have a ForeignKey from one model to
another, and you are editing that field by letting users enter text?
If so, why?  You should be using some type of choice field.

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Using locales 'en-au' 'en-ca' 'en-nz' and 'en-za' in Django

2010-11-13 Thread Wayne Merry
Hi,

Django has en and en-gb installed as languages in it's core. If a
django project wishes to use other locales such as 'en-au' or any of
the others listed in the subject line, how would one go about this
given that a language cannot be used unless it is in the core?

Essentially, how does one go about adding these languages to the core.
en-au and en-nz can essentially be a copy of en-gb.

Regards,
Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: 'unicode' object has no attribute '_committed'

2010-08-10 Thread wayne
What is the code that you are using to save instances of the model
with?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: 'unicode' object has no attribute '_committed'

2010-08-10 Thread wayne
> When i try and add a project  in the admin i get the error: 'unicode'
> object has no attribute '_committed' . I'm quite certain it's an issue
> with the image field.

Well, not to be coy, but you have a unicode string somewhere whose
_committed value you are trying to access.  Problem is, the unicode
string does not have this particular value/method.

That's what I'm guessing without seeing the code, anyway.

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Custom CheckboxSelectMultiple Widget that holds state

2010-08-10 Thread wayne
Well, IMO any way that works and you feel comfortable supporting is
"okay".  I can tell you what I did, but I don't know if it's any
better.

If I understand you correctly, you want to bring up the options a user
made previously and start from there instead of a blank slate.  What I
did to accomplish this was to make an ajax call to the server, and
look up whatever identifiable information I had (user, form, etc.).
If it was in the database, I returned a form built from the previous
instance.  If not, I returned a blank form.  It brings in some
javascript (which is obviously not a part of Django, but is a common
component of web apps), but it made things quite a bit more
straightforward, IMO.

You can differentiate between the different options/fields (if
necessary) by using some guaranteed unique identifier and building
your form by hand, which you already appear to be doing.

HTH,

Wayne

On Aug 10, 11:07 am, vcarney <vincecar...@gmail.com> wrote:
> I've got a form with a multi checkbox that contains static choices.
> Using the forms.MultipleChoiceField with the CheckboxSelectMultiple
> widget worked fine for display. However, when displaying an edit form,
> the checkboxes did not hold state (all items were unchecked). To
> handle this I created a custom widget based on CheckboxSelectMultiple
> with the following:
>
> class CustomCheckboxSelectMultiple(SelectMultiple):
>     def render(self, name, value, attrs=None, choices=()):
>         if value is None: value = []
>         has_id = attrs and 'id' in attrs
>         final_attrs = self.build_attrs(attrs, name=name)
>         output = [u'']
>         # Normalize to strings
>         if (isinstance(value, basestring)):
>             value = value.replace('{','')
>             value = value.replace('}','')
>             value = value.replace('"','')
>             value = value.split(',')
>         str_values = set([force_unicode(v) for v in value])
>         for i, (option_value, option_label) in
> enumerate(chain(self.choices, choices)):
>             # If an ID attribute was given, add a numeric index as a
> suffix,
>             # so that the checkboxes don't all have the same ID
> attribute.
>             if has_id:
>                 final_attrs = dict(final_attrs, id='%s_%s' %
> (attrs['id'], i))
>                 label_for = u' for="%s"' % final_attrs['id']
>             else:
>                 label_for = ''
>
>             cb = CheckboxInput(final_attrs, check_test=lambda value:
> value in str_values)
>             option_value = force_unicode(option_value)
>             rendered_cb = cb.render(name, option_value)
>             option_label =
> conditional_escape(force_unicode(option_label))
>             output.append(u'<label%s>%s %s' %
> (label_for, rendered_cb, option_label))
>         output.append(u'')
>         return mark_safe(u'\n'.join(output))
>
>     def id_for_label(self, id_):
>         # See the comment for RadioSelect.id_for_label()
>         if id_:
>             id_ += '_0'
>         return id_
>     id_for_label = classmethod(id_for_label)
>
> --
> My customizations are:
>
> if (isinstance(value, basestring)):
>             value = value.replace('{','')
>             value = value.replace('}','')
>             value = value.replace('"','')
>             value = value.split(',')
>
> --
> Is there a better way to do this in 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-us...@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: add button to admin change list at row level.

2010-05-04 Thread Wayne
Thanks for your hint. It worked out pretty well.

Wayne

On May 2, 4:06 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On May 2, 4:29 am, Wayne <wayneshen...@gmail.com> wrote:
>
> > Hi,
>
> > We are trying to customize Django admin change list displaying model
> > objects. We want to add two buttons (Change, delete) to each row of
> > the record, something very similar to "Add" and "Change" buttons on
> > application list beside the model name. Could somebody give us some
> > hint on this? The "list_display" can only take existing fields, but
> > not the extra buttons we want to add, right? We do not want to provide
> > user with batch admin actions option. That is why we want to add
> > action to each row.  Drop down actions menu is not our design
> > preference.
>
> > Thanks for your help.
>
> > Wayne
>
> The docs explain how you can use arbitrary ModelAdmin methods in
> list_display, which will do what you 
> want.http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#django.contri...
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-us...@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 change urls for model in admin?

2010-05-04 Thread Wayne
Hi,

I am looking for the answer as well. I came across this tutorial with
some sample code. 
http://lincolnloop.com/assets/Customizing_the_Django_Admin-EuroDjangoCon09.pdf
page 59.

However, I don't want to create new view, but just modify the display
urls. So if somebody could give any hint, that would be great.

Thanks,

Wayne

On May 4, 4:23 am, akonsu <ako...@gmail.com> wrote:
> hello,
>
> by default an admin url for a model looks like this:
>
> http:///admin///...
>
> is there a way to change it? for different models i need to have
> different url structure. say, i want to replace "/admin/ name>" with something else.
>
> ModelAdmin.get_urls()? the documentation is not very helpful for me. i
> do not understand how i can use get_urls(). in particular, i do not
> have any custom views in my admin. and the docs only explain how to
> use get_urls() to hook up views.
>
> thanks for any help
> konstantin
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-us...@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.



add button to admin change list at row level.

2010-05-01 Thread Wayne
Hi,

We are trying to customize Django admin change list displaying model
objects. We want to add two buttons (Change, delete) to each row of
the record, something very similar to "Add" and "Change" buttons on
application list beside the model name. Could somebody give us some
hint on this? The "list_display" can only take existing fields, but
not the extra buttons we want to add, right? We do not want to provide
user with batch admin actions option. That is why we want to add
action to each row.  Drop down actions menu is not our design
preference.

Thanks for your help.

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 Mako as a templating language

2010-03-30 Thread Wayne Koorts
Hi Colin,

>>> Or any other templating language that's a bit looser in allowing a bit
>>> of logic to mix in with the presentation layer?
>>
>> http://kid-templating.org/
>
> Hasn't kid been superseded by genshi?

Firstly I'll say that I hate answers which say "don't try to do what
you're doing" as much as the next person (really, I do) but...

My first experiences with the Django template system were I think
quite similar to yours in that initially felt that it was too simple
and restrictive.  However, as I started focusing more and more on
separation of concerns the templating became less and less of a
problem.

I eventually found that I was almost always better off (usually from a
maintenance perspective) doing the things I felt I wanted to do in the
templates further up the pipeline instead.

--
Regards,
Wayne
Blog: http://www.wkoorts.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-us...@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: charField null=false not enforced for table creation in oracle

2010-03-11 Thread Wayne
Hi Karen,

Many thanks for your reply.
Now our business requirements do not allow either empty string or null
value for this particular charField column (name =
models.CharField(max_length=512, null=False, blank=False)). How do you
suggest we should configure this field so that we can enforce not null
condition in the oracle database by using syncdb? Currently, after
creating those tables we need to manually modify the column properties
in Oracle to make them not null. Or Django Oracle backend deliberately
ignores null=false for charField creation?

Wayne

On Feb 26, 8:47 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Fri, Feb 26, 2010 at 5:35 PM, Wayne <wayneshen...@gmail.com> wrote:
> > Hi,
> > I try to create tables using Django models in our test oracle
> > database. I define a model with one column like this: name =
> > models.CharField(max_length=512, null=False, blank=False). After
> > running python manage.py syncdb, I found that column 'name' in the
> > generated table still allows null value in the column definition. I
> > understand that null = false is the default option. And I verified
> > that for other types of Django fields, null = false or no such option
> > at all would generate columns that do not allow null values in the
> > database. Is there particular reason why null = false is not enforced
> > for charField?
>
> Yes. Oracle does not distinguish between null and an empty string. So
> null=False applied at the database level would mean that you also could not
> store the empty string in that field, which would be quite different from
> what you would see running the same code on most other databases, where the
> empty string is a valid value for a NOT NULL character field.
>
> The behavior is documented, see the note 
> here:http://docs.djangoproject.com/en/dev/ref/models/fields/#null. The note is
> perhaps not as clear as it could be about when the empty string is allowed
> for a field. That's a property of the field type (for example, empty strings
> are allowed for CharField but not a DateField), and is not in any way tied
> to the value of the field's blank option. The blank option, as noted in its
> description, is used for validation and is not applied at the database
> level.
>
> Karen

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



Django GeoRSS syndication feed

2010-03-03 Thread Wayne Dyck
Has anyone created an example of how to incorporate a GeoRSS feed they
would be willing to share? I have seen this link, 
http://code.djangoproject.com/ticket/6547
and understand that "feed_extra_kwargs" and "item_extra_kwargs" were
added to allow this but I am drawing a blank on exactly how to
subclass the base class in order to add a lat and lon point.

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



charField null=false not enforced for table creation in oracle

2010-02-26 Thread Wayne
Hi,
I try to create tables using Django models in our test oracle
database. I define a model with one column like this: name =
models.CharField(max_length=512, null=False, blank=False). After
running python manage.py syncdb, I found that column 'name' in the
generated table still allows null value in the column definition. I
understand that null = false is the default option. And I verified
that for other types of Django fields, null = false or no such option
at all would generate columns that do not allow null values in the
database. Is there particular reason why null = false is not enforced
for charField?
My Django version is 1.1.1, Python version is 2.6, and oracle server
is 10g release 2.

Many thanks for your help.

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



LDAP Authentication and Single Sign on

2010-02-18 Thread Wayne
Hi,

I am about to develop an admin interface using Django framework for
several web applications . By design, those applications will be
decentralized, which means that they may use different databases and
reside on different servers and they will talk to each other via web
services. We have our LDAP server and we plan to use it for
authentication purpose. The authorization part for each application
will be handled locally by individual application. We want to
authenticate user only once for the access to multiple applications as
long as the log-in session does not expire.

What tools and packages Django can provide to realize our design? What
is the best strategy for the development?

Many thanks in advance for your help and time.

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: want to convert object to json data.

2010-02-08 Thread Wayne Koorts
> I want to convert a given regular object to json object. i.e. I want
> to create a function which takes the class object as parameter and it
> should return the json object.

Have a look at the built-in Django "serializers" module:

http://docs.djangoproject.com/en/dev/topics/serialization/#topics-serialization

Regards,
Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Date-based generic views - UTC handling

2010-02-07 Thread Wayne Dyck
I have a database model in which the datetime entry of an item is
stored as a DateTimeField(). This datetime is stored as UTC. In one of
my views, which displays details for each entry, I am converting and
formatting the UTC time to PST.

I just started using generic views and for
"django.views.generic.date_based.archive_month" there is the
"date_field" argument which indicates the name of the DateTimeField in
the QuerySet's model that the view should use.

Is there an easy way to format this date_field to my local time zone
i.e. PST? I have also tried using the "date" and "time" filters within
the template itself, however, those are still UTC.

Any pointers would be appreciated.

Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Flat file application for binary data?

2010-02-05 Thread Wayne Koorts
>> Anybody know of an suitable application for this?
>>
>
> FileFields and ImageFields are by default stored on disk, with just a pointer 
> stored in the db.  For more examples, take a look at David Larlet's 
> django-storages (http://code.welldev.org/django-storages/wiki/Home) and 
> Justin Driscoll's ImageKit 
> (http://bitbucket.org/jdriscoll/django-imagekit/wiki/Home), both of which 
> should give you at least a starting point.  With ImageKit, for example, you 
> create a "spec" for your image fields, and part of the spec is a means of 
> determining the filesystem storage location (including a method you can 
> define if you need to).
>
> ---Peter Herndon

Note that you can do storage like /yy/mm/dd natively in Django without addons.

-Wayne

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: manytomany relations

2010-01-29 Thread Wayne Koorts

What do you mean by "top ten"?

On 29/01/2010, at 20:53, CCC  wrote:


hi,
I have two  models:user,group,and they are manytomany,
class User(model.Model):
name = models.CharField(max_length=20)

class Group(models.Model):
name = models.CharField(max_length=20)
users = models.ManytoManyField(User)

now i want to get the  top ten users who have the groups
,thanks for advance!

--  
You received this message because you are subscribed to the Google  
Groups "Django users" group.

To post to this group, send email to django-us...@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-us...@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: LDAP-groups problem

2009-12-23 Thread Wayne
Hi,

Many thanks for your reply.

I did the test and it seemed that our network is working fine and I
could telnet to the directory with "Connected" feedback. What other
things we could try next?

Wayne



>
> Ralf: $ telnet ldap.example.com 636
> Trying 1.2.3.4...
> Connected to ldap.example.com.
> Escape character is '^]'.
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: LDAP-groups problem

2009-12-22 Thread Wayne
Thanks for the prompt reply. Yes, unique=True was the problem. Now I
passed the "run syncdb" and new tables were created. However, I still
could not "contact LDAP". Could somebody help me with this? There
could be many reasons so I want to start with loggings for Django-LDAP-
Groups.

Thanks!

My settings:

LDAP_SERVER = 'directory.X'

# If using SSL use these:
LDAP_PORT = 636
LDAP_URL = 'ldaps://:636'
SEARCH_DN = ''
SEARCH_FIELDS = ['sn','cn','uid']
BIND_USER = 'XX'
BIND_PASSWORD = 'X'
CERT_FILE = 'XX'

AUTHENTICATION_BACKENDS = (
 'ldap_groups.accounts.backends.eDirectoryGroupMembershipSSLBackend',
 'django.contrib.auth.backends.ModelBackend',
)

The traceback:
Environment:

Request Method: POST
Request URL: http://localhost:8080/admin/
Django Version: 1.1
Python Version: 2.6.2
Installed Applications:
['ldap_groups',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'DjangoTests.TestAdmin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
wrapper
  196. return self.admin_view(view, cacheable)(*args,
**kwargs)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
inner
  185. return self.login(request)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
  44. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
login
  300. user = authenticate(username=username,
password=password)
File "C:\Python26\lib\site-packages\django\contrib\auth\__init__.py"
in authenticate
  37. user = backend.authenticate(**credentials)
File "C:\Python26\lib\site-packages\ldap_groups\accounts\backends.py"
in authenticate
  161. l = self.bind_ldap(settings.BIND_USER,
settings.BIND_PASSWORD)
File "C:\Python26\lib\site-packages\ldap_groups\accounts\backends.py"
in bind_ldap
  154. l.simple_bind_s(username, password)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py" in
simple_bind_s
  206. msgid = self.simple_bind(who,cred,serverctrls,clientctrls)
File "C:\Python26\lib\site-packages\ldap\ldapobject.py" in simple_bind
  200. return self._ldap_call
(self._l.simple_bind,who,cred,EncodeControlTuples
(serverctrls),EncodeControlTuples(clientctrls))
File "C:\Python26\lib\site-packages\ldap\ldapobject.py" in _ldap_call
  96. result = func(*args,**kwargs)

Exception Type: SERVER_DOWN at /admin/
Exception Value: {'desc': "Can't contact LDAP server"}

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Book

2009-12-22 Thread Wayne Koorts
> I'm new in django and i'm searching a book :
> django 1.0 web site development PDF
>
> can u help me please !
> in http://my.softarchive.net/search/?q=django=0=0    I could not
> download it.
>
> Is there another way ?

Absolutely:

http://www.packtpub.com/django-1-0-website-development-2nd-edition

It's a great book and deserves to not be pirated.

Regards,
Wayne

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: LDAP-groups problem

2009-12-18 Thread Wayne
Hi,

Sorry for the late reply. Here is more info.

Django Verstion: 1.1
Oracle Version:Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit
Production
cx_oracle for Python 2.6.

Thanks for the help.

Wayne

On Dec 18, 10:26 am, Peter Herndon <tphern...@gmail.com> wrote:
> On Dec 18, 2009, at 10:15 AM, Peter Herndon wrote:
>
>
>
> > On Dec 17, 2009, at 7:32 PM, Wayne wrote:
>
> >> Hi,
>
> > This error arises from an inconsistency between the behavior of Oracle and 
> > the behavior of PostgreSQL, as Mike noted.  It works under Postgres.  I'll 
> > check with the dev list and see if this behavior difference is known, and 
> > whether the fix is to never use unique=True on a TextField (a bug in my 
> > code), or something that needs to be smoothed over in the SQL generation 
> > for Oracle specifically (a bug in the underlying Django behavior).
>
> Hi Wayne,
>
> Can you tell me the Django version, the version of cx_Oracle, and the Oracle 
> version?  If this has been fixed for certain versions, that would make this 
> error a moot point.  And the developers are certainly going to ask.  :)
>
> Thanks,
>
> ---Peter

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




LDAP-groups problem

2009-12-17 Thread Wayne
Hi,

I tried to use djando-ldap-groups but got some errors from database
configuration. Could somebody shed some light on the possible problems
of my set up?

Thanks,

Our LDAP server is Sun One Server and the site is running in the
windows environment.

The settings.py file:
LDAP_SERVER = 'directory.XXX.xx'

# If using SSL use these:
LDAP_PORT = 636
LDAP_URL = 'ldaps://xxx.xxx:636'
SEARCH_DN = 'ou=people,dc=x,dc=x'
SEARCH_FIELDS = ['sn','cn','uid']
BIND_USER = ''
sBIND_PASSWORD = 'xx'


AUTHENTICATION_BACKENDS = (
 'django.contrib.auth.backends.ModelBackend',
) .

The error message came from command: python manage.py syncdb
Creating table ldap_groups_ldapgroup
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
362, in execute_manager
utility.execute()
  File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 195,
 in run_from_argv
self.execute(*args, **options.__dict__)
  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 222,
 in execute
output = self.handle(*args, **options)
  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 351,
 in handle
return self.handle_noargs(**options)
  File "C:\Python26\lib\site-packages\django\core\management\commands
\syncdb.py"
, line 78, in handle_noargs
cursor.execute(statement)
  File "C:\Python26\lib\site-packages\django\db\backends\util.py",
line 19, in e
xecute
return self.cursor.execute(sql, params)
  File "C:\Python26\lib\site-packages\django\db\backends\oracle
\base.py", line 4
34, in execute
raise e
cx_Oracle.DatabaseError: ORA-02329: column of datatype LOB cannot be
unique or a
 primary key


--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: What apps do besides provide views?

2009-12-03 Thread Wayne Koorts
>> > remember that an app can do a lot more than provide views.
>>
>> Explain this one to me.  AFAICS, its just http request/response all the way 
>> down and this is basically done by getting a
>
> An app can expose views, indeed. It can also expose models - one of
> the most important parts of an application -, templatetags, filters,
> forms, fields, widgets etc. FWIW, the views are perhaps one of the
> less important thing an app has to offer - and obviously the most easy
> to factor out, cf genericviews. Models, OTHO, are really the core. If
> you end up writing most of your code in views, then you more than
> probably failed to identify what belongs to the model and what belongs
> to the views. The fact that "views" are a mandatory part of the
> request-response cycle doesn't mean they are the most important part
> of the app.

Can anyone point out a section in the docs (or anywhere else actually)
the Django "app" concept?  I've had a look through the docs but
haven't been able to find anything specifically about that.

Regards,
Wayne

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Inline admin objects question

2009-11-18 Thread Wayne
Thanks for your reply.

My situation is a little bit more tricky. I have table A and table B.
Table B has several columns, two of which are tableID and resourceID.
Table B is related to table A in the following way:
select * from table B where b.tableID= (table A) and b.resourceID=
(primary key of table A). There is no composite foreign key support in
Django and the database can not be changed. Is there a way to still
relate those two objects and display them in the Django provided
inline admin interface?

Wayne

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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=.




Inline admin objects question

2009-11-18 Thread Wayne
Hi,

I am working with a legacy database which does not set foreign key
constraints at all between tables. I am wondering if I can still
create Inline admin interface by relating two objects through
different methods. If it is doable, what is the best way of doing it?

Thanks,

Wayne

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Does anyone know what happened to djangopluggables.com?

2009-10-21 Thread Wayne Koorts

>> It's been giving me a "502 Bad Gateway
>> nginx" for at least a couple weeks now.

I've been seeing that for a few months now when trying to visit the site.

Regards,
Wayne

--~--~-~--~~~---~--~~
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 Developer Position in New York City, Urgent Stuff

2009-10-11 Thread Wayne Koorts

>> Please refrain from posting messages with this tone to the Django mailing
>> lists.
>>
> I wholeheartedly agree.
> The Django community has a good reputation.
> Don't screw it up with your foul verbal attacks.

Surely it should be grounds for instant removal?

Regards,
Wayne

--~--~-~--~~~---~--~~
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: list some django-powered web sites

2009-09-24 Thread Wayne Koorts

> hi everybody, We want to develop a Bussiness web site with Django framework,
> but we can't decide django's performance. So, would you list some
> large-scale web sites that used django for us?

Define "large-scale".

--~--~-~--~~~---~--~~
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: Editors of choice

2009-09-07 Thread Wayne Koorts

> Anyhow, the purpose of this email was just to ask the community what
> editor(s) they preferred to use with Django.

Assuming you mean text editor: jEdit (www.jedit.org).

Regards,
Wayne

--~--~-~--~~~---~--~~
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: Formwizard and subforms

2009-08-17 Thread Wayne Koorts

> Nobody can help me with this?

If somebody:

a) Has the answer and,
b) Has the time and,
c) The inclination to provide the answer, then they will do so.

--~--~-~--~~~---~--~~
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: Anybody?? uber-newb question... installing django

2009-08-16 Thread Wayne Koorts

Hi Jon,

The "python setup.py install" command copies the Django library files
to your Python's lib\site-packages directory.  You can safely remove
the Django archive which you downloaded.

Regards,
Wayne

2009/8/17 Jonathan Zacsh <jza...@gmail.com>:
>
> please, can anyone help me out??
> --
> Jon
>
>
> On Sun, Aug 16, 2009 at 10:20 AM, jzacsh<jza...@gmail.com> wrote:
>> hello,
>>
>> i'm sorry - i just want to get started and I'm trying to figure out
>> something simple. I installed django last night and am wondering what
>> setup.py actually did.
>>
>> the reason i want to know is: what do i do with the folder of stuff
>> that I downloaded from the original tar.gz (I get the impression its
>> important, as when i tried to move it I had to use sudo)? so can I
>> delete it (when i ran setup.py, it looked like a lot of files were
>> copying... maybe it was copied elsewhere anyway so this one isn't
>> needed?)? I tried reading docs/intro/install.txt (didn't explain much
>> for this purpose) and i tried making sense of the code in setup.py
>> (turned out to be a bit over my head).
>>
>> I'm running Mac OS X 10.5.8
>> i'm also trying to teach myself python, so sorry if something here
>> might seem obvious.
>> and i know there is a useful docs folder in there, but i'm using
>> docs.djangoproject.com
>> (maybe someone wants to advise me: "django is gonna be WAY over your
>> head if you don't have a good grasp of python"?)
>>
>> thanks for any help! :)
>
> >
>

--~--~-~--~~~---~--~~
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 much python do i need to know to learn/use Django?

2009-08-14 Thread Wayne Koorts

> I currently know zero Python and want to start a project with Django
> ASAP.  I've got the opportunity through my work to either take a 5-day
> Python bootcamp or a Django bootcamp - not both.

I don't really think this is a useful question on its own.  A more
appropriate question would be "How much programming experience do I
need?".  If you have prior programming experience in another language
then I'm sure you'll find Python quick and easy to pick up.  In that
case going through the tutorial and playing around with it in an
afternoon should be enough to prep you for a Django book or course.

If you have no programming experience at all then out of the two
options it would be better to take the Python one.  Any pure Django
course would assume a certain amount of Python knowledge.  But even if
you take a Python course you need to know if the particular course
assumes prior programming experience of some kind of is more of an
"Introduction to Programming Using Python".  If you take a Django
course with no programming experience at all then you will be wasting
your time.  If you have experience in some kind of programming and
then take a Django course with no Python experience then you might be
able to get by.

Regards,
Wayne

--~--~-~--~~~---~--~~
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/ Python 3 - nervous about starting large project

2009-08-06 Thread Wayne Koorts

Hi Tony,

> @Wayne: Thanks for the welcome.  Why are you using 2.5 for your new/
> large project instead of 2.6?

It just seems to be the "sweet spot" release at the moment.  I just
found that a few of the libraries I had been using, even in the last
couple of months, had some kind of problem with anything over 2.5.  I
really wanted to start using 2.6 but for some reason 2.5 seems to be
the most all-round compatible release of them all.  Also it seems that
most shared hosting providers use 2.5 by default.

Regards,
Wayne

--~--~-~--~~~---~--~~
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/ Python 3 - nervous about starting large project

2009-08-05 Thread Wayne Koorts

Hi Tony,

> However, I'm nervous about the Python 3 situation.  What if I start
> building a large project based on Django/Python 2.6, and then a year
> or two down the road the project starts limping because of all of the
> cool new Python 3 modules coming out?  And I've got a bunch of Django/
> Python 2.6 code that needs to be ported?

First of all, welcome to the Python world, we'll do our best to make
you feel comfortable here.

You'll find that the Python crowd is very good at supporting legacy
versions.  You'll see that you can even still download [1] Python
1.5.2 (April 1999!).  That's not to say that your favourite libraries
will be available for such old versions, but many libraries still make
releases for at least as far back as Python 2.3.  Also, I don't think
you'll find that Python 3.x will introduce anything so radically new
and innovative that it will severely limit what you can accomplish
with older releases.  I'm working on a team starting a new (large)
project now which we are basing around Python 2.5.

Remember that Python has been around for a long time, since 1991, and
releases like 2.5, 2.6 etc. are extremely mature and by now all of the
common programming problems have already been encountered, solved and
accomodated in the core and standard libraries.

If you do decide to port your application to 3.x (think very carefully
about it first - make sure that any of the associated libraries you
require have mature 3.x releases) there are tools available to make
the job a lot easier, like the 2to3 [2] script.

[1] http://www.python.org/download/
[2] http://www.python.org/doc/2.6/library/2to3.html

HTH,

Regards,
Wayne Koorts
http://www.wkoorts.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
-~--~~~~--~~--~--~---



Re: Checking POST Variables are set?

2009-08-05 Thread Wayne Koorts

Hi,

> I need some support with something, i have the following boolean field
> but if you submit the form without choosing an answer it kicks back an
> error because i have the following IF Statment to make sure when it is
> selected other fields are mandatory. HEres the code.

Instead of this line:

if request.POST['Lived_Out_Uk'] == '1':

Use this:

if 'Lived_Out_Uk' in request.POST:

Regards,
Wayne Koorts
http://www.wkoorts.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
-~--~~~~--~~--~--~---



Re: replicating database changes from one postgres DB to another

2009-07-21 Thread Wayne Koorts

Hi Steve,

> We have an application where we periodically import data from an
> external vendor, and the process is mostly automated, but we need to
> review the data before having it go live.
>
> We were considering an option where we would run processes on another
> database, do the manual validation, and then replicate the DB changes
> to our production database (which would have the same schema).

I do exactly this with one of my sites.  This is my scenario:

1.  Main database table gets updated automatically every night (this
is a kind of data that can be automatically refreshed, but that should
be beside the point for this discussion).  The data first goes into a
pending table on my dev server, which is exactly the same as the main
table, with "_pending" appended to the name.
2.  The data is then dumped to a file using "psql" and sent via FTP up
to an equivalent pending table on the production server (via Python
script in my dev environment).  There is a Python script set up on the
server to monitor a specific folder for a specific dump file name at
regular intervals, and if it finds it, imports it into the table also
with "psql", then deletes the dump file.
3.  The data sits in the pending table on the production server until
I approve it via an admin interface which I have set up Django.
Basically there is a "DB Admin" area on the site which I have set up
which shows me four chunks of the data at various points in the table,
100 at the start, 100 at 1/4 through, 100 at 3/4 through and then 100
at the end.  It also shows me the total number of records so that I
can do a quick visual integrity check.
4.  There are "approve" and "reject" buttons at the bottom of the
approval page.  If I click "approve" it moves the current live table
data into a backup table (the db admin area also has a restore
function) and moves the pending data into the live table using a raw
nested SQL SELECT statement via Django and then empties the pending
table.  If I click "reject" it just empties the pending table.

These same general steps can be adjusted to accomodate more tables
etc. as per your requirements.

Hope this helps,

Regards,
Wayne Koorts
http://www.wkoorts.com
http://www.blazingpanther.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
-~--~~~~--~~--~--~---



Re: New to unit testing, need advice

2009-07-15 Thread Wayne Koorts

> I'm in the process of implementing testing (both doc tests and unit
> tests) though I'm having some conceptual difficulty. I'm not sure how
> far to take the testing. I'm curious what people concider an
> appropriate level of testing.

Uh oh, be ready for a huge thread.  This is one of those unending debates.

Basically:

- More thorough test coverage == more confidence as you know there is
less chance that when you break something it will go unnoticed.
- Creating complete test coverage and keeping it up to date takes a
lot of time, and sometimes the decision is made to use that time for
other things.

As with anything, there's a balance.  It's very dependant on the
project and team involved.

Regards,
Wayne Koorts
http://www.wkoorts.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
-~--~~~~--~~--~--~---



  1   2   >