Implementing a ldap db backend

2010-11-03 Thread sebastien piquemal
Hi !

I am currently on a big project, which should result in a ldap
management service (modifying users, groups, and any other ldap
object).

Until now, I have been using django-ldapdb, in order to use ldap as a
db backend. It was good for a very basic read-only prototype of the
service. However, this library is not really maintained anymore, and
due to a very high-level implementation (it only subclasses Model,
Query, Queryset, ...), there are a lot of quirks which makes it
unusable for more complex cases.

I have thought of many solutions to replace ldapdb. I came to
conclusion than the cleanest, and most useful for the community, would
be to implement a real db backend for ldap. However, I have been told
that it is an awfully big task !

So, here come my questions ... Do some of you have an implementation
of such a thing in mothballs ? Are some of you interested in sharing
the effort for this ?

If no good answer, I guess I'll just do as I was advised and implement
for myself a few python classes based on python-ldap :-(

-- 
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 without template (no colors, no css, just simple html)

2010-11-03 Thread Robbington
Personally I dont bother creating symlinks to my admin media, I just
copy the media folder over to my project directory. Anyway:

If you think that your settings.py is right:

MEDIA_ROOT = '/var/www/django/project/media/'
MEDIA_URL = 'media/'
ADMIN_MEDIA_PREFIX = '/media/'

or its a permissions problem (Not sure why it would be)

you can check with ls -n and alter permissions with chmod. Here is a
guide if your not sure (http://www.comptechdoc.org/os/linux/usersguide/
linux_ugfilesp.html)

Or check out how to setup a fcgi django project from the main django
site. 
http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/?from=olddocs

If you are a beginner, you might save yourself some trouble using
mod_python to serve python instead of fastcgi, just my opinion. I use
Cherokee anyways

Hope that helped,

Rob

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: rabbitmq + celery + django + celery.views.task_status ... simple example?

2010-11-03 Thread wawa wawawa
Hi,

I'm using a message queue because the task is really "offline" and
could take 1sec or 30 seconds (or longer).

I'll look at b-list. Thankyou

W

On 3 November 2010 07:09, Prashanth  wrote:
>
>
> On Tue, Nov 2, 2010 at 10:42 PM, wawa wawawa  wrote:
>>
>> Hi All,
>>
>> So, I've got my django app, rabbitmq and celery working and processing
>> my uploaded files. Next step is to get the client to display status
>> results provided by JSON, ultimately refreshing to a results page when
>> complete.
>>
>> I'm a little new to JSON / AJAX (AJAJ!) and I'm struggling a little
>> with the templates and views part.
>>
>> Are there any easy examples out there?
>>
>
>
> Is the expectation like user will upload a file and will see a result? if
> that is case why are using celery? b-list has a ajax example[1]. BTW,  if
> you are trying to upload a file using ajax you need to create iframe using
> javascript, you might want to use jsupload[2]
>
> [1] http://www.b-list.org/weblog/2006/jul/31/django-tips-simple-ajax-example-part-1/
> [2] http://valums.com/
> --
> regards,
> Prashanth
> twitter: munichlinux
> blog: honeycode.in
> irc: munichlinux, JSLint, munichpython.
>
> --
> 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: rabbitmq + celery + django + celery.views.task_status ... simple example?

2010-11-03 Thread Tom Evans
On Tue, Nov 2, 2010 at 5:12 PM, wawa wawawa  wrote:
> Hi All,
>
> So, I've got my django app, rabbitmq and celery working and processing
> my uploaded files. Next step is to get the client to display status
> results provided by JSON, ultimately refreshing to a results page when
> complete.
>
> I'm a little new to JSON / AJAX (AJAJ!) and I'm struggling a little
> with the templates and views part.
>
> Are there any easy examples out there?
>
> I can't seem to find any!
>
> Many thanks in advance for any suggestions.
>
> Cheers
>
> W
>

Sure. I have a TV recording system built using Django (the UI is web
based), which records TV shows to disk in MPEG2 format. I then use the
whole celery stack to convert those video files into something that I
can then load up onto my ipad/iphone.

The transcoding is initiated by a user clicking an icon on the episode
page, which triggers an AJAX call, which eventually calls this
function:

def setup_transcode_episode(episode):
  data = { 'valid': False, }
  if episode.media:
file = unicode(episode.media)
rv = transcode_episode_for_ipad.delay(file=file, episode_id=episode.id)
tm, created = TaskMeta.objects.get_or_create(task_id=rv.task_id)
episode.ipad_media = tm
episode.save()
data['task_id'] = rv.task_id
data['valid'] = True
  return data

The data dictionary is returned back to the client, which now
periodically polls a view for status, using the task_id.

The task that is invoked, transcode_episode_for_ipad, looks like this:

@task
def transcode_episode_for_ipad(file, episode_id, **kwargs):
  args = make_ipad_encoder_args(file=file)
  out = args[-1]
  ffmpeg = FFmpegProgressMonitor(file=file, task_id=kwargs['task_id'],
args=args)
  rv = ffmpeg.process()
  episode = TVEpisode.objects.get(id=episode_id)
  dir, fn = out.rsplit('/', 1)
  imedia = MplayerFileMedia.objects.create(directory=dir, file=fn)
  episode.ipad_media = imedia
  episode.save()
  return rv

This is pretty straight-forward, I simply produce the arguments for
ffmpeg, and then process it, monitoring the output of the ffmpeg to
give me hints about how long through the transcoding process we are,
which I then store in memcache, to avoid requiring a database hit to
find out the status of the task.
This is easier than it sounds, every  frames, ffmpeg prints out a
line indicating how far through the file it is. Just monitor the
output and update the cache as appropriate.

The way my models are set up, TVEpisode.ipad_media is a generic
foreign key, so while transcoding is taking place it points at the
TaskMeta object, which contains the task id. This allows us to know
that the task is underway in the background, even if we didn't
initiate it ourselfs, and use that information to poll for status etc
as appropriate.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: rabbitmq + celery + django + celery.views.task_status ... simple example?

2010-11-03 Thread wawa wawawa
You Sir, are awesome.

I think this seems to be exactly what I was looking for...

Can I ask for JS code that does the periodic polling from the client
please and possibly the appropriate bits of the template?

Many thanks!

W

On 3 November 2010 11:10, Tom Evans  wrote:
> On Tue, Nov 2, 2010 at 5:12 PM, wawa wawawa  wrote:
>> Hi All,
>>
>> So, I've got my django app, rabbitmq and celery working and processing
>> my uploaded files. Next step is to get the client to display status
>> results provided by JSON, ultimately refreshing to a results page when
>> complete.
>>
>> I'm a little new to JSON / AJAX (AJAJ!) and I'm struggling a little
>> with the templates and views part.
>>
>> Are there any easy examples out there?
>>
>> I can't seem to find any!
>>
>> Many thanks in advance for any suggestions.
>>
>> Cheers
>>
>> W
>>
>
> Sure. I have a TV recording system built using Django (the UI is web
> based), which records TV shows to disk in MPEG2 format. I then use the
> whole celery stack to convert those video files into something that I
> can then load up onto my ipad/iphone.
>
> The transcoding is initiated by a user clicking an icon on the episode
> page, which triggers an AJAX call, which eventually calls this
> function:
>
> def setup_transcode_episode(episode):
>  data = { 'valid': False, }
>  if episode.media:
>    file = unicode(episode.media)
>    rv = transcode_episode_for_ipad.delay(file=file, episode_id=episode.id)
>    tm, created = TaskMeta.objects.get_or_create(task_id=rv.task_id)
>    episode.ipad_media = tm
>    episode.save()
>    data['task_id'] = rv.task_id
>    data['valid'] = True
>  return data
>
> The data dictionary is returned back to the client, which now
> periodically polls a view for status, using the task_id.
>
> The task that is invoked, transcode_episode_for_ipad, looks like this:
>
> @task
> def transcode_episode_for_ipad(file, episode_id, **kwargs):
>  args = make_ipad_encoder_args(file=file)
>  out = args[-1]
>  ffmpeg = FFmpegProgressMonitor(file=file, task_id=kwargs['task_id'],
> args=args)
>  rv = ffmpeg.process()
>  episode = TVEpisode.objects.get(id=episode_id)
>  dir, fn = out.rsplit('/', 1)
>  imedia = MplayerFileMedia.objects.create(directory=dir, file=fn)
>  episode.ipad_media = imedia
>  episode.save()
>  return rv
>
> This is pretty straight-forward, I simply produce the arguments for
> ffmpeg, and then process it, monitoring the output of the ffmpeg to
> give me hints about how long through the transcoding process we are,
> which I then store in memcache, to avoid requiring a database hit to
> find out the status of the task.
> This is easier than it sounds, every  frames, ffmpeg prints out a
> line indicating how far through the file it is. Just monitor the
> output and update the cache as appropriate.
>
> The way my models are set up, TVEpisode.ipad_media is a generic
> foreign key, so while transcoding is taking place it points at the
> TaskMeta object, which contains the task id. This allows us to know
> that the task is underway in the background, even if we didn't
> initiate it ourselfs, and use that information to poll for status etc
> as appropriate.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-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: Attributr error

2010-11-03 Thread Tom Evans
On Wed, Nov 3, 2010 at 5:31 AM, sami nathan  wrote:
> I want my final result in xml format and how can i do that? thanks for
> notification
>

I tell you what, seeing how you've done most of the work already on
this, I'll get you started:





There are literally thousands of ways you can turn some unspecified
data into some unspecified XML format. Try one.

-- 
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: rabbitmq + celery + django + celery.views.task_status ... simple example?

2010-11-03 Thread Tom Evans
On Wed, Nov 3, 2010 at 10:16 AM, wawa wawawa  wrote:
> You Sir, are awesome.
>
> I think this seems to be exactly what I was looking for...
>
> Can I ask for JS code that does the periodic polling from the client
> please and possibly the appropriate bits of the template?
>
> Many thanks!
>
> W
>

Sure. In the main page view, I check to see whether I have transcoded
or started transcoding the episode, and set context variables as
appropriate:

  if episode.ipad_media:
if hasattr(episode.ipad_media, 'task_id'):
  from transcoding.utils import get_task_progress
  data['ipad_media_class'] = 'transcoding'
  data['ipad_media_progress'] = (episode.ipad_media.task_id,
get_task_progress(episode.ipad_media.task_id))
else:
  data['ipad_media_class'] = 'good'
  else:
data['ipad_media_class'] = 'bad'

This is rendered into a widget on the page:

  {% if episode.media %}
  
Play episode

  {% if ipad_media_progress %}
  Transcoding to ipad
  {{
ipad_media_progress.1 }} %
  {% else %}
  Transcode to ipad
  {% endif %}

  
  {% endif %}


Then, during page load, I configure an observer to update each
progress widget (I use the prototype JS framework):

  $$('div.pct').each(function(ctl) {
  new Ajax.PeriodicalUpdater(ctl, '{% url transcode_task_status_ajax %}', {
method: 'get',
asynchronous: true,
frequency: 3,
decay: 2,
parameters: { task_id: ctl.id }
});
  });

That view is trivial, since it just updates the appropriate div with
the current percentage:

def transcode_task_status_ajax(request):
  from transcoding.utils import get_task_progress
  task_id = request.GET.get('task_id')
  return HttpResponse(u'%s %%' % get_task_progress(task_id))


Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: rabbitmq + celery + django + celery.views.task_status ... simple example?

2010-11-03 Thread wawa wawawa
Tom - many thanks again.

This is good stuff.

W

On 3 November 2010 11:36, Tom Evans  wrote:
> On Wed, Nov 3, 2010 at 10:16 AM, wawa wawawa  wrote:
>> You Sir, are awesome.
>>
>> I think this seems to be exactly what I was looking for...
>>
>> Can I ask for JS code that does the periodic polling from the client
>> please and possibly the appropriate bits of the template?
>>
>> Many thanks!
>>
>> W
>>
>
> Sure. In the main page view, I check to see whether I have transcoded
> or started transcoding the episode, and set context variables as
> appropriate:
>
>  if episode.ipad_media:
>    if hasattr(episode.ipad_media, 'task_id'):
>      from transcoding.utils import get_task_progress
>      data['ipad_media_class'] = 'transcoding'
>      data['ipad_media_progress'] = (episode.ipad_media.task_id,
> get_task_progress(episode.ipad_media.task_id))
>    else:
>      data['ipad_media_class'] = 'good'
>  else:
>    data['ipad_media_class'] = 'bad'
>
> This is rendered into a widget on the page:
>
>  {% if episode.media %}
>  
>    Play episode
>    
>      {% if ipad_media_progress %}
>      Transcoding to ipad
>      {{
> ipad_media_progress.1 }} %
>      {% else %}
>      Transcode to ipad
>      {% endif %}
>    
>  
>  {% endif %}
>
>
> Then, during page load, I configure an observer to update each
> progress widget (I use the prototype JS framework):
>
>  $$('div.pct').each(function(ctl) {
>      new Ajax.PeriodicalUpdater(ctl, '{% url transcode_task_status_ajax %}', {
>        method: 'get',
>        asynchronous: true,
>        frequency: 3,
>        decay: 2,
>        parameters: { task_id: ctl.id }
>        });
>      });
>
> That view is trivial, since it just updates the appropriate div with
> the current percentage:
>
> def transcode_task_status_ajax(request):
>  from transcoding.utils import get_task_progress
>  task_id = request.GET.get('task_id')
>  return HttpResponse(u'%s %%' % get_task_progress(task_id))
>
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-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.



Whoosh: 'module' object has no attribute 'FileStorage'

2010-11-03 Thread sureronald
Hi all,

I am using Whoosh version 1.2.5 to allow for full text search on my
models. I was using this guideline from here
http://www.arnebrodowski.de/blog/add-full-text-search-to-your-django-project-with-whoosh.html
but I keep getting the error 'module' object has no attribute
'FileStorage'
Has this attribute has been deprecated? I checked and confirmed that
the attribute FileStorage is actually not there but there's one with
the name Storage. Is this it's replacement?

-- 
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: Whoosh: 'module' object has no attribute 'FileStorage'

2010-11-03 Thread David De La Harpe Golden
On 03/11/10 08:41, sureronald wrote:
> Hi all,
> 
> I am using Whoosh version 1.2.5 to allow for full text search on my
> models. I was using this guideline from here
> http://www.arnebrodowski.de/blog/add-full-text-search-to-your-django-project-with-whoosh.html

Note that django-haystack [1] has a whoosh backend, though there's
obviously nothing really stopping you using whoosh directly, haystack
makes things (even) easier if you have an "ordinary" django app with a
bunch of model instances you want to index for search.

Right at this moment, though, released haystack 1.0.x will only work
with rather older whoosh owing to api changes in whoosh between 0.x and
1.x [2], so you have to do something like easy_install -U whoosh==0.3.18
to use an old version of whoosh.

As [2] says, haystack 1.1 isn't quite out yet, but it should work with
more recent whoosh (untested).

> but I keep getting the error 'module' object has no attribute
> 'FileStorage' Has this attribute has been deprecated?
> I checked and confirmed that the attribute FileStorage is actually 
>  not there but there's one with the name Storage. Is this it's
replacement?

No, that's just the abstract base class for storage backends, you
probably want "from whoosh.filedb.filestore import FileStorage"

The blog post you're following, much like haystack, was presumably
written against older whoosh, refer to the whoosh documentation.

[1] http://haystacksearch.org/

[2] https://github.com/toastdriven/django-haystack/issues/issue/241

-- 
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: Attributr error

2010-11-03 Thread sami nathan
Where should i use this please tell!! should i use in urls.py

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



Sample Auto Log Out Code

2010-11-03 Thread octopusgrabbus
Does anyone have samples for auto logging out a user?

-- 
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: Sample Auto Log Out Code

2010-11-03 Thread Sells, Fred
I'm running on Windows 7, Python 2.4 and Django 1.2.1 

I'm trying to change one table "facility" by dropping it and then
letting syncdb recreate it.  I thought syncdb was supposed to ignore
already created tables, but that does not appear to be the case.  

What am I doing wrong?

>python manage.py syncdb
Creating table facility
Creating table Assessment
Traceback (most recent call last):
  File "manage.py", line 11, in ?
execute_manager(settings)
  File
"c:\alltools\python\Lib\site-packages\django\core\management\__init__.py
", line 438, in execute_manager
utility.execute()
  File
"c:\alltools\python\Lib\site-packages\django\core\management\__init__.py
", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"c:\alltools\python\Lib\site-packages\django\core\management\base.py",
line 191, in run_from_argv
self.execute(*args, **options.__dict__)
  File
"c:\alltools\python\Lib\site-packages\django\core\management\base.py",
line 218, in execute
output = self.handle(*args, **options)
  File
"c:\alltools\python\Lib\site-packages\django\core\management\base.py",
line 347, in handle
return self.handle_noargs(**options)
  File
"c:\alltools\python\Lib\site-packages\django\core\management\commands\sy
ncdb.py", line 95, in handle_noargs
cursor.execute(statement)
  File
"c:\alltools\python\Lib\site-packages\django\db\backends\util.py", line
15, in execute
return self.cursor.execute(sql, params)
  File
"c:\alltools\python\Lib\site-packages\django\db\backends\mysql\base.py",
line 86, in execute
return self.cursor.execute(query, args)
  File
"c:\alltools\python\lib\site-packages\mysql_python-1.2.2-py2.4-win32.egg
\MySQLdb\cursors.py", line 166, in execute
  File
"c:\alltools\python\lib\site-packages\mysql_python-1.2.2-py2.4-win32.egg
\MySQLdb\connections.py", line 35, in defaulterrorhandler
_mysql_exceptions.OperationalError: (1050, "Table 'assessment' already
exists")

-- 
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: Attributr error

2010-11-03 Thread sami nathan
HOW TO GET XML RESPONSE in following
THIS IS HOW MY URL.PY LOOKS LIKE

from django.conf.urls.defaults import *
from it.view import current_datetime



# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
#admin.autodiscover()


urlpatterns = patterns('',
   # Example:
(r"^wap/di/sub/$",current_datetime),
   # Uncomment the admin/doc line below to enable admin documentation:
   # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

   # Uncomment the next line to enable the admin:
   # (r'^admin/', include(admin.site.urls)),
)

`~~~
My view .py looks like this

from django.http import *
import urllib
from django_restapi.responder import XMLResponder


def current_datetime(request):
   word = request.GET['word']
   message = 
urllib.urlopen('http://m.broov.com/wap/di/sub?word='+word+'&type=00submit=Submit',)
   return HttpResponse(message)

-- 
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: Attributr error

2010-11-03 Thread sami nathan
i Think serialisation would be helpful for this some one help me how to use 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.



SERIALIZING

2010-11-03 Thread sami nathan
HOW TO GET XML RESPONSE in following
THIS IS HOW MY URL.PY LOOKS LIKE

from django.conf.urls.defaults import *
from it.view import current_datetime



# Uncomment the next two lines to enable the admin:
#from django.contrib import admin
#admin.autodiscover()


urlpatterns = patterns('',
  # Example:
   (r"^wap/di/sub/$",current_datetime),
  # Uncomment the admin/doc line below to enable admin documentation:
  # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

  # Uncomment the next line to enable the admin:
  # (r'^admin/', include(admin.site.urls)),
)

`~~~
My view .py looks like this

from django.http import *
import urllib
from django_restapi.responder import XMLResponder


def current_datetime(request):
  word = request.GET['word']
  message = 
urllib.urlopen('http://m.broov.com/wap/di/sub?word='+word+'&type=00submit=Submit',)
  return HttpResponse(message)

-- 
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 aggregate values by month

2010-11-03 Thread Rogério Carrasqueira
Hi Scott
Thanks for you help, unfortunately on trying

sales = Sale.objects.filter(date_
created__range=(init_date,ends_date))
   .values(date_ created__month)
   .aggregate(total_sales=Sum('total_value'))

This error appeared,

global name 'date_created__month' is not defined


Do you have another approach?

Regards,

Rogério Carrasqueira

---
e-mail: rogerio.carrasque...@gmail.com
skype: rgcarrasqueira
MSN: rcarrasque...@hotmail.com
ICQ: 50525616
Tel.: (11) 7805-0074



2010/10/28 Scott Gould 

> Personally I hate writing raw SQL so I would probably try something
> like this (untested):
>
> sales = Sale.objects.filter(date_created__range=(init_date,ends_date))
>.values(date_ created__month)
>.aggregate(total_sales=Sum('total_value'))
>
> sales_by_month = [(x.year, x.month, [y for y in sales if y.year ==
> x.year and y.month == x.month])
>for x in set([z.year, z.month for z in sales])]
>
> Should give you a list of (year, month, subqueryset) tuples. Of
> course, there might be performance issues with nested list
> comprehensions like that depending on the size of the initial
> queryset, but at least it's a one-line, SQL-free solution!
>
> On Oct 28, 9:31 am, Rogério Carrasqueira
>  wrote:
> > Hello!
> >
> > I'm having an issue to make complex queries in django. My problem is, I
> have
> > a model where I have the sales and I need to make a report showing the
> sales
> > amount per month, by the way I made this query:
> >
> > init_date = datetime.date(datetime.now()-timedelta(days=365))
> > ends_date = datetime.date(datetime.now())
> > sales =
> >
> Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_
> created__month).aggregate(total_sales=Sum('total_value'))
> >
> > At the first line I get the today's date past one year
> > after this I got the today date
> >
> > at sales I'm trying to between a range get the sales amount grouped by
> > month, but unfortunatelly I was unhappy on this, because this error
> > appeared:
> >
> > global name 'date_created__month' is not defined
> >
> > At date_created is the field where I store the information about when the
> > sale was done., the __moth was a tentative to group by this by month.
> >
> > So, my question: how to do that thing without using a raw sql query and
> not
> > touching on database independence?
> >
> > Thanks so much!
> >
> > Rogério Carrasqueira
> >
> > ---
> > e-mail: rogerio.carrasque...@gmail.com
> > skype: rgcarrasqueira
> > MSN: rcarrasque...@hotmail.com
> > ICQ: 50525616
> > Tel.: (11) 7805-0074
>
> --
> 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.



Using multiple managers

2010-11-03 Thread Benjamin Wohlwend
Hi,

I have a base model A and two models B and C inheriting from the base
model. I'm using django-polymorphic[1] since it very conveniently
returns a list of B and C when querying on A. The requirement came up
that model C needs a GeometryField, and now I'm stuck. Both GeoDjango
and django-polymorphic define their own managers, and they both
require their manager to be the default manager (polymorphic
explicitly, GeoDjango throws exceptions when trying to access the geo
field if GeoManager isn't the default manager).

I almost got it working with this code:

class CombinedQuerySet(GeoQuerySet, PolymorphicQuerySet):
pass

class CombinedManager(GeoManager, PolymorphicManager):
def get_query_set(self):
return CombinedQuerySet(self.model, using=self._db)

class A(models.Model):
objects = CombinedManager()

With this code, GeoDjango only complains ('String or unicode input
unrecognized as WKT EWKT, and HEXEWKB.') on queries like

A.objects.all()[0].geo_field # first elem is of type 'C'

while this query works:

C.objects.all()[0].geo_field

So, is it possible to combine these two managers so that both their
features work?

Kind regards,
Benjamin

[1]: https://github.com/bconstantin/django_polymorphic

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



FormWizard and permission_required

2010-11-03 Thread cootetom
Hi,

When creating normal views I can decorate the view with
@permission_required('some_permission') but when I'm using a
FormWizard class I don't know where to limit access to it based on
permissions? I have a FormWizard mapped to a URL:

(r'^my_url/?$', Wizard([Step1, Step2, Step3])),

Then I have the form class's and wizard class as needed. I'm stumped
as to where I might limit access to this URL based on permissions?

-- 
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-voting url pattern

2010-11-03 Thread Sithembewena Lloyd Dube
Thanks Daniel!

On Tue, Nov 2, 2010 at 11:39 AM, Daniel Roseman wrote:

> On Nov 1, 3:08 pm, Sithembewena Lloyd Dube  wrote:
> > Thanks Daniel, makes sense. Also, I was making the mistake of thinking
> that
> > I had to create a separate view, forgetting that I am calling the one
> > supplied by django-voting. That correct?
>
> I'm not familiar with django-voting, but yes that sounds right.
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.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: FormWizard and permission_required

2010-11-03 Thread ringemup

I use a wrapping view, rather like this:

# urls.py
(r'^my_url/?$', my_view, ...)

# views.py
@permission_required('some_permission')
def my_view(request):
  return MyWizard([Step1, Step2, Step3, ...])



On Nov 3, 9:54 am, cootetom  wrote:
> Hi,
>
> When creating normal views I can decorate the view with
> @permission_required('some_permission') but when I'm using a
> FormWizard class I don't know where to limit access to it based on
> permissions? I have a FormWizard mapped to a URL:
>
> (r'^my_url/?$', Wizard([Step1, Step2, Step3])),
>
> Then I have the form class's and wizard class as needed. I'm stumped
> as to where I might limit access to this URL based on permissions?

-- 
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 without template (no colors, no css, just simple html)

2010-11-03 Thread marcoarreguin
Thanks Robbington!

Hey, Im watching that you mention "your project directory".

But I have my django and my project in another patch, actually, out of
www directory, but I have the fastcgi file right there, only that
file.

So, Where is my project directory in my shared hosting myuser/
home/.local/lib/python/myproject  OR myuser/home/public_html ???

Thanks again!

-- 
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: Repost Admin Site Without Graphics

2010-11-03 Thread octopusgrabbus
Here is my symbolic link to what I believe is the admin media:

media -> /usr/local/lib/python2.6/site-packages/django/contrib/admin/
media

Here's what's in that directory:

a...@h2oamr:~/django/amr$ ls -lH media
total 12
drwxr-xr-x 2 root root 4096 Sep 15 13:54 css
drwxr-xr-x 4 root root 4096 Sep 15 13:54 img
drwxr-xr-x 3 root root 4096 Sep 15 13:54 js

and these directories appear to contain the admin media.

Here's what's in settings.py

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/home/amr/django/media'

# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash if there is a path component (optional in other
cases).
# Examples: "http://media.lawrence.com";, "http://example.com/media/";
MEDIA_URL = 'media/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure
to use a
# trailing slash.
# Examples: "http://foo.com/media/";, "/media/".
ADMIN_MEDIA_PREFIX = '/media/'


I'm missing something, but don't get what I'm missing.
tnx
cmn

On Nov 2, 3:20 pm, James  wrote:
> So your admin media (js, css, images, etc) isn't working?
>
> Try two things:
>
> 1. Open the source of some admin page. Look at some image, css, or js
> object. Find the path where it is pointing. Does this path makes
> sense? (Have you put it in the settings.py file?)
>
> 2. Check your site settings. If you are using django's web server, it
> will serve the admin files automatically, if you are using apache or
> some other web server, you will have to specify where the admin site's
> files are, like Robbington said. Compare the path in the settings file
> to the one that is being served.
>
> ...
>
> On Tue, Nov 2, 2010 at 11:58 AM, octopusgrabbus
>
>  wrote:
> > Tried suggestions, and still do not get full graphics. Everything else
> > works. Users are displayed, and so on.
>
> > On Nov 2, 12:24 pm, octopusgrabbus  wrote:
> >> Thanks. I'll try your suggestions. I am using the phrase no graphics
> >> to mean the admin site comes up, but doesn't have all the nice
> >> background.
>
> >> On Nov 1, 3:41 pm, Robbington  wrote:
>
> >> > Hi,
>
> >> > By 'with out graphics' do you mean no css or Javascript?
>
> >> > If so you want to make sure the value for these 3 varibles are correct
> >> > as its not governed by the templates list.
>
> >> > MEDIA_ROOT = ' /var/www/django_project/media' # Where media is the
> >> > copied folder of admin media or a symbolic link if you are using
> >> > Linux.
>
> >> > MEDIA_URL = 'media/'
>
> >> > ADMIN_MEDIA_PREFIX = '/media/'
>
> >> > Rob

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



RadioSelect widget in Django 1.1 using Model Form

2010-11-03 Thread Ricardo L. Dani
Hello,

I'm working with an project using django-cms and django 1.1 and I have this
problem:

With a big model form with many choice charFields must be reendered as
 and not as 's (default)

Ex:

field = models.CharField(max_length=1, default=None, choices=CHOICES)

renders:



... etc

but i need a 

With django 1.2 i get this using:

class InscricaoForm(ModelForm):

class Meta:
model = Inscricao
widgets ={
'possiveis_areas_de_interesse' : RadioSelect,
'regime_dedicacao_curso' : RadioSelect,
'vinculo_empregaticio' : RadioSelect,
'interesse_bolsa_estudos' : RadioSelect,
'conhecimento_linguas_estrangeiras' : RadioSelect
}

but I use django-cms and this not works fine with django 1.2

the question: how i do that with django 1.1 ?

thanks

Ps: sorry for the bad english :/

-- 
Ricardo Lapa Dani
Graduando em Ciência da Computação
Universidade Federal de Ouro Preto

-- 
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: FormWizard and permission_required

2010-11-03 Thread cootetom
That's a good idea. I'll do that then. Thanks.



On Nov 3, 2:51 pm, ringemup  wrote:
> I use a wrapping view, rather like this:
>
> # urls.py
> (r'^my_url/?$', my_view, ...)
>
> # views.py
> @permission_required('some_permission')
> def my_view(request):
>   return MyWizard([Step1, Step2, Step3, ...])
>
> On Nov 3, 9:54 am, cootetom  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > When creating normal views I can decorate the view with
> > @permission_required('some_permission') but when I'm using a
> > FormWizard class I don't know where to limit access to it based on
> > permissions? I have a FormWizard mapped to a URL:
>
> > (r'^my_url/?$', Wizard([Step1, Step2, Step3])),
>
> > Then I have the form class's and wizard class as needed. I'm stumped
> > as to where I might limit access to this URL based on permissions?

-- 
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: Repost Admin Site Without Graphics

2010-11-03 Thread Robbington
So is your media stored at "" a...@h2oamr:~/django/amr/media? ""
and you MEDIA_ROOT = '/home/amr/django/media' ?

Rob


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: RadioSelect widget in Django 1.1 using Model Form

2010-11-03 Thread Daniel Roseman
On Nov 3, 3:03 pm, "Ricardo L. Dani"  wrote:
> Hello,
>
> I'm working with an project using django-cms and django 1.1 and I have this
> problem:
>
> With a big model form with many choice charFields must be reendered as
>  and not as 's (default)
>
> Ex:
>
>     field = models.CharField(max_length=1, default=None, choices=CHOICES)
>
> renders:
>
>     
>         
>         ... etc
>
> but i need a 
>
> With django 1.2 i get this using:
>
> class InscricaoForm(ModelForm):
>
>     class Meta:
>         model = Inscricao
>         widgets ={
>             'possiveis_areas_de_interesse' : RadioSelect,
>             'regime_dedicacao_curso' : RadioSelect,
>             'vinculo_empregaticio' : RadioSelect,
>             'interesse_bolsa_estudos' : RadioSelect,
>             'conhecimento_linguas_estrangeiras' : RadioSelect
>         }
>
> but I use django-cms and this not works fine with django 1.2
>
> the question: how i do that with django 1.1 ?
>
> thanks
>
> Ps: sorry for the bad english :/
>

Your English is fine.

You have to overwrite the field declaration for each one you want to
change, specifying the `widget` argument:

class InscricaoForm(ModelForm):
possiveis_areas_de_interesse =
forms.ChoiceField(choices=FOO_CHOICES, widget=forms.RadioSelect)

etc. You have to remember to include all the options you've defined
for your model field - default, max_length, is_required. It's
unfortunately very verbose, which is why the `widgets` syntax was
introduced in version 1.2.
--
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: Admin without template (no colors, no css, just simple html)

2010-11-03 Thread Robbington
Well my friend, I have quickly looked into hosting a django project
via blue host and this is what the django site has to say:

Similar setup as Dreamhost. Django is listed as unsupported, but with
some pain it does work, and has a good price..
http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts

I use a vps, so I have never had to intergrate it with a 3rd party
hosting system.


""But I have my django and my project in another patch, actually, out
of
www directory, but I have the fastcgi file right there, only that
file.""

Not sure what you mean by 'in another patch'? Dont worry about the
location of fastcgi, it is responsible for letting apache serve you
python code, if you can log into the admin site, then its working. If
you think its responsible for not serving the static media, then I
would suggest reading the full fastcgi documentation. I use a cherokee-
uwsgi setup, so I cant really comment.

"" So, Where is my project directory in my shared hosting ""

The project directory is the one created when you run django-admin.py
startproject. Where your settings.py file is located.

Rob

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: RadioSelect widget in Django 1.1 using Model Form

2010-11-03 Thread Ricardo L. Dani
Thanks Daniel,

Now it makes sense.

Thank you again

2010/11/3 Daniel Roseman 

> On Nov 3, 3:03 pm, "Ricardo L. Dani"  wrote:
> > Hello,
> >
> > I'm working with an project using django-cms and django 1.1 and I have
> this
> > problem:
> >
> > With a big model form with many choice charFields must be reendered as
> >  and not as 's (default)
> >
> > Ex:
> >
> > field = models.CharField(max_length=1, default=None, choices=CHOICES)
> >
> > renders:
> >
> > 
> > 
> > ... etc
> >
> > but i need a 
> >
> > With django 1.2 i get this using:
> >
> > class InscricaoForm(ModelForm):
> >
> > class Meta:
> > model = Inscricao
> > widgets ={
> > 'possiveis_areas_de_interesse' : RadioSelect,
> > 'regime_dedicacao_curso' : RadioSelect,
> > 'vinculo_empregaticio' : RadioSelect,
> > 'interesse_bolsa_estudos' : RadioSelect,
> > 'conhecimento_linguas_estrangeiras' : RadioSelect
> > }
> >
> > but I use django-cms and this not works fine with django 1.2
> >
> > the question: how i do that with django 1.1 ?
> >
> > thanks
> >
> > Ps: sorry for the bad english :/
> >
>
> Your English is fine.
>
> You have to overwrite the field declaration for each one you want to
> change, specifying the `widget` argument:
>
> class InscricaoForm(ModelForm):
>possiveis_areas_de_interesse =
> forms.ChoiceField(choices=FOO_CHOICES, widget=forms.RadioSelect)
>
> etc. You have to remember to include all the options you've defined
> for your model field - default, max_length, is_required. It's
> unfortunately very verbose, which is why the `widgets` syntax was
> introduced in version 1.2.
> --
> 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Ricardo Lapa Dani
Graduando em Ciência da Computação
Universidade Federal de Ouro Preto

-- 
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 strings as fieldnames to save model

2010-11-03 Thread Thomas M
Hi,

I have to save a model with dynamic fieldnames. So the field
identifiers are strings.

Example:
foo  = Genre("genre_id"=2,"name"="ente")
foo.save()

This creates an error. Is it somehow possible to do this with the
model instance?
Or do I have to use custom SQL?

Thanks, Thomas

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

2010-11-03 Thread Sebastian Alonso
Hi everyone, I'm a complete django newbie, and I need to use the Auth
system. The problem is that I haven't been able to find a good tutorial such
as que django one, with all the examples, pretty simple, very easy, with the
templates included, etc... My main issue is that i dont get on well with
html, so the templates are a complete mistery, and the forms, and
everything. The django tutorial provides you with the different templates
and everything.

For example if I search among the other tutorials in the django site,
there are tutorials related to the Auth system, but they are somehow more
advanced than what I'm looking for. For example there's one on how to expand
the user model.. but I dont even know who to use the basic auth system :P


So, if you know of any tutorial like the one I describe let me know, any
link is helpful...


thanks in advance,

Seba

-- 
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 strings as fieldnames to save model

2010-11-03 Thread Daniel Roseman
On Nov 3, 4:17 pm, Thomas M  wrote:
> Hi,
>
> I have to save a model with dynamic fieldnames. So the field
> identifiers are strings.
>
> Example:
> foo  = Genre("genre_id"=2,"name"="ente")
> foo.save()
>
> This creates an error. Is it somehow possible to do this with the
> model instance?
> Or do I have to use custom SQL?
>
> Thanks, Thomas

This is invalid Python. You can't use strings as parameter names.

What you can do is use a dictionary:

values = {genre_id": 2, "name": "ente"}
foo = Genre(**values)
--
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 at 
http://groups.google.com/group/django-users?hl=en.



Re: using strings as fieldnames to save model

2010-11-03 Thread Thomas M
Ok, thanks.

I'll try it tomorrow.

What is the meaning of the **?

Thanks, Thomas

On 3 Nov., 17:53, Daniel Roseman  wrote:
> On Nov 3, 4:17 pm, Thomas M  wrote:
>
> > Hi,
>
> > I have to save a model with dynamic fieldnames. So the field
> > identifiers are strings.
>
> > Example:
> > foo  = Genre("genre_id"=2,"name"="ente")
> > foo.save()
>
> > This creates an error. Is it somehow possible to do this with the
> > model instance?
> > Or do I have to use custom SQL?
>
> > Thanks, Thomas
>
> This is invalid Python. You can't use strings as parameter names.
>
> What you can do is use a dictionary:
>
> values = {genre_id": 2, "name": "ente"}
> foo = Genre(**values)
> --
> 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 at 
http://groups.google.com/group/django-users?hl=en.



Re: using strings as fieldnames to save model

2010-11-03 Thread Brian Bouterse
** is part of python the python
grammar.
 See 
thisfor
more info on how to use * and ** in python

Brian

On Wed, Nov 3, 2010 at 1:52 PM, Thomas M  wrote:

> Ok, thanks.
>
> I'll try it tomorrow.
>
> What is the meaning of the **?
>
> Thanks, Thomas
>
> On 3 Nov., 17:53, Daniel Roseman  wrote:
> > On Nov 3, 4:17 pm, Thomas M  wrote:
> >
> > > Hi,
> >
> > > I have to save a model with dynamic fieldnames. So the field
> > > identifiers are strings.
> >
> > > Example:
> > > foo  = Genre("genre_id"=2,"name"="ente")
> > > foo.save()
> >
> > > This creates an error. Is it somehow possible to do this with the
> > > model instance?
> > > Or do I have to use custom SQL?
> >
> > > Thanks, Thomas
> >
> > This is invalid Python. You can't use strings as parameter names.
> >
> > What you can do is use a dictionary:
> >
> > values = {genre_id": 2, "name": "ente"}
> > foo = Genre(**values)
> > --
> > 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 at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Brian Bouterse
ITng Services

-- 
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 aggregate values by month

2010-11-03 Thread Rogério Carrasqueira
Hi Mikhail!

Can you give some clue on how to use your plugin considering my scenario?

Thanks

Rogério Carrasqueira

---
e-mail: rogerio.carrasque...@gmail.com
skype: rgcarrasqueira
MSN: rcarrasque...@hotmail.com
ICQ: 50525616
Tel.: (11) 7805-0074



2010/10/28 Mikhail Korobov 

> Hi Rogério,
>
> You can give http://bitbucket.org/kmike/django-qsstats-magic/src a
> try.
> It currently have efficient aggregate lookups (1 query for the whole
> time series) only for mysql but it'll be great if someone contribute
> efficient lookups for other databases :)
>
> On 28 окт, 19:31, Rogério Carrasqueira
>  wrote:
> > Hello!
> >
> > I'm having an issue to make complex queries in django. My problem is, I
> have
> > a model where I have the sales and I need to make a report showing the
> sales
> > amount per month, by the way I made this query:
> >
> > init_date = datetime.date(datetime.now()-timedelta(days=365))
> > ends_date = datetime.date(datetime.now())
> > sales =
> >
> Sale.objects.filter(date_created__range=(init_date,ends_date)).values(date_
> created__month).aggregate(total_sales=Sum('total_value'))
> >
> > At the first line I get the today's date past one year
> > after this I got the today date
> >
> > at sales I'm trying to between a range get the sales amount grouped by
> > month, but unfortunatelly I was unhappy on this, because this error
> > appeared:
> >
> > global name 'date_created__month' is not defined
> >
> > At date_created is the field where I store the information about when the
> > sale was done., the __moth was a tentative to group by this by month.
> >
> > So, my question: how to do that thing without using a raw sql query and
> not
> > touching on database independence?
> >
> > Thanks so much!
> >
> > Rogério Carrasqueira
> >
> > ---
> > e-mail: rogerio.carrasque...@gmail.com
> > skype: rgcarrasqueira
> > MSN: rcarrasque...@hotmail.com
> > ICQ: 50525616
> > Tel.: (11) 7805-0074
>
> --
> 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.



Registrion activate.html 0.8

2010-11-03 Thread craphunter
Hi,

I am using the registration 0.8 alpha. I can create an account and the
activation email is send the activation link. When I click on the link
the account is getting active in the database but the message on the
webpage is telling me something different.

I do use this template.

{% extends "base.html" %}

{% block title %}Account activated{% endblock %}

{% block content %}
  Account activated.
  {% load humanize %}
  {% if account %}
Thanks for signing up! Now you can log in.
  {% else %}
Sorry, it didn't work. Either your activation link was
incorrect, or
the activation key for your account has expired; activation keys
are
only valid for {{ expiration_days|apnumber }} days after
registration.
  {% endif %}
{% endblock %}


Why doesn't come up the Thanks... text obviously the use is activated
in the database? Do I have to set up something in the configuration
file?

Craphunter

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

2010-11-03 Thread Peter Herndon

On Nov 3, 2010, at 12:31 PM, Sebastian Alonso wrote:

> Hi everyone, I'm a complete django newbie, and I need to use the Auth 
> system. The problem is that I haven't been able to find a good tutorial such 
> as que django one, with all the examples, pretty simple, very easy, with the 
> templates included, etc... My main issue is that i dont get on well with 
> html, so the templates are a complete mistery, and the forms, and everything. 
> The django tutorial provides you with the different templates and everything.
> 
> For example if I search among the other tutorials in the django site, 
> there are tutorials related to the Auth system, but they are somehow more 
> advanced than what I'm looking for. For example there's one on how to expand 
> the user model.. but I dont even know who to use the basic auth system :P
> 
> 
> So, if you know of any tutorial like the one I describe let me know, any link 
> is helpful...

Hi Sebastian,

The documentation for auth is here: 
http://docs.djangoproject.com/en/1.2/topics/auth/

Part of that documentation covers what you need, I think, but it isn't 
necessarily obvious which parts you need just to get started, so here are some 
pointers.  You need to mark the views you want protected with the 
@login_required decorator, as documented here:  
http://docs.djangoproject.com/en/1.2/topics/auth/#the-login-required-decorator

You need to add the login view to your URLs, there's boilerplate for this 
immediately above this link:  
http://docs.djangoproject.com/en/1.2/topics/auth/#django.contrib.auth.views.login

In that same section, but a bit further down, there's a code listing for a 
login template, which should go in registration/login.html.

That should be enough to get you started.  There are more parts to it all, 
which are covered in the auth documentation linked above, but just start with 
the parts I've listed and you will have a decent simple basis for 
authentication within your app.  You can add the other bits and pieces as you 
find you need them (for instance, a logout page, groups and permissions are the 
common ones).

Hope that helps,

---Peter Herndon

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



Why my model doesn't get saved?

2010-11-03 Thread Marc Aymerich
Hi,
I have 2 abstract classes with an overrided save function, class BaseA and
class BaseB. BaseA trigger the models.Model save function, the other
doesn't.

class BaseA(models.Model):
class Meta:
abstract = True

def save(self, *args, **kwargs):
super(BaseA, self).save(*args, **kwargs)


class BaseB(models.Model):
class Meta:
abstract = True

   def save(self, *args, **kwargs):
   pass

Now I define a class that inherits from both of these classes:

class test1(BaseA, BaseB):
integer = models.IntegerField()

and when I save a test1 object it is not saved into the database. The reason
is that BaseB class doesn't call super save function. But actually I don't
see why this fact entails the object isn't saved, because models.Model
function is called through BaseA. What is the reason of this behavior? What
can I do in order to save an object into the db when I inherit from multiple
class and one of them doesn't call the super save function?


Many Thanks!
-- 
Marc

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



static file

2010-11-03 Thread Darvin Willy Cotrina Cervera
hello.

I am working with django and I have the need to handle static files such as
doc, xls, ppt and others, but as private by the user. according to the
documentation says django,  file management makes to the Apache that can be
served. I could give an idea of how I can implement this.

I am sorry my english is very bad.

-- 
Willy

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

2010-11-03 Thread Sebastian Alonso
Thanks a lot peter! I think I'll get started with that info and move further
if needed.

thanks


seba

2010/11/3 Peter Herndon 

>
> On Nov 3, 2010, at 12:31 PM, Sebastian Alonso wrote:
>
> > Hi everyone, I'm a complete django newbie, and I need to use the Auth
> system. The problem is that I haven't been able to find a good tutorial such
> as que django one, with all the examples, pretty simple, very easy, with the
> templates included, etc... My main issue is that i dont get on well with
> html, so the templates are a complete mistery, and the forms, and
> everything. The django tutorial provides you with the different templates
> and everything.
> >
> > For example if I search among the other tutorials in the django site,
> there are tutorials related to the Auth system, but they are somehow more
> advanced than what I'm looking for. For example there's one on how to expand
> the user model.. but I dont even know who to use the basic auth system :P
> >
> >
> > So, if you know of any tutorial like the one I describe let me know, any
> link is helpful...
>
> Hi Sebastian,
>
> The documentation for auth is here:
> http://docs.djangoproject.com/en/1.2/topics/auth/
>
> Part of that documentation covers what you need, I think, but it isn't
> necessarily obvious which parts you need just to get started, so here are
> some pointers.  You need to mark the views you want protected with the
> @login_required decorator, as documented here:
> http://docs.djangoproject.com/en/1.2/topics/auth/#the-login-required-decorator
>
> You need to add the login view to your URLs, there's boilerplate for this
> immediately above this link:
> http://docs.djangoproject.com/en/1.2/topics/auth/#django.contrib.auth.views.login
>
> In that same section, but a bit further down, there's a code listing for a
> login template, which should go in registration/login.html.
>
> That should be enough to get you started.  There are more parts to it all,
> which are covered in the auth documentation linked above, but just start
> with the parts I've listed and you will have a decent simple basis for
> authentication within your app.  You can add the other bits and pieces as
> you find you need them (for instance, a logout page, groups and permissions
> are the common ones).
>
> Hope that helps,
>
> ---Peter Herndon
>
> --
> 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: Admin without template (no colors, no css, just simple html)

2010-11-03 Thread marcoarreguin
I made it!!!

Robbington I'm So glad with you and I want to share how I made it.

I have a bluehost, and after the pain that was to run django finally
via FastCGI, I had a new problem: The media of the admin.

I try with a symlink but it was kind of complicated for me, and don't
understand exactly what I have to do and it failure.

Now, reading Robbington, I try to copy the media directory from /home/
myuserDomain/.local/lib/python2.6/site-packages/django/contrib/admin/
to the public_html... yes, to the public_html, where also I have the
FastCGI file, not to my project directory where I do my django-
admin.py startproject.

And Now is running perfectly!

You know.. I think i would write a blog with all the adventure having
django in the bluehost


Thanks Rob!!!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Why my model doesn't get saved?

2010-11-03 Thread Michael
The reason is because you've declared them both to be abstract, which
means they don't get tables of their own, rather their fields get added
to a non-abstract child model's table.

-- 
Michael 

On Wed, 2010-11-03 at 22:17 +0100, Marc Aymerich wrote:
> Hi,
> I have 2 abstract classes with an overrided save function, class BaseA
> and class BaseB. BaseA trigger the models.Model save function, the
> other doesn't. 
> 
> 
> class BaseA(models.Model):
> class Meta:
> abstract = True
> 
> 
> def save(self, *args, **kwargs):
> super(BaseA, self).save(*args, **kwargs)
> 
> 
> 
> 
> class BaseB(models.Model):
> class Meta:
> abstract = True
>  
>def save(self, *args, **kwargs):
>pass
> 
> 
> Now I define a class that inherits from both of these classes:
> 
> 
> class test1(BaseA, BaseB):
> integer = models.IntegerField()
> 
> 
> and when I save a test1 object it is not saved into the database. The
> reason is that BaseB class doesn't call super save function.
> But actually I don't see why this fact entails the object isn't saved,
> because models.Model function is called through BaseA. What is the
> reason of this behavior? What can I do in order to save an object into
> the db when I inherit from multiple class and one of them doesn't call
> the super save function?
> 
> 
> 
> 
> Many Thanks!
> -- 
> Marc
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-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: Why my model doesn't get saved?

2010-11-03 Thread Michael
nevermind my previous email, I see now you are talking about the test1
class, which isn't abstract.  

In that case I assume the problem is Python's multiple inheritance,
where the first parent it finds with a save() method gets called, and no
others.  It's probably calling BaseB.save(), which does nothing.  If you
want test1.save to call BaseA.save, you'll have to make that explicit:

class test1(BaseA, BaseB):
integer = models.IntegerField()

def save(self, *args, **kargs):
BaseA.save(self, *args, **kargs)


-- 
Michael 

On Wed, 2010-11-03 at 22:17 +0100, Marc Aymerich wrote:
> Hi,
> I have 2 abstract classes with an overrided save function, class BaseA
> and class BaseB. BaseA trigger the models.Model save function, the
> other doesn't. 
> 
> 
> class BaseA(models.Model):
> class Meta:
> abstract = True
> 
> 
> def save(self, *args, **kwargs):
> super(BaseA, self).save(*args, **kwargs)
> 
> 
> 
> 
> class BaseB(models.Model):
> class Meta:
> abstract = True
>  
>def save(self, *args, **kwargs):
>pass
> 
> 
> Now I define a class that inherits from both of these classes:
> 
> 
> class test1(BaseA, BaseB):
> integer = models.IntegerField()
> 
> 
> and when I save a test1 object it is not saved into the database. The
> reason is that BaseB class doesn't call super save function.
> But actually I don't see why this fact entails the object isn't saved,
> because models.Model function is called through BaseA. What is the
> reason of this behavior? What can I do in order to save an object into
> the db when I inherit from multiple class and one of them doesn't call
> the super save function?
> 
> 
> 
> 
> Many Thanks!
> -- 
> Marc
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-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: Why my model doesn't get saved?

2010-11-03 Thread Łukasz Rekucki
On 3 November 2010 22:17, Marc Aymerich  wrote:
> Hi,
> I have 2 abstract classes with an overrided save function, class BaseA and
> class BaseB. BaseA trigger the models.Model save function, the other
> doesn't.
> class BaseA(models.Model):
>     class Meta:
>         abstract = True
>     def save(self, *args, **kwargs):
>         super(BaseA, self).save(*args, **kwargs)
>
> class BaseB(models.Model):
>     class Meta:
>         abstract = True
>
>    def save(self, *args, **kwargs):
>        pass
> Now I define a class that inherits from both of these classes:
> class test1(BaseA, BaseB):
>     integer = models.IntegerField()
> and when I save a test1 object it is not saved into the database. The reason
> is that BaseB class doesn't call super save function. But actually I don't
> see why this fact entails the object isn't saved, because models.Model
> function is called through BaseA. What is the reason of this behavior?

Model.save is never called. The super() in Python doesn't work like
you think. It needs to be a little bit smarter to make multiple
inheritance work, so the anwser is a bit complicated.

Here super() looks at the runtime type of `self`, searches for class
BaseA in it's Method Resolution Order (MRO) and then takes the next
class in that order. So in your code

class test1(BaseA, BaseB):
integer = models.IntegerField()

`test1` will have a MRO of [test1, BaseA, BaseB, Model, ... some
irrelevant django stuff ... , object] (you can also check that with
test1.__mro__). Not going into details, immediate base classes are
always most important with the one on the left side being most
important of them. So, the super().save() in BaseA will call the save
method in BaseB which in turn will do nothing and Model.save() will
never get called.

For more information on MRO you can see the official documentation[1]
or just google for "Python MRO".

> What can I do in order to save an object into the db when I inherit from 
> multiple
> class and one of them doesn't call the super save function?

Fix the class that doesn't call super(). The class should either call
super() or not provide the method at all. Otherwise it won't play well
with inheritance.

You can try changing BaseA.save to call Model.save instead of the
super call, but then BaseA.save will never call BaseB.save if you ever
decide to put any code there.

Sorry, if it's not very clear.

[1]: http://www.python.org/download/releases/2.3/mro/

-- 
Łukasz Rekucki

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



Problem in user MySQL merge table.

2010-11-03 Thread funcrush
Hi all :)
I have a regacy db (4dbs and 8 tables, for distirube data) and wanna
build a web tool for these.
When django 1.1.x released, I sovled "4dbs" problem the multi
database.
But I have the problem yet that "8 tables"

Some months ago, I worte a code like bellow for sovling the problem

class Post(models.Model):
   title = ...
   created_at = ...

   def _save(self):
 self._select_table()
 self.save()
 self._restore_meta()

   def _select_table(self):
 key = 5 # generated by some rules
 self._meta.db_table = "Post%d" % key

   def _restore_meta(self):
  self._meta.db_table = "Post"

   class Meta:
  # Post is a merge table of MySQL
  db_table = 'Post'


And then, I got other problem, "self._meta.db_table" is not attribute
of object, is attribute of Post class!!!
So, aquire lock when call _select_table.

from threading import Lock
class Post(models.Model):
__lock = Lock()

...

def _save(self):
with Post.__lock:
  self._select_table()
  self.save()
  self._restore_meta()


I think this is very poor code!!!
How to use a model with many tables? (same schema..)

Sorry for poor English :(
Any way thanks to read!

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