Re: Query help

2021-09-20 Thread Sean Collins
Add a property to count Y for each column

Or add a computed field that tallies that on save

For reference

https://stackoverflow.com/questions/1454727/do-properties-work-on-django-model-fields


On Mon, Sep 20, 2021 at 6:41 PM J.T.  wrote:

> I have a model called member that has 6  columns: ID, Value1, Value2,
> Value3, Value4, Value5
>
> The values in columns Value1, Value2, Value3, Value4, Value5 are either Y
> or N.
>
> I'm trying to query by ID to count the number of Y values for each member.
>
> For example one row would be: 5, Y, N, Y, N, N
>
> I would like to return: 2 (since that is the number of Y in that member's
> row)
>
> I've tried using Aggregate, Annotate, F, Q, Sum, Count in different ways
> and I'm missing the mark. I've been through the docs and SO for about 2
> hours.
> I would post my errors but it's on my work computer and I have to post
> here from my personal laptop.
>
> I feel like I may be over-thinking it but I can't quite figure it out. Any
> help would be greatly appreciated.
>
> Jason
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/597a0acf-65a0-4e9a-8a9f-b61892860789n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADMeFRHuHw4fvKD76QVu%3D7qch-Vt9S6bK8eMNrQ-H3dN%3D8ZmdA%40mail.gmail.com.


Re: htmx: Has someone already tried this tiny JS library?

2020-08-27 Thread sean li
I personally perfer art template js for loading part of the page without
jumping to another url. the links as below.
http://aui.github.io/art-template/

But you still need to serialize your data to send it to frontend.

guettli  于 2020年8月27日周四 上午6:57写道:

> Today I found htmx  a small JS library which helps you
> to make parts of the page easy to load/submit.
>
> I like it since, I would like to avoid the complicated
> http-API + React/Vue/... approach most people advertise
> these days.
>
> I am curious: Have you tried htmx yet, or how do you
> submit forms without a full page reload?
>
> Regards,
>   Thomas Güttler
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f17a847b-4a1f-4f94-a1cf-5b069c42a9c9n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPkQ_gsf6xDopiR3tA2gNCH6acw%2BqhELTSY7b%2BxZ%3D4CwnrJBRg%40mail.gmail.com.


ASGI alongside mod_wsgi behind an Nginx proxy

2017-09-22 Thread Sean F
d and send-packet message types
  # both have a "text" key for their textual data.
  message.reply_channel.send({
  "text": 'You said %s' % (message.content['text'],),
  })


Like I said, this all works great when I serve the entire project from 
Daphne, but I want mod_wsgi to serve HTTP stuff, as the docs suggest is 
possible.

What am I doing wrong here?

Thanks for reading this far,

Sean

-- 
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/53072bc0-9d1c-4d0d-b1ee-c4b043630660%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django.contrib apps migrations

2016-05-12 Thread Sean McKinley
Django 1.7+ noob here. Are you supposed to to track the migrations 
performed within the django.contrib apps? How do you deploy to production 
on a different machine without grabbing these migrations from the django 
installation?

-- 
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/789f6bf9-ed15-4de7-aaf4-de9caf2178a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: installation steps for django and virtualenv setup.

2016-05-12 Thread Sean McKinley
Download Python of choice. Pip install virtualenv. Pip install Django. Use 
google.

On Thursday, April 7, 2016 at 8:28:53 AM UTC-7, srinivas tummalapalli wrote:
>
> Hi santosh,i installed oracle VM virtual box and linux mint,  can send the 
> installation steps for django and virtualenv setup.
>

-- 
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/8c198c2a-e6d8-4fd3-a6ee-c2cfd57a1444%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 1.8 or 1.9?

2016-05-12 Thread Sean McKinley
I haven't taken the course, but the differences between basic Django 1.8 
and 1.9 are not all that significant and you can find out if you are being 
taught something odd by reviewing 1.9 release notes. Big caveat, syncdb is 
gone in 1.9 so you have to learn migrations if the Udemy course is using 
syncdb.

On Thursday, May 12, 2016 at 8:55:15 AM UTC-7, Ankush Thakur wrote:
>
> I want to take a Udemy course on Django because it shows how to make an 
> e-commerce website. The only catch - it follows Django 1.8. So my question 
> is: Will I be "wasting" my time learning a possibly outdated (or 
> unrecommended) version of Django? I have a feeling the changes aren't going 
> to be that significant, but later on when I recreate the project myself in 
> 1.9, I wouldn't want to tear out my hair solving weird error messages.
>
> Any wise words?
>
> Regards,
> Ankush Thakur
>

-- 
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/28a4674e-c4b3-438d-b04f-785f294a05e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Translation is not working for Template even though po and mo files are created

2015-11-01 Thread Sean Xu
Sorry, 

~/django-swingtime/django-swingtime-master/demo should be the project path 
where project level translation files were generated 
under ~/django-swingtime/django-swingtime-master/demo/locale.
The project level locale files should also be recognized, right?
The application path should 
be ~/django-swingtime/django-swingtime-master/demo/karate.

Br
Sean

On Sunday, November 1, 2015 at 6:09:02 PM UTC+8, Andréas Kühne wrote:
>
> Hi Sean,
>
> That's interesting. You shouldn't have to add the locale paths explicitly. 
> Good that it's wokring, but as long as you put the locale files in a 
> directory named locale under each app and also under the project, it should 
> just work (as long as all apps are included in the config). Just check so 
> that you follow the correct way of setting up a project.
>
> Regards,
>
> Andréas
>
> 2015-11-01 4:27 GMT+01:00 Sean Xu >:
>
>> The translation for my template finally gets to work after I explicitly 
>> have LOCALE_PATHS configured in settings.py!
>> Thanks very much for providing the hint :)
>>
>> Actually the models and template come from different applications:
>>
>> ~/django-swingtime/django-swingtime-master/swingtime # Models come from 
>> this swingtime application where translation worked.
>>
>> ~/django-swingtime/django-swingtime-master/demo # Templates come from 
>> this demo application where translation didn't work previously. (I'm 
>> running the server from demo folder actually... 
>> '~/django-swingtime/django-swingtime-master/demo> python manage.py runserver
>> ')
>> It's weird demo was not recognized while swingtime was recognized for 
>> translation, though.
>>
>> Br
>> Sean
>>
>> On Friday, October 30, 2015 at 9:47:53 PM UTC+8, Andréas Kühne wrote:
>>>
>>> Hmmm
>>>
>>> I'm a bit at a loss here. But does Django know where to find the .mo 
>>> files? Is it only your template that isn't getting translated, because you 
>>> said that the form itself is?
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>> 2015-10-30 12:45 GMT+01:00 Sean Xu :
>>>
>>>> Now I have corrected the orders of each Middleware class and removed 
>>>> the duplicated SessionMiddleware:
>>>> MIDDLEWARE_CLASSES = (
>>>> 'django.contrib.sessions.middleware.SessionMiddleware',
>>>> 'django.middleware.locale.LocaleMiddleware',
>>>> 'django.middleware.common.CommonMiddleware',
>>>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>>> 'django.contrib.messages.middleware.MessageMiddleware',
>>>> )
>>>> I also added django.core.context_processors.i18n as one of the context 
>>>> processors. (I just realized that I'm using Django version 1.7 something 
>>>> so 
>>>> django.template.context_processors.i18n should really be 
>>>> django.core.context_processors.i18n).
>>>> But unfortunately the translation for my template still does not work :(
>>>>
>>>> On Friday, October 30, 2015 at 7:27:36 PM UTC+8, Sean Xu wrote:
>>>>>
>>>>> Hi Andréas,
>>>>>
>>>>> Thanks very much for providing the help.
>>>>> Currently the middleware classes are configured like this:
>>>>>
>>>>> MIDDLEWARE_CLASSES = (
>>>>> 'django.middleware.common.CommonMiddleware',
>>>>> 'django.contrib.sessions.middleware.SessionMiddleware',
>>>>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>>>> 'django.contrib.sessions.middleware.SessionMiddleware',
>>>>> 'django.middleware.locale.LocaleMiddleware',
>>>>> 'django.contrib.messages.middleware.MessageMiddleware',
>>>>> ) 
>>>>>
>>>>>  I guess the order of these middleware is not correct because 
>>>>> LocaleMiddleware should come before CommonMiddleware.
>>>>>
>>>>> I have LANGUAGES defined in settings.py like this:
>>>>> from django.utils.translation import ugettext_lazy as _
>>>>>
>>>>> ...
>>>>> LANGUAGES = (
>>>>>   ('zh', _('Chinese')),
>>>>>   ('en', _('English')),
>>>>> )
>>>>> And I don't have django.templat

Re: Translation is not working for Template even though po and mo files are created

2015-10-31 Thread Sean Xu
The translation for my template finally gets to work after I explicitly 
have LOCALE_PATHS configured in settings.py!
Thanks very much for providing the hint :)

Actually the models and template come from different applications:

~/django-swingtime/django-swingtime-master/swingtime # Models come from 
this swingtime application where translation worked.

~/django-swingtime/django-swingtime-master/demo # Templates come from this 
demo application where translation didn't work previously. (I'm running the 
server from demo folder actually... 
'~/django-swingtime/django-swingtime-master/demo> python manage.py runserver
')
It's weird demo was not recognized while swingtime was recognized for 
translation, though.

Br
Sean

On Friday, October 30, 2015 at 9:47:53 PM UTC+8, Andréas Kühne wrote:
>
> Hmmm
>
> I'm a bit at a loss here. But does Django know where to find the .mo 
> files? Is it only your template that isn't getting translated, because you 
> said that the form itself is?
>
> Regards,
>
> Andréas
>
> 2015-10-30 12:45 GMT+01:00 Sean Xu >:
>
>> Now I have corrected the orders of each Middleware class and removed the 
>> duplicated SessionMiddleware:
>> MIDDLEWARE_CLASSES = (
>> 'django.contrib.sessions.middleware.SessionMiddleware',
>> 'django.middleware.locale.LocaleMiddleware',
>> 'django.middleware.common.CommonMiddleware',
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware',
>> )
>> I also added django.core.context_processors.i18n as one of the context 
>> processors. (I just realized that I'm using Django version 1.7 something so 
>> django.template.context_processors.i18n should really be 
>> django.core.context_processors.i18n).
>> But unfortunately the translation for my template still does not work :(
>>
>> On Friday, October 30, 2015 at 7:27:36 PM UTC+8, Sean Xu wrote:
>>>
>>> Hi Andréas,
>>>
>>> Thanks very much for providing the help.
>>> Currently the middleware classes are configured like this:
>>>
>>> MIDDLEWARE_CLASSES = (
>>> 'django.middleware.common.CommonMiddleware',
>>> 'django.contrib.sessions.middleware.SessionMiddleware',
>>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>> 'django.contrib.sessions.middleware.SessionMiddleware',
>>> 'django.middleware.locale.LocaleMiddleware',
>>> 'django.contrib.messages.middleware.MessageMiddleware',
>>> ) 
>>>
>>>  I guess the order of these middleware is not correct because 
>>> LocaleMiddleware should come before CommonMiddleware.
>>>
>>> I have LANGUAGES defined in settings.py like this:
>>> from django.utils.translation import ugettext_lazy as _
>>>
>>> ...
>>> LANGUAGES = (
>>>   ('zh', _('Chinese')),
>>>   ('en', _('English')),
>>> )
>>> And I don't have django.template.context_processors.i18n defined for 
>>> TEMPLATE_CONTEXT_PROCESSORS in settings.py. Do I need to add this i18n 
>>> context processor to settings.py?
>>>
>>> Br
>>> Sean
>>>
>>> On Friday, October 30, 2015 at 6:07:21 PM UTC+8, Andréas Kühne wrote:
>>>>
>>>> Hi,
>>>>
>>>> Have you made sure that you have activated the languages you want in 
>>>> your application? 
>>>> Also, how is the current language being selected?
>>>> See: 
>>>> https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#how-django-discovers-language-preference
>>>>
>>>> Regards,
>>>>
>>>> Andréas
>>>>
>>>> 2015-10-30 7:45 GMT+01:00 Sean Xu :
>>>>
>>>>> Hi,
>>>>>
>>>>> I'm learning Django Translation using django-swingtime with Django 
>>>>> 1.7.9 installed.
>>>>> I followed the official docs and embedded my string to translate with 
>>>>> {% trans "String to translate" %} in my Template and 
>>>>> managed 
>>>>> to create both the po and mo files successfully.
>>>>> But, the page is still shown up in English.
>>>>> Note: the translation works just fine for my models.
>>>>>
>>>>> Partly of the template I was using can be found from below:
>

Re: Translation is not working on ModelForm when widget is specified for form field

2015-10-30 Thread Sean Xu
Hi Andréas,

I have now applied your second approach and now the field names get 
translated into Chinese as expected...
Thanks so much.

On Friday, October 30, 2015 at 6:12:21 PM UTC+8, Andréas Kühne wrote:
>
> Hi,
>
> The problem is that you are redifining the fields, the fields then don't 
> get any labels (because you haven't specified them). You can achieve what 
> you want in two ways:
>
> Either add the following to your modelform:
> start_time = forms.DateTimeField(label=_("start time"), 
> widget=SplitDateTimeWidget)
> end_time = forms.DateTimeField(label=_("end time"), 
> widget=SplitDateTimeWidget)
>
> But I would much rather remove the start_time / end_time definitions in 
> your model form and instead add this under the "class Meta:" heading:
> widgets = {
> 'start_time': SplitDateTimeWidget,
> 'end_time': SplitDateTimeWidget,
> }
>
> That way you don't have to add the labels once more, but just use them 
> from the model instead.
>
> Regards,
>
> Andréas
>
> 2015-10-30 7:21 GMT+01:00 Sean Xu >:
>
>> Hi,
>>
>> I was learning Django Translation using django-swingtime as project with 
>> Django 1.7.9 installed.
>> And I found out when Non-default widgets was originally specified for 
>> form fields, the preferred language did not show up from my Firefox browser.
>> The problem has gone when these widgets were removed.
>> I'm not sure if this is a bug of Django or was there anything I did wrong.
>>
>> Note: po and mo file can be created correctly with or without the widgets 
>> in place.
>>
>> You can find the Model definition from below:
>> class Occurrence(models.Model):
>> '''
>> Represents the start end time for a specific occurrence of a master 
>> ``Event``
>> object.
>> '''
>> start_time = models.DateTimeField(_('start time'))
>> end_time = models.DateTimeField(_('end time'))
>> event = models.ForeignKey(Event, verbose_name=_('event'), editable=
>> False)
>> notes = GenericRelation(Note, verbose_name=_('notes'))
>>
>>
>> objects = OccurrenceManager()
>>
>>
>> 
>> #===
>> class Meta:
>> verbose_name = _('occurrence')
>> verbose_name_plural = _('occurrences')
>> ordering = ('start_time', 'end_time')
>>
>>
>> And the ModelForm is defined as follows:
>> class SingleOccurrenceForm(forms.ModelForm):
>> '''
>> A simple form for adding and updating single Occurrence attributes
>>
>>
>> '''
>>
>>
>> start_time = forms.DateTimeField(widget=SplitDateTimeWidget)
>> end_time = forms.DateTimeField(widget=SplitDateTimeWidget)
>> # Translation works if these 2 lines get removed
>>
>>
>> 
>> #===
>> class Meta:
>> model = Occurrence
>> if FIELDS_REQUIRED:
>> fields = "__all__"
>>
>>
>> Br
>> Sean
>>
>> -- 
>> 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/52a50110-4c9d-4f71-9ebf-6ade058fa47e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/52a50110-4c9d-4f71-9ebf-6ade058fa47e%40googlegroups.com?utm_medium=email&utm_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/d350c903-7285-4932-8c9f-0c5c1a4407f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Translation is not working for Template even though po and mo files are created

2015-10-30 Thread Sean Xu
Now I have corrected the orders of each Middleware class and removed the 
duplicated SessionMiddleware:
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
I also added django.core.context_processors.i18n as one of the context 
processors. (I just realized that I'm using Django version 1.7 something so 
django.template.context_processors.i18n should really be 
django.core.context_processors.i18n).
But unfortunately the translation for my template still does not work :(

On Friday, October 30, 2015 at 7:27:36 PM UTC+8, Sean Xu wrote:
>
> Hi Andréas,
>
> Thanks very much for providing the help.
> Currently the middleware classes are configured like this:
>
> MIDDLEWARE_CLASSES = (
> 'django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.locale.LocaleMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> ) 
>
>  I guess the order of these middleware is not correct because 
> LocaleMiddleware should come before CommonMiddleware.
>
> I have LANGUAGES defined in settings.py like this:
> from django.utils.translation import ugettext_lazy as _
>
> ...
> LANGUAGES = (
>   ('zh', _('Chinese')),
>   ('en', _('English')),
> )
> And I don't have django.template.context_processors.i18n defined for 
> TEMPLATE_CONTEXT_PROCESSORS in settings.py. Do I need to add this i18n 
> context processor to settings.py?
>
> Br
> Sean
>
> On Friday, October 30, 2015 at 6:07:21 PM UTC+8, Andréas Kühne wrote:
>>
>> Hi,
>>
>> Have you made sure that you have activated the languages you want in your 
>> application? 
>> Also, how is the current language being selected?
>> See: 
>> https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#how-django-discovers-language-preference
>>
>> Regards,
>>
>> Andréas
>>
>> 2015-10-30 7:45 GMT+01:00 Sean Xu :
>>
>>> Hi,
>>>
>>> I'm learning Django Translation using django-swingtime with Django 1.7.9 
>>> installed.
>>> I followed the official docs and embedded my string to translate with 
>>> {% trans "String to translate" %} in my Template and managed 
>>> to create both the po and mo files successfully.
>>> But, the page is still shown up in English.
>>> Note: the translation works just fine for my models.
>>>
>>> Partly of the template I was using can be found from below:
>>> {% extends "base.html" %}
>>> {% load url from future %}
>>> {% load i18n %}
>>> {% block title %}Event Occurrence{% endblock %}
>>> {% block main_content %}
>>>  {% trans "Swingtime Event Occurrence" %}
>>>  
>>>  {{ occurrence
>>> .title }}
>>>  –
>>>  {% with occurrence.start_time as st  %}
>>>  
>>> {{ st|date:"l, F jS P" }}
>>> 
>>> {% endwith %}
>>>  
>>>  {% trans "Event type:" %}
>>>  {{ occurrence.event.event_type }}
>>>
>>> The subroutine to render my Template is:
>>>
>>> #---
>>> def occurrence_view(
>>> request,
>>> event_pk,
>>> pk,
>>> template='swingtime/occurrence_detail.html',
>>> form_class=forms.SingleOccurrenceForm
>>> ):
>>> '''
>>> View a specific occurrence and optionally handle any updates.
>>> 
>>> Context parameters:
>>> 
>>> ``occurrence``
>>> the occurrence object keyed by ``pk``
>>>
>>>
>>> ``form``
>>> a form object for updating the occurrence
>>> '''
>>>   
>>> occurrence = get_object_or_404(Occurrence, pk=pk, event__pk=event_pk
>>> )
>>> if request.method == 'POST':
>>> form = form_class(request.POST, instance=

Re: Translation is not working for Template even though po and mo files are created

2015-10-30 Thread Sean Xu
Hi Andréas,

Thanks very much for providing the help.
Currently the middleware classes are configured like this:

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
) 

 I guess the order of these middleware is not correct because 
LocaleMiddleware should come before CommonMiddleware.

I have LANGUAGES defined in settings.py like this:
from django.utils.translation import ugettext_lazy as _

...
LANGUAGES = (
  ('zh', _('Chinese')),
  ('en', _('English')),
)
And I don't have django.template.context_processors.i18n defined for 
TEMPLATE_CONTEXT_PROCESSORS in settings.py. Do I need to add this i18n 
context processor to settings.py?

Br
Sean

On Friday, October 30, 2015 at 6:07:21 PM UTC+8, Andréas Kühne wrote:
>
> Hi,
>
> Have you made sure that you have activated the languages you want in your 
> application? 
> Also, how is the current language being selected?
> See: 
> https://docs.djangoproject.com/en/1.8/topics/i18n/translation/#how-django-discovers-language-preference
>
> Regards,
>
> Andréas
>
> 2015-10-30 7:45 GMT+01:00 Sean Xu >:
>
>> Hi,
>>
>> I'm learning Django Translation using django-swingtime with Django 1.7.9 
>> installed.
>> I followed the official docs and embedded my string to translate with 
>> {% trans "String to translate" %} in my Template and managed 
>> to create both the po and mo files successfully.
>> But, the page is still shown up in English.
>> Note: the translation works just fine for my models.
>>
>> Partly of the template I was using can be found from below:
>> {% extends "base.html" %}
>> {% load url from future %}
>> {% load i18n %}
>> {% block title %}Event Occurrence{% endblock %}
>> {% block main_content %}
>>  {% trans "Swingtime Event Occurrence" %}
>>  
>>  {{ 
>> occurrence.title 
>> }}
>>  –
>>  {% with occurrence.start_time as st  %}
>>  
>> {{ st|date:"l, F jS P" }}
>> 
>> {% endwith %}
>>  
>>  {% trans "Event type:" %}
>>  {{ occurrence.event.event_type }}
>>
>> The subroutine to render my Template is:
>>
>> #---
>> def occurrence_view(
>> request,
>> event_pk,
>> pk,
>> template='swingtime/occurrence_detail.html',
>> form_class=forms.SingleOccurrenceForm
>> ):
>> '''
>> View a specific occurrence and optionally handle any updates.
>> 
>> Context parameters:
>> 
>> ``occurrence``
>> the occurrence object keyed by ``pk``
>>
>>
>> ``form``
>> a form object for updating the occurrence
>> '''
>>   
>> occurrence = get_object_or_404(Occurrence, pk=pk, event__pk=event_pk)
>> if request.method == 'POST':
>> form = form_class(request.POST, instance=occurrence)
>> if form.is_valid():
>> form.save()
>> return http.HttpResponseRedirect(request.path)
>> else:  
>> form = form_class(instance=occurrence)
>> 
>> return render(request, template, {'occurrence': occurrence, 'form': 
>> form})
>>
>> And the url configuration associated with the Template reads:
>> url(
>> r'^events/(\d+)/(\d+)/$', 
>> views.occurrence_view, 
>> name='swingtime-occurrence'
>> ),
>>
>> Could some one help me solve this problem?
>> Thanks very much
>>
>> Br
>> Sean
>>
>> -- 
>> 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/a45afc10-97ad-4574-b541-14ff67e892cd%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/a45afc10-97ad-4574-b541-14ff67e892cd%40googlegroups.com?utm_medium=email&utm_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/20d057f4-bad2-4dc2-9827-43451cf5f832%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Translation is not working on ModelForm when widget is specified for form field

2015-10-30 Thread Sean Xu
Hi,

I was learning Django Translation using django-swingtime as project with 
Django 1.7.9 installed.
And I found out when Non-default widgets was originally specified for form 
fields, the preferred language did not show up from my Firefox browser.
The problem has gone when these widgets were removed.
I'm not sure if this is a bug of Django or was there anything I did wrong.

Note: po and mo file can be created correctly with or without the widgets 
in place.

You can find the Model definition from below:
class Occurrence(models.Model):
'''
Represents the start end time for a specific occurrence of a master 
``Event``
object.
'''
start_time = models.DateTimeField(_('start time'))
end_time = models.DateTimeField(_('end time'))
event = models.ForeignKey(Event, verbose_name=_('event'), editable=False
)
notes = GenericRelation(Note, verbose_name=_('notes'))


objects = OccurrenceManager()



#===
class Meta:
verbose_name = _('occurrence')
verbose_name_plural = _('occurrences')
ordering = ('start_time', 'end_time')


And the ModelForm is defined as follows:
class SingleOccurrenceForm(forms.ModelForm):
'''
A simple form for adding and updating single Occurrence attributes


'''


start_time = forms.DateTimeField(widget=SplitDateTimeWidget)
end_time = forms.DateTimeField(widget=SplitDateTimeWidget)
# Translation works if these 2 lines get removed



#===
class Meta:
model = Occurrence
if FIELDS_REQUIRED:
fields = "__all__"


Br
Sean

-- 
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/52a50110-4c9d-4f71-9ebf-6ade058fa47e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Translation is not working for Template even though po and mo files are created

2015-10-30 Thread Sean Xu
Hi,

I'm learning Django Translation using django-swingtime with Django 1.7.9 
installed.
I followed the official docs and embedded my string to translate with 
{% trans "String to translate" %} in my Template and managed 
to create both the po and mo files successfully.
But, the page is still shown up in English.
Note: the translation works just fine for my models.

Partly of the template I was using can be found from below:
{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% block title %}Event Occurrence{% endblock %}
{% block main_content %}
 {% trans "Swingtime Event Occurrence" %}
 
 {{ occurrence.title 
}}
 –
 {% with occurrence.start_time as st  %}
 
{{ st|date:"l, F jS P" }}

{% endwith %}
 
 {% trans "Event type:" %}
 {{ occurrence.event.event_type }}

The subroutine to render my Template is:
#---
def occurrence_view(
request,
event_pk,
pk,
template='swingtime/occurrence_detail.html',
form_class=forms.SingleOccurrenceForm
):
'''
View a specific occurrence and optionally handle any updates.

Context parameters:

``occurrence``
the occurrence object keyed by ``pk``


``form``
a form object for updating the occurrence
'''
  
occurrence = get_object_or_404(Occurrence, pk=pk, event__pk=event_pk)
if request.method == 'POST':
form = form_class(request.POST, instance=occurrence)
if form.is_valid():
form.save()
return http.HttpResponseRedirect(request.path)
else:  
form = form_class(instance=occurrence)

return render(request, template, {'occurrence': occurrence, 'form': form
})

And the url configuration associated with the Template reads:
url(
r'^events/(\d+)/(\d+)/$', 
    views.occurrence_view, 
name='swingtime-occurrence'
),

Could some one help me solve this problem?
Thanks very much

Br
Sean

-- 
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/a45afc10-97ad-4574-b541-14ff67e892cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Testing Migrations (django 1.7)?

2015-03-16 Thread Sean Briceland
Hi all,
Previous to Django 1.7, I had a nifty solution for testing south Migrations.

I'd basically get a list of migrations for an app via:
migrations = Migrations('some_app')

Then to get the ORM at a given point in migrations:
orm_at_migration = migrations['000X_name_of_migration'].orm()

I could then use call_command to perform a migration and assert using the 
state-based orm's.

In Django 1.7, I haven't found a way to get the ORM at a given point in 
migrations. If anyone has any ideas or experience in this area, I would 
greatly appreciate a nudge in the right direction.

Thanks

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


Re: Is there anyone whos used Django with webfaction that has made there own tutorial ?

2015-02-15 Thread Sean Fulmer
On Saturday, February 14, 2015 at 2:11:50 PM UTC-7, djangocharm2020 wrote:
>
> seem to be having issues with it one question if anyone has if you make a 
> new project from scratch do you still need to use the virtualenv to create 
> a project 
>

No, you don't need to use virtualenv with WebFaction's Django setup.

WebFaction's own Django documentation shows you how to create a new project 
within a Django installation installed via their control panel:

cd ~/webapps/name_of_django_install
./bin/django-admin.py startproject whatever

More information is available 
here: http://docs.webfaction.com/software/django/getting-started.html

Hope that helps!

-- 
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/ac8f3166-9a37-47f4-8021-e6a464009784%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django newbie frustrated

2014-02-12 Thread Sean Luke
It gives me an error saying unresolved reference.  I will try the django 
tutorial.

-- 
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/6d8bb317-acfc-4b06-aa7b-646d2ba4e083%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django newbie frustrated

2014-02-12 Thread Sean Luke
models.py

from django.db import models

# Create your models here.


class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')


class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()

views.py 

from django.shortcuts import render

# Create your views here.
from django.shortcuts import render_to_response


def index(request):
return render_to_response('index.html')


def detail(request, poll_id):
return render_to_response('detail.html')


def results(request, poll_id):
return render_to_response('results.html')


def vote(request, poll_id):
return render_to_response('vote.html')

-- 
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/a1164929-b6aa-4ca8-8dd1-6012a05dfb50%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django newbie frustrated

2014-02-12 Thread Sean Luke
Here is settings.py


"""

Django settings for MyDjangoApp project.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '1xcp91qi*estwvv$0_z@=9z+w98evzcdk*!psi@-pha_4&j5v_'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'MyDjangoApp.urls'

WSGI_APPLICATION = 'MyDjangoApp.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/static/'


On Wednesday, February 12, 2014 1:21:53 PM UTC-6, Lucas Klassmann wrote:
>
> Hi Sean!
>
> You has added *polls* inside of *INSTALLED_APPS* in the *settings.py*?
>
> You can show me other source files?
>
> Greetings
>
>
> On Wed, Feb 12, 2014 at 5:13 PM, Sean Luke <192.se...@gmail.com
> > wrote:
>
>> Here is the screenshot of my file structure and admin.py
>>
>>
>> On Wednesday, February 12, 2014 1:05:28 PM UTC-6, Sean Luke wrote:
>>
>>> I have just installed pycharm and django.  And i followed the pycharm 
>>> tutorial for creating your first app (http://www.jetbrains.com/
>>> pycharm/quickstart/django_guide.html).  But now when I run the app I 
>>> get this error in my browser.
>>>
>>> Page not found (404)  Request Method: GET  Request URL: 
>>> http://127.0.0.1:8000/  
>>>  
>>> Using the URLconf defined in MyDjangoApp.urls, Django tried these URL 
>>> patterns, in this order: 
>>>
>>>1. ^polls/$ 
>>>2. ^admin/ 
>>>
>>> The current URL, , didn't match any of these.
>>>
>>>
>>> My url.py file looks like this: 
>>> from django.conf.urls import patterns, include, url
>>>
>>> from django.contrib import admin
>>> admin.autodiscover()
>>>
>>>
>>> urlpatterns = patterns('',
>>>
>>> # url(r'^$', 'MyDjangoApp.views.home', name='home'),
>>> # url(r'^blog/', include('blog.urls')),
>>>
>>> (r'^polls/$', 'MyDjangoApp.polls.views.index'),
>>> # (r'^polls/(?P\d+)/$', 'MyDjangoApp.polls.views.detail'),
>>> # (r'^polls/(?P\d+)/results/$', 'MyDjangoApp.polls.views.
>>> results'),
>>>     # (r'^polls/(?P\d+)/vote/$', 'MyDjangoApp.polls.views.vote'
>>> ),
>>> (r'^admin/', include(admin.site.urls)),
>>>
>>> #url(r'^admin/', include(admin.site.urls)),
>>> )
>>>
>>> When I comment the (r^polls/$,'MyDangoApp.vie...) line it 
>>> works fine.  With it uncommented it doesn't work and if I try entering 
>>> /admin at the end of the url i get this error:
>>>
>>> ImportError at /admin/ 
>>>
>>> No module named polls
>>>
>>>  Request Method: GET 

Re: Output of form in Extjs

2013-12-16 Thread Sean
Hi JJ,

I am very interested in the django form output in ExtJS style, has your 
code been upload somewhere I can have a look, such as github?
Also, my email address is liushu2...@gmail.com

Thanks,
Sean

On Tuesday, 4 September 2012 20:05:01 UTC+1, JJ wrote:
>
> Hi all,
> I created parse django to extjs in modelforms and forms. Basically works 
> as form.as_p but is form.extjs_output. I mapped all widgets fields to 
> extjs. I would like to submit this code to django-project. What do you 
> think?
> Thank you.
>
> João Júnior
>

-- 
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/f7c5db94-aad9-4570-9c71-60c28c504364%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django for corporate web site

2013-08-05 Thread sean chen
I need to build a site for a small law firm. I looked at the poweredby 
pages http://www.djangosites.org/, but I found it shows sites for different 
purposes and I did not find a good example site for me to spark my thoughts 
further.

I see there exists a focus area for e-commerce site at 
https://www.djangopackages.com/grids/g/ecommerce/, is there a focus area 
for corporate websites?

Thanks,
Sean

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Avoiding huge IDs after deleting data

2013-08-05 Thread Sean Whalen
How can the models be configured to use bigserial? I know I could convert
the tables myself, but that is not helpful for distributing the app.

It looks like someone requested that feature three years ago.

https://code.djangoproject.com/ticket/14286


On Mon, Aug 5, 2013 at 5:36 PM, Javier Guerra Giraldez
wrote:

> On Mon, Aug 5, 2013 at 4:26 PM, Sean Whalen  wrote:
> > However, because the Django ORM uses the SERIAL data type to store the
> IDs
> > in the DB; the IDs get larger, even when all existing records have been
> > deleted. Eventually, I will run out of key space. What can I do to make
> > Django produce smaller ID values?
>
>
> instead of "producing smaller ID values" (which could potentially
> collide if you decide to keep a few "old" records), try switching to
> bigserial.  even if you get a million requests per day, producing a
> billion new records, you won't exhaust the keyspace before several
> billion days (almost 50 million years from now)
>
> --
> Javier
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/Ro7TOBuBEQg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Avoiding huge IDs after deleting data

2013-08-05 Thread Sean Whalen
I have a Django/PostgreSQL application to analyze data from tweets. The 
dataset increases by thousands of records with each request. I am using the 
database primarily as a relational cache, so I had planned to delete all 
records every 24 hours to permit new requests, without needlessly 
increasing the size of the database.

However, because the Django ORM uses the 
SERIALdata
 type to store the IDs in the DB; the IDs get larger, even when all 
existing records have been deleted. Eventually, I will run out of key 
space. What can I do to make Django produce smaller ID values?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Announcing DjangoNYC Office Hours

2012-09-29 Thread Sean O'Connor
 

Hello Everybody,

Tomorrow I'll be running a bit of an experiment on Google+.  The basic idea 
is that I'll be available on a Google Hangout for an hour or two tomorrow 
afternoon answering any Django questions that you might have.

If your interested in asking questions, join the hangout and ask away. 
 Otherwise, it might be interesting to just watch the hang out and see what 
you can learn from other people's questions.

You can join the office hours over at http://bit.ly/SauDRO.

If you have any questions, have any feedback, or run into any problems, 
please feel free to let me know.

Thanks!

____

Sean O'Connor
http://seanoc.com

-- 
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/-/FpF0cRXZtg8J.
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: Choosing a Django-based CMS

2012-08-06 Thread Sean O'Brian
Thanks all.
As I get, I should try both Mezzazine and FeinCMS.
May be they're have another advantages and disadvantages.

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



Choosing a Django-based CMS

2012-08-05 Thread Sean O'Brian
Hi!
I'm using Django CMS for a few of weeks and I like it. But there's one 
problem, which I already ran into: I can't extend Page model easily.
I found one tutorial, 
but this not seem to be very developer-friendly and author said that it's 
produces overwhelming SQL queries.
There's a lot of comparisons in the web, but most of them are old, and as I 
noticed on github, the main competitors (FeinCMS and Mezzazine) was 
actively developed last months.
Can you advice a mature and extensible CMS? The main requirement is 
extending pages, for avatars for example.

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



DjangoCon US CfP Closes Tomorrow

2012-06-15 Thread Sean O'Connor
Hey Everybody,

Just a quick heads up that the call for talk and tutorial proposals for 
DjangoCon US 2012 closes tomorrow.  You can find all of the details on this 
year's conference along with the form to submit a proposal at 
http://www.djangocon.us/.

If you have any questions or feedback please feel free to let me know at 
s...@seanoc.com.

Thanks!

-- 
Sean O'Connor
http://www.seanoc.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.



DjangoCon US Accepting Talk and Tutorial Proposals

2012-05-29 Thread Sean O'Connor
Hey Everybody,

DjangoCon US is now accepting talk and tutorial proposals for this year's 
conference.  Proposals are open now until Saturday 6/16.  Check 
outDjangoCon.US<http://djangocon.us/blog/2012/05/29/welcome-djangocon-2012/>for 
all of the details.

If you have any questions or run into any problems, please let me know at 
s...@seanoc.com.

Thanks!

Sean O'Connor
DjangoCon US Community Chair

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



GeoDjango and pyspatialite

2011-08-10 Thread Sean
GeoDjango normally looks for libspatialite for Spatialite
functionality.

I want to use, instead, pyspatialite which has the spatialite
functions built into the sqlite3 library.  I changed the reference in
the standard sqlite3 backend base.py to use pyspatialite instead of
pysqlite2/sqlite3.

I tried changing the base.py for the spatialite base.py in contrib.gis
to look for the sqlite3 library but that didn't work. I'm sure it's a
bad idea anyway to have it load the sqlite3 lib again.

Has anyone found a way to get GeoDjango to pyspatialite?

Thanks,

  Sean

-- 
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: Want to give a talk at Djangocon, the time to submit is now

2011-06-22 Thread Sean O'Connor
Not by the organizers of Djangocon.US. So far, each of the regional conferences 
(djangocon.us, djangocon.eu, djangoski, etc) have been organized by independent 
organizations. That being said, we do all collaborate to some extent. Should 
anybody be interested in organizing a Djangocon in Asia, I and I'm sure other 
organizers would be happy to provide guidance and support in what ever ways we 
can.

-- 
Sean O'Connor
http://www.seanoc.com

On Wednesday, June 22, 2011 at 12:15 PM, Addy Yeow wrote:

> Any plan to host Djangcon in Asia?
> 
> On Thu, Jun 23, 2011 at 12:08 AM, Sean O'Connor  (mailto:sean.b.ocon...@gmail.com)> wrote:
> > Hey Everybody,
> > 
> > I know we're a bit late this year but the new Djangocon.US 
> > (http://Djangocon.US) site is finally up and we are accepting talk 
> > proposals today. 
> > 
> > Unfortunately, thanks to our lateness we will only be able to accept 
> > proposals for the next two weeks. This means if you want to have a chance 
> > to speak at this year's Djangocon, you need to get your proposal in ASAP. 
> > 
> > You can read more about submitting a proposal at 
> > http://djangocon.us/blog/2011/06/22/call-papers/ and feel free to contact 
> > me directly if you have any questions or concerns. 
> > 
> > -Sean O'Connor
> > s...@seanoc.com (mailto:s...@seanoc.com)
> > 
> >  -- 
> >  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/-/5cZtk6GOBNIJ.
> >  To post to this group, send email to django-users@googlegroups.com 
> > (mailto:django-users@googlegroups.com).
> >  To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com 
> > (mailto:django-users%2bunsubscr...@googlegroups.com).
> >  For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> -- 
> http://www.dazzlepod.com . http://twitter.com/dazzlepod
>  We write elegant and minimal apps that works. We develop web apps with 
> Django framework.
>  -- 
>  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 
> (mailto:django-users@googlegroups.com).
>  To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com 
> (mailto: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.



Want to give a talk at Djangocon, the time to submit is now

2011-06-22 Thread Sean O'Connor
Hey Everybody,

I know we're a bit late this year but the new Djangocon.US site is finally 
up and we are accepting talk proposals today.

Unfortunately, thanks to our lateness we will only be able to accept 
proposals for the next* *two weeks.  This means if you want to have a chance 
to speak at this year's Djangocon, you need to get your proposal in ASAP.

You can read more about submitting a proposal 
at http://djangocon.us/blog/2011/06/22/call-papers/ and feel free to contact 
me directly if you have any questions or concerns.

-Sean O'Connor
s...@seanoc.com

-- 
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/-/5cZtk6GOBNIJ.
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: Annotate with a filtered Count

2011-05-25 Thread Sean McArthur
I would be very interested to know if there is a way to do this using 
Django's Aggregation API. For now, the only solution I can come up with is 
having to use a fat .extra() call.

-- 
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: Encrpting urls to hide PKs

2011-05-10 Thread Sean Brant




On May 10, 2011, at 4:02 PM, "Cal Leeming [Simplicity Media 
Ltd]" wrote:

> Sean, are you suggesting that the OP rely on base36 encoding for security? 
> Please tell me you are joking.

No not at all, I thought he stated this does not have to be secure.

If it does, then yeah my code is a bad idea. If security is a issue this should 
be behind a password.

> On 10/05/2011 15:32, Sean Brant wrote:
>> Sorry I think I only responded to the original poster.
>> 
>> >>>  from django.utils.http import int_to_base36, base36_to_int
>> >>>  int_to_base36(123)
>> '3f'
>> >>>  base36_to_int('3f')
>> 123
>> 
>> Sean
>> 
> 

-- 
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: Encrpting urls to hide PKs

2011-05-10 Thread Sean Brant
Sorry I think I only responded to the original poster.

>>> from django.utils.http import int_to_base36, base36_to_int
>>> int_to_base36(123)
'3f'
>>> base36_to_int('3f')
123

Sean

-- 
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 should I properly impliment HTTP(S) auth (REMOTE_AUTH) in django?

2011-02-09 Thread Sean W
The relays would operate garage doors. So, I want the user to be able to be 
able to quickly and securely launch the application and operate the doors. I 
would like to have a system which is almost as easy to use as an existing 
opener, but with additional features:

 

- Check the door status from anywhere*

- Logging

- User, group, and time-based authentication

- Without decreasing security (if anything, I want to improve it)

 

* I would only allow the user to operate the door if he/she is in close 
geographic location compared to the door, for safety reasons.

 

I looked into OAuth, but it does not seem to fit my use-case well.

 
I wonder how difficult it would be to implement PKI auth for this 
application…

On Wednesday, February 9, 2011 12:06:36 AM UTC-5, Eric wrote:

>  I wouldn't consider using a UUID as multi-factor authentication.
>
> All our API traffic is over https.  We use the basic authentication 
> included with django-piston.
>
> Any reason why you want to exchange username and password for an API Key? 
>  Why not just authenticate each request with username and password?
>
>
>
>  On Feb 8, 2011, at 5:37 PM, Sean W wrote:
>
> This is a re-post of my stack overflow question here 
> http://stackoverflow.com/questions/4939908/how-should-i-properly-impliment-https-auth-remote-auth-in-django
>   
>   Hi,
>
> I am in the planning phase a new project. I want to be able to control 
> multiple relays from my android powered phone over the internet. I need to 
> use an HTTP based server as a middleman between the phone and the relays. 
> Django is my preferred platform because Python is my strongest skill set. 
> This would not be a "web app" (with the exception of the admin interface for 
> managing the user and their access to the relays). Rather, the server would 
> simply provide an API in the form of HTTPS requests and JSON encoding. 
> Though, I should note that I have never done any web development in my life, 
> so I don't know best practices (yet). The authentication method should meet 
> the following criteria:
>
>- Works over HTTPS (self-signed SSL) 
>- Provides multi-factor authentication (in the form of something you 
>have and something you know) 
>- Be reasonably secure (Would be very difficult to fool, guess at. or 
>otherwise bypass) 
>- Is simple in implementation for the server operator and end user on 
>the mobile client 
>- 
>
>Is lightweight in in terms of both CPU cycles and bandwidth
>
>I plan to use the following scheme to solve this:
> 1. An administrator logs into the web interface, creates a user, and 
>   sets up his/her permissions (including a username and a password chosen 
> by 
>   the user). 
>   2. The user starts the client, selects add server, and enters the 
>   server URL and his/her credentials. 
>   3. The client attempts to authenticate the the user via HTTP auth 
>   (over SSL). If the authentication was successful, the server will 
> generate 
>   an API key in the form of a UUID and sends it to the client. The client 
> will 
>   save this key and use it in all API calls over HTTPS. HTTP auth is only 
> used 
>   for the initial authentication process prior to reviving a key, as a 
> session 
>   scheme would not be nessessary for this application. Right? The client 
> will 
>   only work if the phone is configured to automatically lock with a PIN 
> or 
>   pattern after a short timeout. The server will only allow one key to be 
>   generated per user, unless an administrator resets the key. Hence, 
> simple, 
>   mobile, multifactor authentication.
>
> Is this sound from a security standpoint? Also, can anyone point me to an 
> example of how to use the HTTP auth that is built into Django? From a Google 
> search, I can find a lot of snipits witch hack the feature together. But, 
> none of them implement HTTP auth in the wayit was added to Django in 
> 1.1<http://code.djangoproject.com/ticket/689>. 
> The official documentation for REMOTE_AUTH can be found 
> here<http://docs.djangoproject.com/en/1.2/howto/auth-remote-user/>, 
> but I am having difficulty understanding the documentation as I am very new 
> to Django.
>
>
>

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



Re: How should I properly impliment HTTP(S) auth (REMOTE_AUTH) in django?

2011-02-09 Thread Sean W
 

The relays wound operate garage doors. So, I want the user to be able to be 
able to quickly and securely launch the application and operate the doors. I 
would like to have a system which is almost as easy to use as an existing 
opener, but with additional features:

 

- Check the door status from anywhere*

- Logging

- User, group, and time-based authentication

- Without decreasing security (if anything, I want to improve it)

 

* I would only allow the user to operate the door if he/she is in close 
geographic location compared to the door, for safety reasons.

 

I looked into OAuth, but it does not seem to fit my use-case well.

 

I wonder how difficult it would be to implement PKI auth for this 
application…


On Wednesday, February 9, 2011 12:06:36 AM UTC-5, Eric wrote:

>  I wouldn't consider using a UUID as multi-factor authentication.
>
> All our API traffic is over https.  We use the basic authentication 
> included with django-piston.
>
> Any reason why you want to exchange username and password for an API Key? 
>  Why not just authenticate each request with username and password?
>
>
>
>  On Feb 8, 2011, at 5:37 PM, Sean W wrote:
>
> This is a re-post of my stack overflow question here 
> http://stackoverflow.com/questions/4939908/how-should-i-properly-impliment-https-auth-remote-auth-in-django
>   
>   Hi,
>
> I am in the planning phase a new project. I want to be able to control 
> multiple relays from my android powered phone over the internet. I need to 
> use an HTTP based server as a middleman between the phone and the relays. 
> Django is my preferred platform because Python is my strongest skill set. 
> This would not be a "web app" (with the exception of the admin interface for 
> managing the user and their access to the relays). Rather, the server would 
> simply provide an API in the form of HTTPS requests and JSON encoding. 
> Though, I should note that I have never done any web development in my life, 
> so I don't know best practices (yet). The authentication method should meet 
> the following criteria:
>
>- Works over HTTPS (self-signed SSL) 
>- Provides multi-factor authentication (in the form of something you 
>have and something you know) 
>- Be reasonably secure (Would be very difficult to fool, guess at. or 
>otherwise bypass) 
>- Is simple in implementation for the server operator and end user on 
>the mobile client 
>- 
>
>Is lightweight in in terms of both CPU cycles and bandwidth
>
>I plan to use the following scheme to solve this:
> 1. An administrator logs into the web interface, creates a user, and 
>   sets up his/her permissions (including a username and a password chosen 
> by 
>   the user). 
>   2. The user starts the client, selects add server, and enters the 
>   server URL and his/her credentials. 
>   3. The client attempts to authenticate the the user via HTTP auth 
>   (over SSL). If the authentication was successful, the server will 
> generate 
>   an API key in the form of a UUID and sends it to the client. The client 
> will 
>   save this key and use it in all API calls over HTTPS. HTTP auth is only 
> used 
>   for the initial authentication process prior to reviving a key, as a 
> session 
>   scheme would not be nessessary for this application. Right? The client 
> will 
>   only work if the phone is configured to automatically lock with a PIN 
> or 
>   pattern after a short timeout. The server will only allow one key to be 
>   generated per user, unless an administrator resets the key. Hence, 
> simple, 
>   mobile, multifactor authentication.
>
> Is this sound from a security standpoint? Also, can anyone point me to an 
> example of how to use the HTTP auth that is built into Django? From a Google 
> search, I can find a lot of snipits witch hack the feature together. But, 
> none of them implement HTTP auth in the wayit was added to Django in 
> 1.1<http://code.djangoproject.com/ticket/689>. 
> The official documentation for REMOTE_AUTH can be found 
> here<http://docs.djangoproject.com/en/1.2/howto/auth-remote-user/>, 
> but I am having difficulty understanding the documentation as I am very new 
> to Django.
>
>
>

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



How should I properly impliment HTTP(S) auth (REMOTE_AUTH) in django?

2011-02-08 Thread Sean W
This is a re-post of my stack overflow question here 
http://stackoverflow.com/questions/4939908/how-should-i-properly-impliment-https-auth-remote-auth-in-django

  Hi,

I am in the planning phase a new project. I want to be able to control 
multiple relays from my android powered phone over the internet. I need to 
use an HTTP based server as a middleman between the phone and the relays. 
Django is my preferred platform because Python is my strongest skill set. 
This would not be a "web app" (with the exception of the admin interface for 
managing the user and their access to the relays). Rather, the server would 
simply provide an API in the form of HTTPS requests and JSON encoding. 
Though, I should note that I have never done any web development in my life, 
so I don't know best practices (yet). The authentication method should meet 
the following criteria:

   - Works over HTTPS (self-signed SSL)
   - Provides multi-factor authentication (in the form of something you have 
   and something you know)
   - Be reasonably secure (Would be very difficult to fool, guess at. or 
   otherwise bypass)
   - Is simple in implementation for the server operator and end user on the 
   mobile client
   - 
   
   Is lightweight in in terms of both CPU cycles and bandwidth
   
   I plan to use the following scheme to solve this:
   1. An administrator logs into the web interface, creates a user, and sets 
  up his/her permissions (including a username and a password chosen by the 
  user).
  2. The user starts the client, selects add server, and enters the 
  server URL and his/her credentials.
  3. The client attempts to authenticate the the user via HTTP auth 
  (over SSL). If the authentication was successful, the server will 
generate 
  an API key in the form of a UUID and sends it to the client. The client 
will 
  save this key and use it in all API calls over HTTPS. HTTP auth is only 
used 
  for the initial authentication process prior to reviving a key, as a 
session 
  scheme would not be nessessary for this application. Right? The client 
will 
  only work if the phone is configured to automatically lock with a PIN or 
  pattern after a short timeout. The server will only allow one key to be 
  generated per user, unless an administrator resets the key. Hence, 
simple, 
  mobile, multifactor authentication.
   
Is this sound from a security standpoint? Also, can anyone point me to an 
example of how to use the HTTP auth that is built into Django? From a Google 
search, I can find a lot of snipits witch hack the feature together. But, 
none of them implement HTTP auth in the wayit was added to Django in 
1.1. 
The official documentation for REMOTE_AUTH can be found 
here, 
but I am having difficulty understanding the documentation as I am very new 
to Django.

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



Re: Can someone help with Many-to-many referencing and then calculations against another field on the linked model

2011-01-21 Thread Sean Wallace
Hi Trevor,

On Fri, Jan 21, 2011 at 1:47 PM, Trevor Stanley wrote:

> def get_fringe_value(self, fringe):


should be

def get_fringe_value(self):

I don't think you are using the local variable "fringe" anywhere in this
method, so you should get rid of it.

and


>   self.fringe_total = self.fringe_value
>

should be:

  self.fringe_total = self.fringe_value()

I'm not sure if that'll make the whole thing work, but it will fix the error
you received. You have to call the method somewhere along the line or it
won't get executed.

sean

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



Converting from Wordpress, upgrading users.

2011-01-15 Thread Sean Brant
I am migrating a site from Wordpress to Django and I need the old
username and passwords to keep working. I first create auth.User
objects for all Wordpress users. Wordpress' login username does not
conform to Django's so I need to fix some of the usernames during
migration.

I then store Wordpress Credentials wp_user_login, wp_user_pass,
fixed_username (True is i need to fix there username during migration)
and a FK to the new auth.User in a separate table. My custom auth
backend will look up the Credentials by wp_user_login, then check the
password (hashing it with the same algorithm that Wordpress uses)
against wp_user_pass.

If the password hashes match and and fixed_username is False I can
update the auth.User's password and the upgrade is complete.

If fixed_username is True I need to provide an additional step of
having the User verify they like there new username, or provide a new
one. And then the upgrade is complete.

I would like to not have to recreate all of
django.contrib.auth.views.login to get this workflow working, but i
can figure out how to redirect to the "verify fixed username" page.

Anyone solve this before?

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



Re: Need HELP urgently

2011-01-13 Thread Sean Wallace
On Wed, Jan 12, 2011 at 10:59 PM, Derek  wrote:

> You could also consider using an AJAX-based "autocomplete" approach;
> see:
> http://code.djangoproject.com/wiki/AutoCompleteSolutions
>
> On Jan 12, 7:27 am, gupta-django  wrote:
> > I have two application
> >
> > 1. App1 - It has a Model Class "Entry" that has 20 entries
> > 2. App2 - It has a Model Class "Priority"
> >
> > In Priority class I am defining a Foreign Key Relationship as
> >
> > from App1.models import Entry
> >
> > class Priority(models.Model):
> > entry = models.ForeignKey(Entry)
> > priority = models.CharField(max_length=2)
> >
> > And in App2/admin.py I am simply registering Priority
> >
> > admin.site.register(Priority)
> >
> > But on Admin website when I try to add a priority - the control hangs
> > up and only a blank page is returned after a long time gap.
> >
> > Can anyone please look into the issue that why it is not letting me
> > add priorities through Admin? I am able to add from backend,
> >
> > Thanks


The time gap is created because Django is trying to generate a select input
with 200,000 options in it.

I'd recommend choosing another widget type, probably an autocomplete of some
sort...

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_overrides

Sean

-- 
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 training resources?

2010-12-17 Thread Sean W
I should mention that a would prefer a tutorial that goes over 
web development principals like Javascript and AJAX because I've never used 
those tools before.

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: Django training resources?

2010-12-17 Thread Sean
USA
On Dec 17, 2010 9:28 PM, "Kenneth Gonsalves"  wrote:
> On Fri, 2010-12-17 at 15:12 -0800, Sean W wrote:
>> Is anyone aware of good quality, affordable training for Django?
>
> which country?
> --
> regards
> Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-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.



Django training resources?

2010-12-17 Thread Sean W
Is anyone aware of good quality, affordable training for Django?  I'm 
entirely new to web development, although I do have some experience with 
Python. I'm also a college student, so cost is a concern. I don't have the 
time to travel to a training seminar. I'm not one of those people who can 
master a subject simply by reading a book or tutorial–I need some hands on 
experience. Something like a webinar would work, even a pre-recorded one.

Any suggestions are appreciated. Thanks.
 

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

2010-09-11 Thread Sean W
After a bit of googling I found:

https://code.google.com/p/sct-project/

On Sep 11, 12:47 pm, Shamail Tayyab  wrote:
> Hi,
>
>   I need a very minimal wiki, best if it runs on flat files. moinmoin is too
> heavy for what I am looking. Is there some Django thing available or written
> by someone here?
>
> Thanks
>
> --
> Shamail Tayyab
> Blog:http://shamail.in/blog

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



Admin Inline inside another admin inline

2010-07-03 Thread Sean Brant
I have these models and model admins and I was hoping inlines = []
inside a admin.TabularInline would work, but it doesn't seem to.



class Size(models.Model):
pass

class Product(models.Model):
pass

class ProductType(models.Model):
title = models.CharField(_('title'), max_length=200)
product = models.ForeignKey(Product, verbose_name=_('product'))
sizes = models.ManyToManyField(Size, through='ProductSize')

class ProductSize(models.Model):
product_type = models.ForeignKey(ProductType,
verbose_name=_('product type'))
size = models.ForeignKey(Size, verbose_name=_('size'))
quantity = models.IntegerField()


class ProductSizeInline(admin.TabularInline):
model = Product Size


class ProductTypeInline(admin.TabularInline):
model = ProductType
inlines = (ProductSizeInline,)


class ProductAdmin(admin.ModelAdmin):
inlines = (ProductTypeInline,)

admin.site.register(Product, ProductAdmin)



Im not even sure if this is best way to display things, I would like
one main product edit screen that lets you attach "product types"
which have "sizes" to a "product", it seems jumping between a bunch of
screens is not good ux. Wondering if I need to create a custom view
for this? 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-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.



SQL along side NoSQL

2010-06-02 Thread Sean Brant
Whats the best way to use django's orm along side a NoSQL DB? I want
to keep my users and other data in postgres but have some data that
would be better suited for a NoSQL DB like redis.

I see a lot of talk about switching to NoSQL but little talk on
integrating it with existing systems. I think it would be foolish to
throw the baby out with the bath water and ditch SQL all together,
unless it makes things easier to maintain and develop.

I'm wondering what the best approach is for relating data stored in
SQL to my data in redis. I was thinking of something along the line of
this.

* User object stored in SQL
* Book object in redis, key sh1 hash of value, value is a JSON string
* Relations stored in redis, key User.pk:books, value redis set of
sha1's

Anyone have experience, tips, better ways?

-- 
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: Python 2.6 Decompile --- I lost my views.py but have the views.pyc

2009-12-17 Thread Sean Perry


On Thu Dec 17 11:28 , Bill Freeman  sent:

>I saw a demo of a byte code disassembler once.  It won't get you the
>source code back, but you could conceivably construct equivalent from
>it.  You can, for example, see what it's calling, and sketch out the
>contiditionals and any loops.  You could google for it, or ask on the
>python tutor mailing list.
>

There was decompyle, but the author decided to turn it into a service. Last
released source works on 2.3. You can get it from packages.debian.org or
elsewhere. If the original poster is desperate enough, he could try the service.

unpyc is an attempt to continue decompyle. Apparently it has issues with code
using iterators and still needs work. If anyone out there is interested, all of
the pieces exist it just needs work.

That said, Bill's suggestion of asking on tutor is spot on. That is a fabulous
mailing list for general Python questions. Lots of bright people, some involved
in Python directly, answer 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: Sick of defining urls

2009-12-03 Thread Sean Perry


On Thu Dec  3  8:42 , Todd Blanchard  sent:

>
>I've read the little poem.  I disagree with about half of it.  If you can't 
>take
constructive criticism of your toolkit (I have plenty negative to say about 
rails
and any of the other dozen web app development environments I know too) then you
should maybe put down the kool-aid and walk away.  No environment is perfect.
>

You are welcomed to disagree with it, all of us hackers view things differently.
That said, understanding what Tim is saying will help you understand Python and
the people who use it. Most of us agree with most of Tim's points. I believe 
this
was mentioned not to tell you to walk away, but that you should learn to use the
tools as intended instead of forcing a screw driver to be a chisel.

Maybe the standard Rails URLs make sense to you. But I suspect many if not most
of the Django projects actually do not have URLs that directly bind to their
internals. Remember it grew up out of reporting where the URLS are dictacted by
other people or even how stories are organized. There is a lot of flexibility in
any URL can go anywhere you want.

Here is the page on Amazon for Learning Python:
http://www.amazon.com/Learning-Python-Animal-Guide-Mark/dp/0596158068/ref=sr_1_1?ie=UTF8&s=books&qid=1259864161&sr=8-1

That does not map to model/view/blah directly. When amazon decides to use
/books/Oreilly/Python/dp/0596158068 they can and only by adjusting urls.py and
maybe their views indirection routine.

Sure, mapping things directly to code and models is fast for initial 
development.
But real websites do not exist to make the hackers happy. They exist to get 
ideas
out to people who probably have no idea how a website is run, and yeah maybe 
make
some money at the time. Simple urls like 'http://example.com/xmas/toys' do not
come from convention. Now, you may point out that this would be a special 
holiday
thing and easily to add. You'd be right, but the "use pretty URLS" concept is a
driving force behind Django. Giving people simple URLs they can type in, see on 
a
billboard, etc. are the main driving force, not some last minute requirement 
from
Marketing.

Ponder this, consider why Django does what it does. Look at where and who the
focus is. You are free to disagree and do it some other way. But don't assume
Django has somehow missed this or chosen not to because the developers just like
to waste their time typing.



--

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.




middleware to log request/response objects for testing purposes?

2009-11-25 Thread Sean Neilan
Dear Django Community,

I am curious if anyone has built some middleware to log all request/
response objects & possibly view & exception calls. I could do this
myself easily, but, I would like to not reinvent the wheel.

Thank you for your time.

-Sean Neilan

--

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: Switching a Models Field Class at Runtime

2009-11-12 Thread Sean Brant
Yeah that would work. I'd like to avoid that because every Item will
need its child content, so you would have to always use a join (which
are slow).

One more thought is it possible to has multiple models that all save
to the same table? I only really need the helpful Image and File
fields for writing, I can do all my reads from a base model.

Sean

--

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




Switching a Models Field Class at Runtime

2009-11-12 Thread Sean Brant
Let me start out by saying this feels a little over engineered but I
wanted to see what people thought anyways.

I would like to create a list similar to a Facebook wall. You can post
stuff and attach content to the post. In the past I have create a
table with properties for all content formats and only set the one I
was interested in. Thats bad cause you have all these empty fields for
no reason. I have also just created foreign key to a separate content
model (one for each format). That means you have to joins all the
time. Since at the end of the day all of these formats are stored as
strings, I can just use ONE content field. However I lose all the nice
Image and File handling stuff Django gives you. So what if there was a
ModelField that could change itself at runtime. Would I be better of
doing this feature in a non-relational database and handling all the
file upload stuff myself?

All content will be represented in the database as a VARCHAR. I'll add
some pseudo code that might explain it better than i can.

choices = (
(0, 'note'),
(1, 'link'),
(2, 'image'),
)

formats = (
(0, models.CharField, {'max_length': 200}),
(1, models.UrlField,),
(2, models.ImageField, {'upload_to': 'uploads'),
)

class Item(models.Model):
title = models.CharField(max_length=200)
format = models.IntegerField(choices=choices, default=0)
content = MultiFormatField(formats=formats, format_field='format')
# changes based on instance.format

Thanks for taking the time to read this over.

- Sean

--

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




Sessions for Anonymous Users

2009-11-05 Thread Sean Brant

So I have a invite system for one of my projects and right now when a
user clicks the link /invitations// I get the invitation object
and store it in request.session['invitation']. Then I redirect to /
accounts/new/ if request.session['invitation'] is None then I produce
and error if not I present a registration form. Once the form is saved
successfully I remove request.session['invitation'].

Any advice on this? Something feels wrong about storing the invitation
in the session. Is this going to be a safe maintainable option? Should
I be storing something in a cookie instead, or just put the
registration form on a page that contains the key in the url?

Thanks for any design decisions you might offer 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-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: Marking usernames as not for use dynamically

2009-11-02 Thread Sean Brant

Thanks Ethan.

bruno you are right moving stuff under the /profiles/ namespace would
solve everything.

Moving the pattern last but allowing users to still create the
username of "login" would prevent there username from working.

You are also right about "whenever you add any other url..." this will
defiantly become a problem. Say someone creates a username of
"my_super_cool_promotion" and in 3 months i want to create a page at
the url "my_super_cool_promotion" promoting something. They would
effectively take my url.

Let me revise my question some. Anyone have user profiles living at
http://domain.com/username/ and if so how are you handling the above
problems? I guess you could run a query against usernames before
creating a new page, making sure that path is not taken.

Thoughts welcome.

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



Marking usernames as not for use dynamically

2009-11-02 Thread Sean Brant

So i have user profiles at http://domain.com/username. I'd like to
prevent a user from signing up with a username that is the same as a
page on my site (ie: /login/, /blog/, etc). I was thinking I could
inspect my url patterns to determine what pages exist  so I can
prevent that from being a username. Although I'm not sure how
expensive that will be. I'd rather not have to maintain a list in my
settings file. Anyone know of a solution for this? Seems like a fairly
common use case.

Sean

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



October's Django-NYC Meeting

2009-09-29 Thread Sean

Hey folks,

Join us on October 13th for an exciting django-nyc. This month's talks
will be by Hani, on how he developed the API for http://indexedbygoogle.com/
, and I'll be giving a recap of what came out of DjangoCon 2009.

The meeting will be held at the HUGE offices at 45 Main Street, Suite
220, in Brooklyn at 7pm on 10/13/09.

We look forward to seeing you there!

-Sean

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



Re: Any one knows equivalent non php plugin for this?

2009-09-28 Thread Sean Perry



On Mon Sep 28 15:04 , ydjango  sent:

>
>http://www.frontpageslideshow.net/
>
>
>Anyone knows equivalent plugin of above which I can use in python/
>django site.
>
>The plugin above is in jquery and php.

Most of the magic is in the javascript (they use jQuery) and CSS, integrating
that with Django should not be too hard. There may be some hard coded GET's that
you will need to adapt.

They list a whole bunch of sites using this style of slideshow. Grab the
Javascript and HTML and see what is going on.


--~--~-~--~~~---~--~~
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: Permissions per model instance

2009-09-10 Thread Sean Kemplay

Maybe not exactly what you are after, however I have a user profile that
links to an account model. Everything model that instances need to be
owned by a user has a foreign key to the account model.  When I want to
retrieve anything that is owned by an account I get the account from the
user profile, and retrieve the instance through it.  eg
account.domain_set.get().  If it throws an error, it
doesnt exist or isnt owned by that account.  This stops url manipulation
as far as I can tell.

Sean

On Wed, 2009-09-09 at 16:37 -0700, eka wrote:
> Hi all..
> 
> Is there any way to assign permissions to an instance of a model
> instead of to a model itself?
> 
> Example:
> 
> I have a model for Files so john can (view) file 1, 5 and 6 but not
> the rest
> 
> Regards
> 
> Eka
> > 



--~--~-~--~~~---~--~~
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: Restricting database permissions

2009-09-07 Thread sean

Hi Thomas,

Thank you for your suggestion.  The modified manage.py sounds like a
very good place for me to start.

Best regards,
Sean

On Mon, 2009-09-07 at 16:09 +0200, Thomas Guettler wrote:
> I can speak only for postgres.
> 
> We create the database with a special admin-account and
> the owner if the db is the admin-account. Then we grant
> insert, update, delete permissions to the django-db-user.
> 
> We have a modified manage.py which let syncdb run with
> the admin-account (interactive password prompt).
> 
> It is possible, it is more secure, but makes some trouble.
> 
> sean schrieb:
> > Hi All,
> > 
> > I am currently working on a front end to pam-mysql and nss-mysql to
> > allow the creation of linux user accounts through the web.  
> > 
> > I need to separate out permissions so that Django can read some columns
> > and not others, for instance it should have no access to the password
> > column.  
> > 
> > I need another mysql user with it's mysql password stored in a file
> > owned by root with permissions 700 to do the actual data modification -
> > so this part will need to be separate from the Django app, but called
> > from it via a passwordless sudo entry or something.
> > 
> > As Django can only connect to mysql with one user, what is the best way
> > to restrict it's permissions to the ones I want it to be able to read?
> > Can this be done at a configuration file level so that upon running
> > syncb, the permissions are in place?
> > 
> > Any pointers greatly 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
-~--~~~~--~~--~--~---



Restricting database permissions

2009-09-07 Thread sean

Hi All,

I am currently working on a front end to pam-mysql and nss-mysql to
allow the creation of linux user accounts through the web.  

I need to separate out permissions so that Django can read some columns
and not others, for instance it should have no access to the password
column.  

I need another mysql user with it's mysql password stored in a file
owned by root with permissions 700 to do the actual data modification -
so this part will need to be separate from the Django app, but called
from it via a passwordless sudo entry or something.

As Django can only connect to mysql with one user, what is the best way
to restrict it's permissions to the ones I want it to be able to read?
Can this be done at a configuration file level so that upon running
syncb, the permissions are in place?

Any pointers greatly appreciated.

Regards,
Sean




--~--~-~--~~~---~--~~
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: The admin interface - this used to work?

2009-08-18 Thread Sean Kemplay

I had a similar problem after updating the django version.  I had custom
admin templates based on the previous version.  Copying the latest
versions accross fixed it for me.

Regards,
Sean

On Tue, 2009-08-18 at 07:18 -0700, Joakim Hove wrote:
> Hello,
> 
> I am slowly building up a site with django - it feels very good.
> 
> About two months ago I tried the admin interface; with nearly zero
> effort (basically uncomment a couple of lines from the default files)
> I got a very nice and functional interface up and running - great!
> 
> Now I have done some changes, and can not get the interface to work
> any longer. What I have done is:
> 
>   1. I have moved to the production server, and django is invoked with
> apache & mod_wsgi (previously used the dev server).
>   2. I have upgraded django to the latest svn release (I had latest
> svn in june as well).
>   3. I have not installed any admin.py files.
> 
> When I now go to the admin url I can log in with the django super user
> account, but:
> 
>   1. The interface is damn basic - maybe some stylesheets / templates
> are missing?
>   2. The interface does not seem to contain any information about my
> site anymore.
> 
> Any tips?
> 
> Joakim
> 
> > 


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



Testing code that uses geopy

2009-08-10 Thread Sean Brant

I have written some unit tests that test various parts of code that
utilize geopy for determining geo locations. Should I be running my
tests using the geocoder class, or should I create a mock class that
does not actually ping any services? If creating a mock class is
recommended should I specify the geocoder class in settings, then
overwrite that when my test run? Is all of this silly to even be
worried about, should I be wanting to hit the geocode service on every
test.

Thanks in advance for any insight.
--~--~-~--~~~---~--~~
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: Touch django.wsgi not reloading daemon

2009-08-05 Thread Sean Kemplay

You are correct - it actually didn't work - it just seemed to.

The issue was resolved by installing the latest version of mod_wsgi
from source - I am using ubuntu hardy server edition.

I uninstalled, installed from source, enabled the module using the
original ubuntu config files that were left behind by apt and all is
now fine.  I did notice in my apache logs that mod_wsgi was compiled
against python 2.5.1 and that python 2.5.2 was installed on my system
- I am not sure if that contributed.

The config files needed no change.

Thanks,
Sean

On Aug 5, 10:20 pm, Graham Dumpleton 
wrote:
> On Aug 5, 11:12 pm, Sean Kemplay  wrote:
>
> > Hi all.
>
> > I have resolved this by adding user=www-data group=www-data to the
> > WSGIDaemonProcess:
>
> > WSGIDaemonProcess sean75_ispy user=www-data group=www-data
>
> That change shouldn't have made any difference as those are the
> defaults for user/group anyway and so aren't required. You only need
> to supply those options if you want to override what the Apache
> defaults are.
>
> Unfortunately a lot of blog posts show the use of those options with
> same credentials as Apache. It is just a waste of time to do it.
>
> Best to have just worked through:
>
>  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
>
> and double check that where you were placing your configuration was in
> fact actually resulting in daemon mode being used, as touching the
> WSGI script file only works for daemon mode.
>
> Graham
>
> > Regards,
> > Sean
>
> > On Aug 5, 1:46 pm, Sean Kemplay  wrote:
>
> > > Hi All,
>
> > > I have the following in my virtual host config:
>
> > > WSGIDaemonProcess sean75_ispy
> > > WSGIProcessGroup sean75_ispy
>
> > > and the following in my django.wsgi:
>
> > > import os, sys
> > > sys.path.append('/srv/home/sean75/django/')
> > > os.environ['DJANGO_SETTINGS_MODULE'] = 'ispy.settings'
> > > import django.core.handlers.wsgi
> > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > Everything is working as expected except reloading the daemon.
>
> > > When I try touch /srv/home/sean75/django/ispy/apache/django.wsgi it
> > > does not reload and any changes I have made d not show up.
>
> > > When I run apache2ctl restart, the changes show up.
>
> > > Has anyone else experienced this?
>
> > > Regards,
> > > Sean
--~--~-~--~~~---~--~~
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: Touch django.wsgi not reloading daemon

2009-08-05 Thread Sean Kemplay

Hi all.

I have resolved this by adding user=www-data group=www-data to the
WSGIDaemonProcess:

WSGIDaemonProcess sean75_ispy user=www-data group=www-data

Regards,
Sean

On Aug 5, 1:46 pm, Sean Kemplay  wrote:
> Hi All,
>
> I have the following in my virtual host config:
>
> WSGIDaemonProcess sean75_ispy
> WSGIProcessGroup sean75_ispy
>
> and the following in my django.wsgi:
>
> import os, sys
> sys.path.append('/srv/home/sean75/django/')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'ispy.settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> Everything is working as expected except reloading the daemon.
>
> When I try touch /srv/home/sean75/django/ispy/apache/django.wsgi it
> does not reload and any changes I have made d not show up.
>
> When I run apache2ctl restart, the changes show up.
>
> Has anyone else experienced this?
>
> Regards,
> Sean
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Touch django.wsgi not reloading daemon

2009-08-05 Thread Sean Kemplay

Hi All,

I have the following in my virtual host config:

WSGIDaemonProcess sean75_ispy
WSGIProcessGroup sean75_ispy

and the following in my django.wsgi:

import os, sys
sys.path.append('/srv/home/sean75/django/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'ispy.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Everything is working as expected except reloading the daemon.

When I try touch /srv/home/sean75/django/ispy/apache/django.wsgi it
does not reload and any changes I have made d not show up.

When I run apache2ctl restart, the changes show up.

Has anyone else experienced this?

Regards,
Sean

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



Inserting into existing tables

2009-08-04 Thread Sean Brown

I have existing tables in a postgresql database created with existing  
sequences as the default values for their primary key. I am trying to  
interface with the database with django (i have tried with 1.0.2, 1.1  
and now have django-trunk) and while it seems the model works  
(runserver complains if I have a typo in a column name) I can not  
insert into the table.

If I define the primary key field as follows:

id = models.AutoField(primary_key=True)

an insert (with the save() method) throws:

relation "tablename_id_seq" does not exist

If I define the primary key field like this:

id = models.IntegerField(primary_key=True)

an insert fails with null value in column "id" violates not-null  
constraint

Obviously, I am not specifying a value for the id in my forms as I  
want it to auto increment. How am I supposed to use django with  
existing tables in existing DB's?

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



QuerySet question, getting latest 3 objects filtered by a key.

2009-06-22 Thread Sean Brant

This is best explained with an example.

i have a model for Stats

class Stat(models.Model):
key = models.CharField(max_length=50)
value = models.TextField()
pub_date = models.DateTimeField()

so if i create a few stat objects lets say these.

stat1 = Stat(key='total_books_sold', value=100,
pub_date=datetime.datetime.now())
stat2 = Stat(key='total_books_returned', value=10,
pub_date=datetime.datetime.now())
stat3 = Stat(key='avg_foos', value=2.6,  pub_date=datetime.datetime.now
())

i would like to be able to one query and get the latest stat per key
so the query should only return. Even if we insert stats every hour.
It should only return 2 (the latest unique for key).

[, , ]

I hope that makes sense. I'll do multiple queries if need be.

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



Dual Storage Backends?

2009-06-18 Thread Sean Brant

has anyone come across dual storage backend, ideally id would like a
way to save a file locally and then in a back ground process save to
s3, the guess the storage class would handle the files locally until
the background process has finished then switch to serving the files
off of s3?

Basecamp does something similar, for about 30mins the file is served
by them then after that it gets served by s3.
--~--~-~--~~~---~--~~
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: Images not uploading in the admin tool

2009-06-17 Thread Sean Brant

Nope, there customer support takes to long so I just gave up. Please  
post if you have any updates. Last I remember it might be a NFS issue  
on there end. Not really sure.

On Jun 17, 2009, at 9:43 AM, mmarshall   
wrote:

>
> On Jun 9, 9:19 am, Sean Brant  wrote:
>> "Did MediaTemple change something about the file system you have
>> access to?  It sounds like they must have changed something so that
>> the file locking code that used to work for your setup is no longer
>> working."
>>
>> That is what it sounds like to me, however they we're not much help.
>> I'll reach back out to them and see what they say.
>
> Any news on this?  I'm running up against the same problem.
>
> MWM
> >

--~--~-~--~~~---~--~~
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: Is there a way to calling a model field method on model save

2009-06-16 Thread Sean Brant

Okay I just came up with this, let me know if this is a really hacky
way to do this. With this it will save the model, then the file and
then the model again, not sure how to do this since we don't get the
filename until after we save the file and we have to set the filename
in the database.

class PostSaveImageField(ImageField):
def pre_save(self, model_instance, add):
return Field.pre_save(self, model_instance, add)

def post_save(self, sender, instance, created, **kwargs):
file = getattr(instance, self.attname)
if file and not file._committed:
file.save(file.name, file, save=False)
setattr(instance, self.attname, file)
instance.save()

def contribute_to_class(self, cls, name):
post_save.connect(self.post_save, sender=cls)
super(PostSaveImageField, self).contribute_to_class(cls, name)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Is there a way to calling a model field method on model save

2009-06-16 Thread Sean Brant

I am creating a custom image field, that I would like for it not to
save the image until after the model instance is written to the
database (i want the id for the object to use in the filename). The
ImageField class saves the image to storage via pre_save. Is there any
methods or any other code that fires post save on the Field class? Is
doing some sort of dynamic signal stuff that only way?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with query set order_by

2009-06-11 Thread Sean Brant

You the man Alex, that was the problem!

On Jun 11, 11:19 am, Alex Gaynor  wrote:
> On Thu, Jun 11, 2009 at 11:15 AM, Tom Evans wrote:
>
>
>
>
>
> > On Thu, 2009-06-11 at 09:04 -0700, Sean Brant wrote:
> > > If I have 2 sql queries one with a limit of 5 and the other with a
> > > limit or 6 they return there results in diffrent orders.
>
> > > Here is a example.
>
> > > >>> class Book(models.Model):
> > > >>>    title = models.CharField(max_length=150)
> > > >>>    author = models.CharField(max_length=100)
>
> > > >>> book_list_1 = Books.objects.order_by('author')[0:5]
> > > >>> book_list_2 = Books.objects.order_by('author')[0:6]
>
> > > >>> print book_list_1
> > > <<< [, , , ,
> > > ]
>
> > > >>> print book_list_2
> > > <<< [, , , ,
> > > , ]
>
> > > Very confused.
>
> > Django just returns them in the order your database engine returns them.
> > If you look at django.db.connection.queries, and run them in your db
> > shell, they will return the items in a different order. What's causing
> > that is interesting though, what db engine do you use?
>
> > Might be interesting to see the queries, and also book_list_n.values().
>
> > Cheers
>
> > Tom
>
> The cause is likely that the author for each item is equal, and there is no
> defined ordering for equal objects.  If you want a consistant ordering
> provide 2 levels or ordering, aka: order_by('author', 'other_field') with
> another field such as 'id'.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Problem with query set order_by

2009-06-11 Thread Sean Brant

If I have 2 sql queries one with a limit of 5 and the other with a
limit or 6 they return there results in diffrent orders.

Here is a example.

>>> class Book(models.Model):
>>>title = models.CharField(max_length=150)
>>>author = models.CharField(max_length=100)

>>> book_list_1 = Books.objects.order_by('author')[0:5]
>>> book_list_2 = Books.objects.order_by('author')[0:6]

>>> print book_list_1
<<< [, , , ,
]

>>> print book_list_2
<<< [, , , ,
, ]

Very confused.
--~--~-~--~~~---~--~~
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: Images not uploading in the admin tool

2009-06-09 Thread Sean Brant

"Did MediaTemple change something about the file system you have
access to?  It sounds like they must have changed something so that
the file locking code that used to work for your setup is no longer
working."

That is what it sounds like to me, however they we're not much help.
I'll reach back out to them and see what they say.

On Tue, Jun 9, 2009 at 9:15 AM, Karen Tracey wrote:
> On Tue, Jun 9, 2009 at 9:49 AM, Sean Brant  wrote:
>>
>> I am running on a MediaTemple Django container with the SVN version of
>> Django. When I try and upload a image in the admin tool I get a proxy
>> error. The following is the part of the traceback that gets emailed to
>> me.
>>
>> Traceback (most recent call last):
>>
>> [snip]
>>
>> File "/home/58124/data/python/django/django/core/files/storage.py",
>> line 169, in _save
>>   locks.lock(fd, locks.LOCK_EX)
>>
>> File "/home/58124/data/python/django/django/core/files/locks.py", line
>> 57, in lock
>>   fcntl.lockf(fd(file), flags)
>>
>> IOError: [Errno 37] No locks available
>>
>> Im not really sure what the problem is, the MediaTemple support team
>> says they do not support Django to this degree. I suspect it might be
>> a server issue though? This code however worked for a while then just
>> stopped, and there were no code changes that took place when It
>> stopped working.
>
> Searching trac for "No locks available" brings up this ticket:
>
> http://code.djangoproject.com/ticket/9400
>
> Did MediaTemple change something about the file system you have access to?
> It sounds like they must have changed something so that the file locking
> code that used to work for your setup is no longer working.
>
> 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-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
-~--~~~~--~~--~--~---



Images not uploading in the admin tool

2009-06-09 Thread Sean Brant

I am running on a MediaTemple Django container with the SVN version of
Django. When I try and upload a image in the admin tool I get a proxy
error. The following is the part of the traceback that gets emailed to
me.

Traceback (most recent call last):

File "/home/58124/data/python/django/django/core/handlers/base.py",
line 92, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

File "/home/58124/data/python/django/django/contrib/admin/sites.py",
line 480, in root
   return self.model_page(request, *url.split('/', 2))

File "/home/58124/data/python/django/django/views/decorators/
cache.py", line 44, in _wrapped_view_func
   response = view_func(request, *args, **kwargs)

File "/home/58124/data/python/django/django/contrib/admin/sites.py",
line 499, in model_page
   return admin_obj(request, rest_of_url)

File "/home/58124/data/python/django/django/contrib/admin/options.py",
line 1088, in __call__
   return self.add_view(request)

File "/home/58124/data/python/django/django/db/transaction.py", line
240, in _commit_on_success
   res = func(*args, **kw)

File "/home/58124/data/python/django/django/contrib/admin/options.py",
line 733, in add_view
   self.save_model(request, new_object, form, change=False)

File "/home/58124/data/python/django/django/contrib/admin/options.py",
line 557, in save_model
   obj.save()

File "/home/58124/containers/django/goalscoring/apps/entries/
models.py", line 55, in save
   super(Entry, self).save(*args, **kwargs)

File "/home/58124/data/python/django/django/db/models/base.py", line
410, in save
   self.save_base(force_insert=force_insert,
force_update=force_update)

File "/home/58124/data/python/django/django/db/models/base.py", line
474, in save_base
   values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname)
or f.pre_save(self, True))) for f in meta.local_fields if not
isinstance(f, AutoField)]

File "/home/58124/data/python/django/django/db/models/fields/
files.py", line 252, in pre_save
   file.save(file.name, file, save=False)

File "/home/58124/containers/django/goalscoring/apps/thumbs.py", line
104, in save
   super(ImageWithThumbsFieldFile, self).save(name, content, save)

File "/home/58124/data/python/django/django/db/models/fields/
files.py", line 91, in save
   self.name = self.storage.save(name, content)

File "/home/58124/data/python/django/django/core/files/storage.py",
line 47, in save
   name = self._save(name, content)

File "/home/58124/data/python/django/django/core/files/storage.py",
line 169, in _save
   locks.lock(fd, locks.LOCK_EX)

File "/home/58124/data/python/django/django/core/files/locks.py", line
57, in lock
   fcntl.lockf(fd(file), flags)

IOError: [Errno 37] No locks available

Im not really sure what the problem is, the MediaTemple support team
says they do not support Django to this degree. I suspect it might be
a server issue though? This code however worked for a while then just
stopped, and there were no code changes that took place when It
stopped working.

Thanks
Sean
--~--~-~--~~~---~--~~
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: UnicodeEncodeError

2009-05-21 Thread Sean Brant

Thanks Karen.

This is a script that fetched some json from a remote service. I  
switched from using the normal simplejson module to the one provided  
by Django and that seems to decode things in a unicode safe way.

On May 21, 2009, at 8:48 AM, Karen Tracey  wrote:

> I see I specified the unicode string incorrectly in my shell  
> example.  Turns out it doesn't make a difference in this case except  
> for the specifics of the exception, but what it should have been was:
>
> >>> u = u'\u2013'
> >>> stderr = open('/tmp/stderr.ascii.out', 'w')
> >>> print >> stderr, '%s' % u
> Traceback (most recent call last):
>   File "", line 1, in 
> UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013'  
> in position 0: ordinal not in range(128)
> >>> import codecs
> >>> stderr = codecs.open('/tmp/stderr.utf8.out', mode='w',  
> encoding='utf-8')
> >>> print >> stderr, '%s' % u
> >>> quit()
>
> 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-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
-~--~~~~--~~--~--~---



UnicodeEncodeError

2009-05-20 Thread Sean Brant

Traceback (most recent call last):
  File "manage.py", line 11, in ?
execute_manager(settings)
  File "/home/58124/data/python/django/django/core/management/
__init__.py", line 362, in execute_manager
utility.execute()
  File "/home/58124/data/python/django/django/core/management/
__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/58124/data/python/django/django/core/management/
base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/home/58124/data/python/django/django/core/management/
base.py", line 222, in execute
output = self.handle(*args, **options)
  File "/home/58124/containers/django/contest/apps/entries/management/
commands/grabentries.py", line 73, in handle
print '[%s] Saved - Entry "%s"' % (datetime.now(), entry.title)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in
position 56: ordinal not in range(128)

Is there any way to insure that this error does not occur? Do I need
to do some sort of unicode conversion with Django?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Trying to access admin but getting AttributeError: 'NoneType' object has no attribute 'cursor'

2009-05-15 Thread Sean Brant
I rechecked out trunk and it seems to work as expected. Thanks.

On May 15, 2009, at 10:54 PM, Alex Gaynor  wrote:

>
>
> On Fri, May 15, 2009 at 8:40 PM, Sean Brant   
> wrote:
>
> On more thing I reverted back to rev: 9500 (choose it randomly) every
> thing seems to work.
>
> On May 15, 8:24 pm, Sean Brant  wrote:
> > Im running trunk rev: 10790 with Postgres 8.3 and when I access the
> > admin area or when using login_required i get this error:
> >
> > Traceback (most recent call last):
> >
> >   File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
> > servers/basehttp.py", line 278, in run
> > self.result = application(self.environ, self.start_response)
> >
> >   File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
> > servers/basehttp.py", line 635, in __call__
> > return self.application(environ, start_response)
> >
> >   File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
> > handlers/wsgi.py", line 245, in __call__
> > response = middleware_method(request, response)
> >
> >   File "/Users/seanbrant/webapps/django/lib/python2.5/django/ 
> contrib/
> > sessions/middleware.py", line 36, in process_response
> > request.session.save()
> >
> >   File "/Users/seanbrant/webapps/django/lib/python2.5/django/ 
> contrib/
> > sessions/backends/cached_db.py", line 28, in save
> > super(SessionStore, self).save(must_create)
> >
> >   File "/Users/seanbrant/webapps/django/lib/python2.5/django/ 
> contrib/
> > sessions/backends/db.py", line 56, in save
> > sid = transaction.savepoint()
> >
> >   File "/Users/seanbrant/webapps/django/lib/python2.5/django/db/
> > transaction.py", line 190, in savepoint
> > connection._savepoint(sid)
> >
> >   File "/Users/seanbrant/webapps/django/lib/python2.5/django/db/
> > backends/__init__.py", line 62, in _savepoint
> > self.connection.cursor().execute(self.ops.savepoint_create_sql
> > (sid))
> >
> > AttributeError: 'NoneType' object has no attribute 'cursor'
> >
> > running syncdb works fine and updates my database.
>
>
> I don't believe you are correctly running r10790, as that code no  
> longer exists in it, this was a bug fixed several months ago.  I  
> suggest you make sure your SVN checkout is correct.
>
> Alex
>
> -- 
> "I disapprove of what you say, but I will defend to the death your  
> right to say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
> >

--~--~-~--~~~---~--~~
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: Trying to access admin but getting AttributeError: 'NoneType' object has no attribute 'cursor'

2009-05-15 Thread Sean Brant

On more thing I reverted back to rev: 9500 (choose it randomly) every
thing seems to work.

On May 15, 8:24 pm, Sean Brant  wrote:
> Im running trunk rev: 10790 with Postgres 8.3 and when I access the
> admin area or when using login_required i get this error:
>
> Traceback (most recent call last):
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
> servers/basehttp.py", line 278, in run
>     self.result = application(self.environ, self.start_response)
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
> servers/basehttp.py", line 635, in __call__
>     return self.application(environ, start_response)
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
> handlers/wsgi.py", line 245, in __call__
>     response = middleware_method(request, response)
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/contrib/
> sessions/middleware.py", line 36, in process_response
>     request.session.save()
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/contrib/
> sessions/backends/cached_db.py", line 28, in save
>     super(SessionStore, self).save(must_create)
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/contrib/
> sessions/backends/db.py", line 56, in save
>     sid = transaction.savepoint()
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/db/
> transaction.py", line 190, in savepoint
>     connection._savepoint(sid)
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/db/
> backends/__init__.py", line 62, in _savepoint
>     self.connection.cursor().execute(self.ops.savepoint_create_sql
> (sid))
>
> AttributeError: 'NoneType' object has no attribute 'cursor'
>
> running syncdb works fine and updates my database.
--~--~-~--~~~---~--~~
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: Trying to access admin but getting AttributeError: 'NoneType' object has no attribute 'cursor'

2009-05-15 Thread Sean Brant

It might be due to threading, every once in a while I can pull up the
admin page. It's pretty random thought.

On May 15, 8:24 pm, Sean Brant  wrote:
> Im running trunk rev: 10790 with Postgres 8.3 and when I access the
> admin area or when using login_required i get this error:
>
> Traceback (most recent call last):
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
> servers/basehttp.py", line 278, in run
>     self.result = application(self.environ, self.start_response)
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
> servers/basehttp.py", line 635, in __call__
>     return self.application(environ, start_response)
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
> handlers/wsgi.py", line 245, in __call__
>     response = middleware_method(request, response)
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/contrib/
> sessions/middleware.py", line 36, in process_response
>     request.session.save()
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/contrib/
> sessions/backends/cached_db.py", line 28, in save
>     super(SessionStore, self).save(must_create)
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/contrib/
> sessions/backends/db.py", line 56, in save
>     sid = transaction.savepoint()
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/db/
> transaction.py", line 190, in savepoint
>     connection._savepoint(sid)
>
>   File "/Users/seanbrant/webapps/django/lib/python2.5/django/db/
> backends/__init__.py", line 62, in _savepoint
>     self.connection.cursor().execute(self.ops.savepoint_create_sql
> (sid))
>
> AttributeError: 'NoneType' object has no attribute 'cursor'
>
> running syncdb works fine and updates my database.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Trying to access admin but getting AttributeError: 'NoneType' object has no attribute 'cursor'

2009-05-15 Thread Sean Brant

Im running trunk rev: 10790 with Postgres 8.3 and when I access the
admin area or when using login_required i get this error:

Traceback (most recent call last):

  File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
servers/basehttp.py", line 278, in run
self.result = application(self.environ, self.start_response)

  File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
servers/basehttp.py", line 635, in __call__
return self.application(environ, start_response)

  File "/Users/seanbrant/webapps/django/lib/python2.5/django/core/
handlers/wsgi.py", line 245, in __call__
response = middleware_method(request, response)

  File "/Users/seanbrant/webapps/django/lib/python2.5/django/contrib/
sessions/middleware.py", line 36, in process_response
request.session.save()

  File "/Users/seanbrant/webapps/django/lib/python2.5/django/contrib/
sessions/backends/cached_db.py", line 28, in save
super(SessionStore, self).save(must_create)

  File "/Users/seanbrant/webapps/django/lib/python2.5/django/contrib/
sessions/backends/db.py", line 56, in save
sid = transaction.savepoint()

  File "/Users/seanbrant/webapps/django/lib/python2.5/django/db/
transaction.py", line 190, in savepoint
connection._savepoint(sid)

  File "/Users/seanbrant/webapps/django/lib/python2.5/django/db/
backends/__init__.py", line 62, in _savepoint
self.connection.cursor().execute(self.ops.savepoint_create_sql
(sid))

AttributeError: 'NoneType' object has no attribute 'cursor'

running syncdb works fine and updates my database.
--~--~-~--~~~---~--~~
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.contrib.auth tests fail

2009-05-13 Thread Sean Brant

I am also having a issue with contrib.auth test errors. They errors
seem to be caused by url tags in my base.html template. When I comment
out all of those tags the tests pass. The url tags seem to work when i
look at the site im my browser.

==
ERROR: test_confirm_complete
(django.contrib.auth.tests.views.PasswordResetTest)
--
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/django/contrib/auth/tests/
views.py", line 81, in test_confirm_complete
response = self.client.get(path)
  File "/usr/lib/python2.5/site-packages/django/test/client.py", line
278, in get
return self.request(**r)
  File "/usr/lib/python2.5/site-packages/django/test/client.py", line
222, in request
response = self.handler(environ)
  File "/usr/lib/python2.5/site-packages/django/test/client.py", line
66, in __call__
response = self.get_response(request)
  File "/usr/lib/python2.5/site-packages/django/core/handlers/
base.py", line 128, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)
  File "/usr/lib/python2.5/site-packages/django/core/handlers/
base.py", line 160, in handle_uncaught_exception
return callback(request, **param_dict)
  File "/usr/lib/python2.5/site-packages/django/views/defaults.py",
line 24, in server_error
return http.HttpResponseServerError(t.render(Context({})))
  File "/usr/lib/python2.5/site-packages/django/test/utils.py", line
15, in instrumented_test_render
return self.nodelist.render(context)
  File "/usr/lib/python2.5/site-packages/django/template/__init__.py",
line 768, in render
bits.append(self.render_node(node, context))
  File "/usr/lib/python2.5/site-packages/django/template/debug.py",
line 71, in render_node
result = node.render(context)
  File "/usr/lib/python2.5/site-packages/django/template/
loader_tags.py", line 97, in render
return compiled_parent.render(context)
  File "/usr/lib/python2.5/site-packages/django/test/utils.py", line
15, in instrumented_test_render
return self.nodelist.render(context)
  File "/usr/lib/python2.5/site-packages/django/template/__init__.py",
line 768, in render
bits.append(self.render_node(node, context))
  File "/usr/lib/python2.5/site-packages/django/template/debug.py",
line 71, in render_node
result = node.render(context)
  File "/usr/lib/python2.5/site-packages/django/template/
loader_tags.py", line 24, in render
result = self.nodelist.render(context)
  File "/usr/lib/python2.5/site-packages/django/template/__init__.py",
line 768, in render
bits.append(self.render_node(node, context))
  File "/usr/lib/python2.5/site-packages/django/template/debug.py",
line 81, in render_node
raise wrapped
TemplateSyntaxError: Caught an exception while rendering: Reverse for
'crowdSPRING.contact_us' with arguments '()' and keyword arguments
'{}' not found.

Original Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/django/template/debug.py",
line 71, in render_node
result = node.render(context)
  File "/usr/lib/python2.5/site-packages/django/template/
defaulttags.py", line 387, in render
args=args, kwargs=kwargs)
  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
line 262, in reverse
*args, **kwargs)))
  File "/usr/lib/python2.5/site-packages/django/core/urlresolvers.py",
line 251, in reverse
"arguments '%s' not found." % (lookup_view, args, kwargs))
NoReverseMatch: Reverse for 'MySite.contact_us' with arguments '()'
and keyword arguments '{}' not found.


On May 13, 10:55 am, Michael  wrote:
> On Wed, May 13, 2009 at 9:42 AM, Luc Saffre  wrote:
>
> > Hello,
>
> > when I run ``manage.py test`` to test my Django applications, then I
> > also get a lot of test failures for django.contrib.auth.
>
> > Is that normal? What can I do to get rid of these errors?
>
> Auth leans on some templates in django.contrib.admin for the tests. This is
> known, though not ideal. If you added django.contrib.admin to your installed
> apps, the failures should go away.
>
> I hope that helps,
> Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help a noob with a stupid question - forms

2009-05-12 Thread Sean Brant

Oh i see.

Have a look at this widget

from django.forms.extras.widgets import SelectDateWidget
date = forms.DateField(widget=SelectDateWidget)

This will display Month, Day, and Year as separate selects. I would
probably subclass it to drop the Day field. Just automatically have it
set in the background to 1 or something.

On May 12, 9:05 am, zachp  wrote:
> Yes, but the calendar widget isn't what I want. My user only really
> needs to pick a month (and maybe a year) but not a day. I could resort
> to using that field type, but I wanted to see if I could overcome this
> problem since, at least in my opinion, the calendar widget might be a
> little confusing.
>
> Thanks for the suggestion.
>
> On May 12, 7:56 am, Sean Brant  wrote:
>
> > Did you try date = models.DateTimeField(). This will show up in the
> > admin tool as a calendar widget that you can use to select the date.
> > Django takes care of converting the dates into Python objects and into
> > whatever format your database needs for storing. You could also just
> > use a DateField if you do not need the 
> > time.http://docs.djangoproject.com/en/dev/ref/models/fields/#datetimefield
> > orhttp://docs.djangoproject.com/en/dev/ref/models/fields/#datefield
>
> > On May 12, 6:47 am, zachp  wrote:
>
> > > Hi, I'm completely new to django, so please bear with me. My first
> > > project is a site which handles a monthly prize drawing for my
> > > company. People build up points throughout the month by carpooling/
> > > biking to work, etc, and at the end of the month a drawing is done to
> > > determine a winner. My question is with the form that will be used to
> > > run the contest. I need the user who does this to be able to select a
> > > month (and possibly a year) for the drawing she wants to run. I need
> > > django to convert those two data points into a datetime object for me,
> > > but it's not readily obvious how to do that. My first shot at it had a
> > > ChoiceField in the form which I populated with month names, but now
> > > I'm stuck on the best way to get those converted to datetime objects.
> > > Please help! 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: Help a noob with a stupid question - forms

2009-05-12 Thread Sean Brant

Did you try date = models.DateTimeField(). This will show up in the
admin tool as a calendar widget that you can use to select the date.
Django takes care of converting the dates into Python objects and into
whatever format your database needs for storing. You could also just
use a DateField if you do not need the time.
http://docs.djangoproject.com/en/dev/ref/models/fields/#datetimefield
or http://docs.djangoproject.com/en/dev/ref/models/fields/#datefield

On May 12, 6:47 am, zachp  wrote:
> Hi, I'm completely new to django, so please bear with me. My first
> project is a site which handles a monthly prize drawing for my
> company. People build up points throughout the month by carpooling/
> biking to work, etc, and at the end of the month a drawing is done to
> determine a winner. My question is with the form that will be used to
> run the contest. I need the user who does this to be able to select a
> month (and possibly a year) for the drawing she wants to run. I need
> django to convert those two data points into a datetime object for me,
> but it's not readily obvious how to do that. My first shot at it had a
> ChoiceField in the form which I populated with month names, but now
> I'm stuck on the best way to get those converted to datetime objects.
> Please help! 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: ModelForm customizing

2009-05-08 Thread Sean Brant

Try this, not tested but it might work.

class ProfileForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
self.error_class = DivErrorList
super(ProfileForm, self).__init__(*args, **kwargs)

class Meta:
model = P
exclude = ('date', 'user', 'public')

When you override a class method you need to make sure to call super
inside it. This calls the classes parent method.


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



Re: Template tags and variables overlapping

2009-04-30 Thread Sean Brant

If the tag excepts more than one argument you should be able to do
something like this.

{% sayHello "Robert and" currentname %}

You would just need to figure out how best to break the bits up (a
regex probably would work) and iterate over those bits resolving the
variables to strings, keeping the strings normal strings.
--~--~-~--~~~---~--~~
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: request.urlconf does not get used in URL template tag

2009-04-15 Thread Sean Brant

I knew I couldn't be that easy. Thanks for the heads up. Any other
work around? besides the patch mentioned.

On Apr 15, 11:17 pm, Alex Gaynor  wrote:
> On Thu, Apr 16, 2009 at 12:15 AM, Sean Brant  wrote:
>
> > If you set request.urlconf in say a Middleware then the reverse
> > function and the url tag will not work because those try to match
> > based on your ROOT_URLCONF. I was trying to find a solution to this
> > problem and came across this ticket.
> >http://code.djangoproject.com/ticket/5034
>
> > Then It dawned on me what if I also override settings.ROOT_URLCONF in
> > my middleware when I am setting request.urlconf. This seemed to solve
> > my problems.
>
> > I now wonder If what I did is a good and solid idea. If anyone out
> > there has come across this let me know. It seems to work fine for now
> > though.
>
> It's a bad idea because your application is not threadsafe at all, if  you
> try to run your application in a threaded enviroment you will get lots of
> reverses that return incorrect data since the settings are shared state.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



request.urlconf does not get used in URL template tag

2009-04-15 Thread Sean Brant

If you set request.urlconf in say a Middleware then the reverse
function and the url tag will not work because those try to match
based on your ROOT_URLCONF. I was trying to find a solution to this
problem and came across this ticket. http://code.djangoproject.com/ticket/5034

Then It dawned on me what if I also override settings.ROOT_URLCONF in
my middleware when I am setting request.urlconf. This seemed to solve
my problems.

I now wonder If what I did is a good and solid idea. If anyone out
there has come across this let me know. It seems to work fine for now
though.


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



Setting and deleting cache keys with tags

2009-04-13 Thread Sean Brant

I wrote up a blog post the other day on how I go about deleting
multiple related objects from cache based on tags. It allows you to
tag objects as you add them to cache that way you can delete a bunch
with one call. 
http://stepsandnumbers.com/archive/2009/04/11/setting-and-delete-cache-in-django-with-tags/

My question to the group is??? Is there a common use-case for this?
and should I submit a ticket and see if this or an approach similar is
worth including into trunk?

Thank,
Sean
--~--~-~--~~~---~--~~
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: Business Logic Architecture Questions on Models & ModelManagers

2009-04-12 Thread Sean Neilan

Hey Malcolm,

Thank you very much for your thoughts on those questions!

I will definitely be referring to your advice when I'm writing this
thing.

I had been thinking about those questions when I was on spring break
(about a week or so) and couldn't seem to reach a conclusion, but, I
think I'll be a bit better off now.

Thank you again.

-Sean

On Apr 12, 11:16 pm, Malcolm Tredinnick 
wrote:
> On Sun, 2009-04-12 at 20:41 -0700, Sean Neilan wrote:
> > I'm building a large web application & I'm trying to figure out ways
> > to organize my business logic (just the queries). I figure I should
> > either put all my queries inside Model functions or ModelManager
> > functions. I've searched all over the internet for documentation on
> > where the business logic goes, but, didn't find what I was looking
> > for.
>
> > I have a couple questions:
>
> Opinions vary a bit on these sorts of things. What follows are mine...
>
>
>
> > 1) Should Model methods not contain any queries? Only calculations
> > based on the attributes of that model. Much like
> >http://docs.djangoproject.com/en/dev/topics/db/models/#id4
>
> When you have a model instance, it represents a single row in the
> database. Methods on a Python class instance tend to act on that
> instance, so it makes sense to have model methods act on the particular
> data for that instance, not be more general.
>
> Now, it could well be that "acting on the instance" really means
> "related to that instance" and does other queries to pull in
> information. For example, my blog code currently has the world's lamest
> tagging system (a very simple tag model with a name and a pointer to
> itself for the parent) and I have methods on the model that are "get all
> the descendents of this instance" and "get the ancestors of this
> instance". They are methods that are specific to the instance at hand.
>
>
>
> > 2) Is it a good idea to encapsulate _all_ queries as methods inside of
> > a manager class? Thus making it slightly easier to reuse queries.
>
> Abstracting everything to the n-th degree can often make code a lot
> harder to read, so curb your enthusiasm a little bit here.
>
> Model managers tend to be a good place to put methods that act on the
> collection of model instances. For example, using my lame tag example
> again, a method to query all the tags matching a particular name prefix.
> The documentation describes these as table-level methods, which tends to
> be the way I've thought of them over the years.
>
> For genuinely reusable query fragments, I find myself writing normal
> Python functions that accept a queryset as an argument. Then they aren't
> tied to any particular model, although I have some implicit contract
> with myself (as the user of those functions) that they querysets I pass
> in will be for objects that, say, have a "title" attribute so I can
> filter on the title.
>
> I will point out that some people like using classmethods for this sort
> of stuff. For model class-level queries -- the table-level stuff -- I
> find this looks very odd in code. It's one of those cases of not looking
> like almost all other Django code.
>
> In general, I'm fairly negative about classmethods in Python, though,
> since they're fairly unnecessary as Python already has ample namespacing
> capabilities. Other languages have classmethod equivalents because
> they're namespacing isn't as good. So you won't see me using classmethod
> style operations and there's swearing involved when I have to use
> somebody else's code that does (something that's happening in a
> side-project at the moment -- the other app is making my code looking
> fugly!)
>
>
>
> > 3) Is it a bad thing if a query inside of a Manager function uses
> > filter() to join with or even return another object type/list? This
> > obviously couples the query to the name of a model, but, also couples
> > the manager to an object that it doesn't manage. (The object that it
> > doesn't manage being joined in the query.)
>
> Trying to frame things as "bad" or "good" is probably not going to help
> very much, since it leads to discussions about what is really bad or
> good. I personally don't write things like that, since I like my
> managers methods on model X to returns things about model X.
>
> However, I'm not a slave to "everything must be in a class" and normal
> Python module-level functions are my good friends. So if I'm got
> something that is related to model X and returns something that isn't a
&g

Business Logic Architecture Questions on Models & ModelManagers

2009-04-12 Thread Sean Neilan

I'm building a large web application & I'm trying to figure out ways
to organize my business logic (just the queries). I figure I should
either put all my queries inside Model functions or ModelManager
functions. I've searched all over the internet for documentation on
where the business logic goes, but, didn't find what I was looking
for.

I have a couple questions:

1) Should Model methods not contain any queries? Only calculations
based on the attributes of that model. Much like
http://docs.djangoproject.com/en/dev/topics/db/models/#id4

2) Is it a good idea to encapsulate _all_ queries as methods inside of
a manager class? Thus making it slightly easier to reuse queries.

3) Is it a bad thing if a query inside of a Manager function uses
filter() to join with or even return another object type/list? This
obviously couples the query to the name of a model, but, also couples
the manager to an object that it doesn't manage. (The object that it
doesn't manage being joined in the query.)

4) Also, Is it possible for a ModelManager object to gain access to
request.user so that the objects returned depend on who's logged in?
Perhaps, if this is not a good design pattern (coupling the
authentication mechanisms to the ModelManager), should I simply take a
User object as a parameter on the ModelManager functions? (I'm asking
this question because perhaps there's a better way to couple the
authentication mechanism or User object to the ModelManager)

Thank you for your time.

--Sean Neilan
http://seanneilan.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: Django wont display images on my CSS file

2009-03-27 Thread Sean Brant

In most of my projects I have a img, css, js folder. In my css file I
reference images like this url(../img/path/to/img.jpg) in my css
files. The ../ basically says start the path back one directory. Not
sure if this is what's causing your problem.

On Mar 27, 8:10 am, Martin Ostrovsky 
wrote:
> I spoke too soon. Re-reading your comment, it does seem to be entirely
> a CSS/HTML issue - not Django related. Since the inlined style works,
> Django is finding the image.
>
> Sorry about that misleading response.
>
> On Mar 27, 9:07 am, Martin Ostrovsky 
> wrote:
>
> > Without seeing your settings.py file and urls.py, I can only guess,
> > but you probably don't have serving static media setup correctly. If
> > you're running this on the development server, you'll probably see a
> > 404 next to /site_media/header_background.gif in the terminal window.
> > This means Django can't find the image, probably for the reasons I
> > stated above.
>
> > If it says 200 (or 304) next to the filename in the terminal window,
> > then Django has found the image, but your CSS/HTML is the problem.
>
> > Hope that helps.
>
> > - Martin
>
> > On Mar 27, 8:33 am, Gath  wrote:
>
> > > Guys,
>
> > > Am having a problem in displaying images in my CSS file.
>
> > > I have a css file with the following class
>
> > > .header
> > > {
> > >  margin-left: auto;
> > >  bla bla
> > >  bla bla
> > >  ...
> > > background: url(/site_media/header_background.gif) no-repeat top left;
>
> > > }
>
> > > When i execute the template with this css, no image is displayed!
> > > But when i directly inject the background style on my template it
> > > works perfect.
>
> > > What am i not doing right!
>
> > > Gath
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Faster Database?

2009-02-25 Thread Sean

Hi,

I am using django+MySql.
My job involves to write a huge number of products codes into the
MySql, code such as: ABCDEFGHI10, it is typically between 1 million up
to 50 million codes within 1 file, which need to be uploaded/
downloaded into MySql.

The problem for this is it takestoo much time to insert data into the
database, a typical 10 million code file will take 3 hours at least to
load/download into MySql, it is even took a night time to process a 50
million code file, which is a nightmare. So I want to make it faster.

I got a powerful Core2 workstation and Xeron Server, which are almost
the most powerful machin I can get in the market, so hardware is not a
issue.

I guess the slow down is caused by I/O to hard-disk.

Anyone have any suggestion how can I make this process faster, or
there is any other superfast database engine than MySql?

Sean
--~--~-~--~~~---~--~~
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: select_related() and reverse foreign keys -OR- how to I get a blog post and its comments?

2009-02-24 Thread Sean Patrick Hogan
Thanks for the input!  So, I'm assuming by "easiest case" you mean just
calling LEFT OUTER JOINs.  That's Rails behavior and then it deals with it
in Ruby.  I'm not too familiar with SQLAlchemy, but it looks like that's
what they're doing in their EagerLoader as well.

The only way I can think of overcoming this would be to do an SQL UNION with
the LEFT OUTER JOIN in the union.  That way you're doing one join per UNION
clause and should end up with X + Y rows (which is better in cases of many
multiple related objects, but in the case that there is 1 or none, would
actually add more to the return set).  It's ugly because you have to specify
null fillers for the things that won't exist. As I realise how silly it was
to do an OUTER JOIN there, I retract and change it to INNER JOINs within the
UNIONs (since we don't need to get duplicate rows for relations that don't
exist).

That would seem to allow for decent iteration over something to propagate
the appropriate *_set list attributes.

To illustrate using the blog example (extended with an authors m2m
relationship so that an article can have many authors):

SELECT * FROM articles /*fill nulls for other columns, cut for readability*/
UNION
SELECT * FROM articles /*could also possibly just fill nulls for articles to
make the iteration easier*/
INNER JOIN comments ON comments.article_id=articles.id
UNION
SELECT * FROM articles
INNER JOIN authors_m2m_table ON authors_m2m_table.article_id=articles.id
INNER JOIN authors ON authors_m2m_table.author_id=authors.id


The problem with that is that any filters would have to be repeated multiple
times - like if you just wanted articles written by Malcom, you'd have to
add the explicit joins on each clause to the union.

Well, my brain has checked out for lunch so I think I'll follow it.  Maybe
someone here has a better idea.

Sean.

On Mon, Feb 23, 2009 at 6:11 PM, Malcolm Tredinnick <
malc...@pointy-stick.com> wrote:

>
> On Mon, 2009-02-23 at 21:49 +0100, Torsten Bronger wrote:
> > Hallöchen!
> >
> > Alex Gaynor writes:
> >
> > > On Mon, Feb 23, 2009 at 12:40 PM, sphogan  wrote:
>
> [...]
> > >> What I would like to be able to do is:
> > >>
> > >> Article.objects.select_related('comment_set').all()
> > >>
> > >> This seems like a somewhat simple case and there seems to be no
> > >> mention of it in the documentation anywhere.
> > >
>
> > > That's not possible,
> >
>
> > By principle, or just because Django can't do it (yet)?  The related
> > feature request can be found at
> > <http://code.djangoproject.com/ticket/2238>.
>
> Actually, this is really just a disguised version of #5768, which is
> talking about values() -- since that contains this problem plus the
> presentation issue subtlety. Read the comments there for information
> (I've repeated the basic hard part of this, below).
>
> >   It it, I refer to
> >
> http://rubynugs.blogspot.com/2008/07/couple-of-stupid-things-about-djano.html
> > where a Rails fan claims that Rails can do it.
> >
> > I don't know much about SQL so I really would like to know whether
> > this could be realised.
>
> It's possible, but it's not at all trivial. Firstly, there's a
> representation issue for values(): there are multiple *_set rows
> returned for any individual result in the original query. So it requires
> a bunch more munging of results.
>
> Secondly, there's the "don't shoot yourself in the foot" issue, in that
> it's *very* easy to create a horribly inefficient query. The problem is
> when you start querying for both foo_set and bar_set. If they return X
> and Y results, respectively, for a given row, we need to make sure we
> only get back O(X + Y) results from the database, not O(X * Y) results.
> the simplest ways to construct the query for these multi-valued returns
> leads to the second case, so extra care has to be put into the situation
> with multiple multi-valued return results.
>
> We've always said we'll put this in once there's an excellent patch that
> avoids the second problem and has a decent return format for values()
>
> Hopefully that should put to rest all the debate in this thread about
> what's going on. We'll do, but somebody has to write the patch and it's
> not trivial. (That somebody might be me one day, but I also about a few
> hundred other things to work on in Django, so it's prioritised
> accordingly).
>
> Regards,
> Malcolm
>
>
> >
>

--~--~-~--~~~---~--~~
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: select_related() and reverse foreign keys -OR- how to I get a blog post and its comments?

2009-02-23 Thread Sean Patrick Hogan
 It isn't *an* extra SQL query that I'm worried about.  It's that it's going
to be about 2,000 extra SQL queries in a loop.  If it were just constructing
a page with one item and then its related items, that's not a problem to do
two queries, but when you're looping over 2,000 items and running an extra
query for all 2,000, it becomes a large performance issue.  When you're
dealing with that many items, it does affect the viability of your
application.

Rails can do this.  However, the problem isn't a simple one to solve.  I'll
probably look at their code sometime later this week.  Going back to my
example, SQL is going to give you the list of tuples of scalars as Aaron
notes.  This isn't a problem that SQL can solve since an SQL result set will
look like a spreadsheet and (for obvious reasons) you just can't have many
related objects shown in a spreadsheet.

BUT, you can iterate over objects in python.  So, let's say I had this
result set:
Article1, Comment1
Article 1, Comment 4
Article 1, Comment 8
Article 2, Comment 3
Article 2 Comment5

Ugly!  But I could loop over that and aggregate them together as such:

final_results = []
for item in results:
  if item.pk != last_item.pk:
final_results.append(item)
  item.comment_set = []
  item.comment_set.append(#a comment object from those columns)
  last_item = item

Basically, each loop you look to see if it's the same article and so you
realise that you should only be appending the comment to the comments list.
That seems easy enough, but then what do you do when you have multiple
relations you're trying to get in the select_related?  It gets a lot harder.

Anyway, I'll look over the Rails source sometime later this week and see if
there is a simple enough pattern to port or maybe just hack a simple case
through for single calls for the reverse relationship which isn't so hard.

One thing that would be nice, however, is if select_related() would raise an
exception when you tried to call it and passed in a name that wasn't a
foreign key (and therefore it couldn't get) so that you'd get an error
message rather than having that error message pass silently.

Errors should never pass silently.
Unless explicitly silenced.
~Zen of Python

Well, I guess I have a project for this week!
Sean.



On Mon, Feb 23, 2009 at 3:55 PM, Alex Gaynor  wrote:

>
>
> On Mon, Feb 23, 2009 at 3:49 PM, Torsten Bronger <
> bron...@physik.rwth-aachen.de> wrote:
>
>>
>> Hallöchen!
>>
>> Alex Gaynor writes:
>>
>> > On Mon, Feb 23, 2009 at 12:40 PM, sphogan  wrote:
>> >
>> >> [...]
>> >>
>> >> However, select_related() only works on the object the foreign
>> >> key is declared on
>> >> (http://docs.djangoproject.com/en/dev/ref/models/querysets/ #id4
>> >> <http://docs.djangoproject.com/en/dev/ref/models/querysets/%0A#id4>;
>> >> specifically, "You can only refer to ForeignKey relations in the
>> >> list of fields passed to select_related.")  Presumably this is
>> >> because it does an INNER JOIN rather than a LEFT OUTER JOIN and
>> >> would therefore miss articles with no comments.
>> >>
>> >> What I would like to be able to do is:
>> >>
>> >> Article.objects.select_related('comment_set').all()
>> >>
>> >> This seems like a somewhat simple case and there seems to be no
>> >> mention of it in the documentation anywhere.
>> >
>> > That's not possible,
>>
>> By principle, or just because Django can't do it (yet)?  The related
>> feature request can be found at
>> <http://code.djangoproject.com/ticket/2238>.  It it, I refer to
>>
>> http://rubynugs.blogspot.com/2008/07/couple-of-stupid-things-about-djano.html
>> where a Rails fan claims that Rails can do it.
>>
>> I don't know much about SQL so I really would like to know whether
>> this could be realised.
>>
>> Tschö,
>> Torsten.
>>
>> --
>> Torsten Bronger, aquisgrana, europa vetus
>>   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
>>
>>
>>
>>
> I have no idea if it's possible, by my inclination is that it isn't since
> no one seems to have ponied up the SQL to make it happen :) .  Further SQL
> generally returns a list of tuples of scalars(to use there python datatypes)
> SQL doesn't really ever return a collection, so my inclination is that it
> can't.  Someone better versed in SQL can probably say for sure.  Regardless
> it's still easy to get the data:
>
> p =Post.object.get(pk=2)
> p.comment_set.all() # all the comments for that post.
>
> Alex
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
>
> >
>

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



Re: Problem outputting date in template as timestamp

2009-02-21 Thread Sean Brant

BTW, That is with a timezone of "America/New_York"

On Feb 21, 1:05 pm, Sean Brant  wrote:
> Would something like this work?
>
> def U(self):
>     "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)"
>     import calendar
>     timestamp = calendar.timegm(self.data.timetuple())
>     return timestamp + time.timezone
>
> Test:
> r""">>> print dateformat.format(my_birthday, 'U')
>
> 40437
> """
>
> from django.utils import dateformat, translation
> import datetime
>
> my_birthday = datetime.datetime(1982, 10, 25)
>
> On Feb 20, 7:17 pm, Malcolm Tredinnick 
> wrote:
>
> > On Fri, 2009-02-20 at 19:45 -0500, Karen Tracey wrote:
>
> > [...]
>
> > > Near as I can tell, also, the "U" date-formatting implementation
> > > doesn't work.  It is:
>
> > >     def U(self):
> > >         "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)"
> > >         off = self.timezone.utcoffset(self.data)
> > >         return int(time.mktime(self.data.timetuple())) + off.seconds *
> > > 60
>
> > Wow, that code's really old (like 2005 old). Possibly marked as
> > unimplemented because Adrian knew it was broken and wanted to fix it, or
> > something.
>
> > [...]
>
> > > So this is what off winds up being:
>
> > > >>> off = df.timezone.utcoffset(x)
> > > >>> off
> > > datetime.timedelta(-1, 68400)
> > > >>> off.days
> > > -1
> > > >>> off.seconds
> > > 68400
>
> > > This is negative one day, plus 68,4000 seconds, equivalent to -18,000
> > > seconds, but the subsequent code:
>
> > > return int(time.mktime(self.data.timetuple())) + off.seconds * 60
>
> > > doesn't consider the negative days value and just uses the 68,4000
> > > seconds value, so that's a problem.
>
> > That's a lovely trap in the timedelta API that regularly catches people
> > out (including me, regularly enough, when I forget it happens). When we
> > were implementing timezone support for syndicated feeds at the
> > Washington DC sprint last year, I seem to recall it took a large portion
> > of the time spent on that issue just to get things working for timezones
> > west of UTC due to that "feature".
>
> > If somebody wants to fix this robustly, I'd strongly suggest swiping the
> > offset computation code from django.utils.feedgenerator. Both the
> > rfc822_date() and rfc3339_date() functions do the computation correctly.
>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem outputting date in template as timestamp

2009-02-21 Thread Sean Brant

Would something like this work?

def U(self):
"Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)"
import calendar
timestamp = calendar.timegm(self.data.timetuple())
return timestamp + time.timezone

Test:
r"""
>>> print dateformat.format(my_birthday, 'U')
40437
"""

from django.utils import dateformat, translation
import datetime

my_birthday = datetime.datetime(1982, 10, 25)

On Feb 20, 7:17 pm, Malcolm Tredinnick 
wrote:
> On Fri, 2009-02-20 at 19:45 -0500, Karen Tracey wrote:
>
> [...]
>
> > Near as I can tell, also, the "U" date-formatting implementation
> > doesn't work.  It is:
>
> >     def U(self):
> >         "Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)"
> >         off = self.timezone.utcoffset(self.data)
> >         return int(time.mktime(self.data.timetuple())) + off.seconds *
> > 60
>
> Wow, that code's really old (like 2005 old). Possibly marked as
> unimplemented because Adrian knew it was broken and wanted to fix it, or
> something.
>
> [...]
>
>
>
> > So this is what off winds up being:
>
> > >>> off = df.timezone.utcoffset(x)
> > >>> off
> > datetime.timedelta(-1, 68400)
> > >>> off.days
> > -1
> > >>> off.seconds
> > 68400
>
> > This is negative one day, plus 68,4000 seconds, equivalent to -18,000
> > seconds, but the subsequent code:
>
> > return int(time.mktime(self.data.timetuple())) + off.seconds * 60
>
> > doesn't consider the negative days value and just uses the 68,4000
> > seconds value, so that's a problem.
>
> That's a lovely trap in the timedelta API that regularly catches people
> out (including me, regularly enough, when I forget it happens). When we
> were implementing timezone support for syndicated feeds at the
> Washington DC sprint last year, I seem to recall it took a large portion
> of the time spent on that issue just to get things working for timezones
> west of UTC due to that "feature".
>
> If somebody wants to fix this robustly, I'd strongly suggest swiping the
> offset computation code from django.utils.feedgenerator. Both the
> rfc822_date() and rfc3339_date() functions do the computation correctly.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem outputting date in template as timestamp

2009-02-20 Thread Sean Brant

> I asked a similar question a while ago... turns out the server i'm
> using from godaddy was set for Arizona and was an additional 20 some
> minutes off...

I checked my server and the timezone is set to US/CENTRAL and my
settings file is set to America/Chicago. So that should be the same.
Plus the time is off by ~14 days.

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



Problem outputting date in template as timestamp

2009-02-20 Thread Sean Brant

I am trying to render a timestamp in my template with date:"U" but the
timestamps are days off. I wrote up a simple test case that fails. Do
you think this is a bug or a user error? I am running rev: 9846.

from django.test import TestCase

class SimpleTest(TestCase):
def test_template_timestamp(self):
from datetime import datetime
from django.template import Context, Template
now = datetime.now()
t = Template('{{ now|date:"U" }}')
c = Context({'now': now})
self.failUnlessEqual(int(now.strftime('%s')), int(t.render
(c)))

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



Re: Query that grabs objects before and after object

2009-02-19 Thread Sean Brant

> current_show = 5 #Presumably you get this in your request
> show_range = (current_show - 4, current_show + 4)
> shows = Show.objects.filter(show_order__range=show_range)

This seems to work so far.

shows = Show.objects.filter(Q(pk__range=(show_id - 4, show_id + 4) & Q
(category=category))

Behind the scenes it preforms a BETWEEN query.

Thanks to all for the 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
-~--~~~~--~~--~--~---



Query that grabs objects before and after object

2009-02-18 Thread Sean Brant

Is there a simple way to say get me 4 objects from model that come
before this object and 4 that come after this object.

So lets say I have a Show. I would like to know which 4 shows come
before the current show and which 4 come after, however I must limit
the shows based on a category type. Would slicing work for this?

If this is not sure clear let me know and I will try and clarify more.
--~--~-~--~~~---~--~~
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: Svn pre-commit hooks with beanstalkapp.com

2009-02-15 Thread Sean Brant

In case anyone else in interested I whipped up this simple script that
seems to do the job.

http://dpaste.com/121117/

It basically works like svn commit but looks thru all of directories
under your current directory for manage.py files. If it finds one it
runs manage.py test. If all tests pass it runs svn commit passing your
arguments thru.
--~--~-~--~~~---~--~~
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   3   >