Wednesday, February 29, 2012

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

subprocess

Hi ,

i am using django  s view function to invoke python script to run in background.
now i want to pass command line args to the script

here is wat i did

subprocess.Popen([sys.executable,"script_name","command_args1"])

i got the error 

execv requires arg 2 to be a string

please help me 

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

view the code in .vmdk .vmx files

I am now migrating from one version to another. the vendors have given
my just 3 files with .vmdk and .vmx extension. however i installed
vmware and finished the setup though, i wanted to view the code of my
new version. any idea how to view the code of the product in vmware?
Thanks in advance.

Regards,
Kalyani

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

Re: Filtering model searches by a property (as opposed to a field)

Thank you very much for that Javier.

After flailing around with raw SQL for a while I realised that Django
has conveniently provided a powerful set of field lookups that I did
not know about.

I have ended up doing this, which is a million times simpler than what
I was previously attempting:

<views.py>
...
date = datetime.date.today()
day_of_the_week = date.weekday()
last_date_in_week = date + datetime.timedelta(days = 7 -
day_of_the_week)
week = Todo.objects.filter(owner__id =
user.id).filter(due_date__lte=last_date_in_week).filter(due_date__gt=date)
...
</views.py>

This gives me 'todo' objects from tomorrow until the end of the week,
which is what I want.

On Mar 1, 3:35 am, Javier Guerra Giraldez <jav...@guerrag.com> wrote:
> On Wed, Feb 29, 2012 at 3:16 PM, Tom <t.scr...@gmail.com> wrote:
> > Is it not possible to filter based on a property?
>
> queries are compiled to SQL to be sent and processed at the database;
> properties are Python code, the database knows nothing about them.
> that's why the compiler only allows you to use database fields on a
> filter
>
> > What is the correct method for doing this?
>
> the generic answer is to do it in Python, something like:
>
> result = [ record in queryset if record.property == value ]
>
> but this can be very inefficient, and nowhere as flexible as Django's querysets.
>
> much better is to translate the criteria into something the database
> can process.  In this case, find the beginning and end of the current
> week and use a range filter.
>
> --
> Javier

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

Tabularinline in CreateView ?????????????

Hi all:

My ask is here: http://dpaste.com/709735/

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

Re: Filtering model searches by a property (as opposed to a field)

On Wed, Feb 29, 2012 at 3:16 PM, Tom <t.scrace@gmail.com> wrote:
> Is it not possible to filter based on a property?

queries are compiled to SQL to be sent and processed at the database;
properties are Python code, the database knows nothing about them.
that's why the compiler only allows you to use database fields on a
filter


> What is the correct method for doing this?

the generic answer is to do it in Python, something like:

result = [ record in queryset if record.property == value ]

but this can be very inefficient, and nowhere as flexible as Django's querysets.

much better is to translate the criteria into something the database
can process. In this case, find the beginning and end of the current
week and use a range filter.


--
Javier

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

Re: using django templates to generate and replace a file

Hey,

I just thought I'd give you a quick reply. First, you can save the rendered output of a template using this:


Then, take that String and write over that 'users.cfg' file. For example,


Hopefully that helps a little bit. I'm not sure if I understand the problem right but I figured I'd give it a shot.

Good luck!
- Kurtis

On Wed, Feb 29, 2012 at 4:27 PM, Paul Bunker <paulmarkbunker@gmail.com> wrote:
Hi Django Users,

I'd like to use the django template system to generate a file
'users.cfg' that gets read some dispatching software. Is it possible
to get django  to generate this file and replace the existing one?

Thanks
-Paul

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


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

Re: Keeping filters when adding in the admin interface

On Wed, Feb 29, 2012 at 10:55 PM, Marc Aymerich <glicerinu@gmail.com> wrote:
> On Wed, Feb 29, 2012 at 8:22 PM, Mauro Sánchez <mauroka@gmail.com> wrote:
>> Hello, if I have the following Model:
>>
>> class A:
>>    name
>>
>> class B:
>>    name
>>    a = models.ForeignKey(A)
>>
>> class C:
>>    name
>>    b = models.ForeignKey(B)
>>
>> And let's suppose that in the Admin Site I have a Filter in the C list
>> that refers to the A model. Is there a way to keep that filter when I
>> am going to add a new C object and use it to filter the combobox of
>> the b filed so that it will only show the b objects that are related
>> to the A model in the filter?
>> For example:
>> If the filter I choose points to the id=1 in the A model, the combobox
>> for the b field when I add a C object only has to show the B objects
>> that has a = 1
>>
>
> If I understand you righ, it's a bit triky stuff, you have to do two things:
> 1)  Define a custom add_form and override their __init__ method with
> something like:
>  self.fields['b'].queryset = self.fields['b'].queryset.filter(a=a_pk)
> 2)  Provides the current value of your filter (a_pk) to the defined form on 1)
>  I think this can be done overriding modeladmin.get_form() method
> since request is one of their args, so you can extract the value of
> the filter on the http referer url and provide it to the form that
> this method creates.
>

More specifically:

def get_form(self, request, *args **kwargs):
form = super(YourModelAdmin, self).get_form(request, *args, **kwargs)
a_pk = get_a_pk_from_http_referer(request)
form.a_pk = a_pk
return form

def __init__(self, *args, **kwargs):
super(YourModelForm, self).__init__(*args, **kwargs)
self.fields['b'].queryset = self.fields['b'].queryset.filter(a=self.a_pk)

--
Marc

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

Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/

On Wednesday, 29 February 2012 20:03:21 UTC, Django_for_SB wrote:
Hi Anoop,

Thank you for the kind reply, I've tried that already. Here are the 3 variations that I've attempted so far within settings.py in TEMPLATE_DIRS:

'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/index.html'
'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/'
'C:/Python27/my_Djando_projects/mysite/My_Templates/'


They all yield the same error unfortunately. I'm coding this on a Windows Vista system, fyi.

Best,

SB

On Wed, Feb 29, 2012 at 11:48 AM, Anoop Thomas Mathew wrote:
You have to give template directories, not template names in the settings.py.
Thanks,
Anoop
atm
___
Life is short, Live it hard.


You also need to separate the different strings with commas. Otherwise Python will automatically concatenate them, as they are within parentheses.
--
DR. 

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

Re: Keeping filters when adding in the admin interface

On Wed, Feb 29, 2012 at 8:22 PM, Mauro Sánchez <mauroka@gmail.com> wrote:
> Hello, if I have the following Model:
>
> class A:
>    name
>
> class B:
>    name
>    a = models.ForeignKey(A)
>
> class C:
>    name
>    b = models.ForeignKey(B)
>
> And let's suppose that in the Admin Site I have a Filter in the C list
> that refers to the A model. Is there a way to keep that filter when I
> am going to add a new C object and use it to filter the combobox of
> the b filed so that it will only show the b objects that are related
> to the A model in the filter?
> For example:
> If the filter I choose points to the id=1 in the A model, the combobox
> for the b field when I add a C object only has to show the B objects
> that has a = 1
>

If I understand you righ, it's a bit triky stuff, you have to do two things:
1) Define a custom add_form and override their __init__ method with
something like:
self.fields['b'].queryset = self.fields['b'].queryset.filter(a=a_pk)
2) Provides the current value of your filter (a_pk) to the defined form on 1)
I think this can be done overriding modeladmin.get_form() method
since request is one of their args, so you can extract the value of
the filter on the http referer url and provide it to the form that
this method creates.


--
Marc

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

Re: Unicode lists and form submissions

Found an answer here http://stackoverflow.com/questions/9210117/attributeerror-str-object-has-no-attribute-n-when-using-dateutil

Thanks guys.

On 1 March 2012 00:30, Mario Gudelj <mario.gudelj@gmail.com> wrote:
Hi djangoers,

I've ran into an issue I'm not sure how to handle.

I have a form with 7 checkboxes representing 7 days of the week. I want to collect the submitted days and use them in rrule to generate some dates.

The form field looks like this:

weekly_interval = forms.MultipleChoiceField(label='Repeat on:', choices=EventSeries.weekly_interval,widget=forms.CheckboxSelectMultiple, required=False)

The choices are generated from this:

weekly_interval = (
        (rrule.SU, 'Sun'),
        (rrule.MO, 'Mon'),
        (rrule.TU, 'Tue'),
        (rrule.WE, 'Wed'),
        (rrule.TH, 'Thu'),
        (rrule.FR, 'Fri'),
        (rrule.SA, 'Sat')
    )

So, the form renders and everything is fine, but once I submit the form, the data is in incorrect format and I'm not sure how to fix it.

This is how I'm collecting the interval:

interval=form.cleaned_data['weekly_interval']

Then I'm using it in this line:

start_dates = list(rrule.rrule(rrule.WEEKLY, count=self.recurrences, byweekday=self.interval, dtstart=self.start_datetime))

My problem is in this byweekday=self.interval

If I test this form console with the following it works fine

start_dates = list(rrule.rrule(rrule.WEEKLY, count=a_s.recurrences, byweekday=(rrule.MO,rrule.TU), dtstart=appt.start_time))

But when I look at the interval submitted from the form using pdb it looks like this [u'WE', u'TH', u'SA']

I suspect that I need to convert this from unicode to objects. Does anyone know the best approach? And what it would be? 

Thanks a million!

-m

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

using django templates to generate and replace a file

Hi Django Users,

I'd like to use the django template system to generate a file
'users.cfg' that gets read some dispatching software. Is it possible
to get django to generate this file and replace the existing one?

Thanks
-Paul

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

jython django install - django import error

Hi,
I have problems installing django for jyhton.
I followed instructions on the django / django-jython site, but can't
import django from jython.

Jython 2.5.3b1
django_jython-1.3.0b2

### INSTALLATION
# after
# - installing jython
# - adding JYTHON_DIR/bin to path:
> jython pip install django-jython

...installs fine


### USE
> jython
Jython 2.5.3b1 (2.5:5fa0a5810b25, Feb 22 2012, 12:39:02)
[Java HotSpot(TM) Server VM (Sun Microsystems Inc.)] on java1.6.0_26
Type "help", "copyright", "credits" or "license" for more information.

>>> import doj
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django

***
importing 'doj' works fine though. But there is no 'django'.
I tried to put pyhon's django to JYTHONPATH:
/usr/local/lib/python2.7/dist-packages/django

Still no luck.

Do I miss something?
Otherwise django on python seems to work fine.

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

Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/

Try:
'C:\Python27\my_Djando_projects\mysite\My_Templates\polls\index.html'
'C:\Python27\my_Djando_projects\mysite\My_Templates\polls\'
'C:\Python27\my_Djando_projects\mysite\My_Templates\'

Or:
abspath = lambda *p: os.path.abspath(os.path.join(*p))
PROJECT_ROOT = abspath(os.path.dirname(__file__))
(...)
TEMPLATE_DIRS = (abspath(PROJECT_ROOT, "My_Templates"),)




2012/2/29 Sami Balbaky <sami.balbaky@gmail.com>
Hi Anoop,

Thank you for the kind reply, I've tried that already. Here are the 3 variations that I've attempted so far within settings.py in TEMPLATE_DIRS:

'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/index.html'
'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/'
'C:/Python27/my_Djando_projects/mysite/My_Templates/'


They all yield the same error unfortunately. I'm coding this on a Windows Vista system, fyi.

Best,

SB


On Wed, Feb 29, 2012 at 11:48 AM, Anoop Thomas Mathew <atmb4u@gmail.com> wrote:
You have to give template directories, not template names in the settings.py.
Thanks,
Anoop
atm
___
Life is short, Live it hard.





On 1 March 2012 01:16, Django_for_SB <sami.balbaky@gmail.com> wrote:
Hello All,

I'm going through the tutorial on djangoproject.com, and can't seem to
hurdle over this section that reads "Write views that actually do
something"

Here's the code I have so far, which is directly copied from the
tutorial or prescribed by the tutorial:

views.py:
"from django.template import Context, loader
from polls.models import Poll
from django.http import HttpResponse

def index(request):
   latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
   t = loader.get_template('polls/index.html')
   c = Context({
       'latest_poll_list': latest_poll_list,
   })
   return HttpResponse(t.render(c))"



settings.py:
"...
TEMPLATE_DIRS = (
   # Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
   # Always use forward slashes, even on Windows.
   # Don't forget to use absolute paths, not relative paths.
   'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/
base_site.html'
   'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/
index.html'
   'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/
index.html'
)
..."


index.html:
"{% if latest_poll_list %}
   <ul>
   {% for poll in latest_poll_list %}
       <li><a href="/polls/{{ poll.id }}/">{{ poll.question }}</a></
li>
   {% endfor %}
   </ul>
{% else %}
   <p>No polls are available.</p>
{% endif %}
"




I keep getting the same error, which reads:


TemplateDoesNotExist at /polls/

polls/index.html

Request Method:         GET
Request URL:            http://localhost:8000/polls/
Django Version:                 1.3.1
Exception Type:         TemplateDoesNotExist
Exception Value:

polls/index.html

Exception Location:     C:\Python27\lib\site-packages\django\template
\loader.py in find_template, line 138
Python Executable:      C:\Python27\python.exe
Python Version:         2.7.2
Python Path:

['C:\\Python27\\my_Djando_projects\\mysite',
 'C:\\Windows\\system32\\python27.zip',
 'C:\\Python27\\DLLs',
 'C:\\Python27\\lib',
 'C:\\Python27\\lib\\plat-win',
 'C:\\Python27\\lib\\lib-tk',
 'C:\\Python27',
 'C:\\Python27\\lib\\site-packages']

Server time:    Wed, 29 Feb 2012 11:32:54 -0800
Template-loader postmortem

Django tried loading these templates, in this order:

Using loader django.template.loaders.filesystem.Loader:
c:\python27\my_djando_projects\mysite\my_templates\admin
\base_site.html
c:\python27\my_djando_projects\mysite\my_templates\admin\index.html
c:\python27\my_djando_projects\mysite\my_templates\polls\index.html
\polls\index.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
c:\python27\lib\site-packages\django\contrib\admin\templates\polls
\index.html (File does not exist)




What on earth am I doing wrong here? I've so many different variations
of my settings.py, views.py, and index.html. Any help would be much
appreciated.


Thanks,

SB

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


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



--
Sami Balbaky
System Engineer - Ultrawave Labs


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

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

Filtering model searches by a property (as opposed to a field)

Hi all,

I have the following model:

<models.py>
class Todo(models.Model):
name = models.CharField(max_length=200)
due_date = models.DateTimeField()
location = models.CharField(max_length=200)
type = models.CharField(max_length=4, choices=TODO_TYPES)
owner = models.ForeignKey(User, verbose_name='owner')
done = models.BooleanField(default=False)
def _get_due_week(self):
return int(self.due_date.strftime("%W"))
due_week = property(_get_due_week)
def __unicode__(self):
return self.name
</models.py>

and this search code:

<views.py>
...
user = request.user
this_week = int(date.strftime("%W"))
this_weeks_todos =
Todo.objects.filter(owner__id=user.id).filter(due_week=this_week)
...
</views.py>

But I get:

"Cannot resolve keyword 'due_week' into field. Choices are: done,
due_date, id, location, name, owner, type"

Is it not possible to filter based on a property?

What is the correct method for doing this?

Thanks in advance for your help.

Tom

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

Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/

Hi Anoop,

Thank you for the kind reply, I've tried that already. Here are the 3 variations that I've attempted so far within settings.py in TEMPLATE_DIRS:

'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/index.html'
'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/'
'C:/Python27/my_Djando_projects/mysite/My_Templates/'


They all yield the same error unfortunately. I'm coding this on a Windows Vista system, fyi.

Best,

SB

On Wed, Feb 29, 2012 at 11:48 AM, Anoop Thomas Mathew <atmb4u@gmail.com> wrote:
You have to give template directories, not template names in the settings.py.
Thanks,
Anoop
atm
___
Life is short, Live it hard.





On 1 March 2012 01:16, Django_for_SB <sami.balbaky@gmail.com> wrote:
Hello All,

I'm going through the tutorial on djangoproject.com, and can't seem to
hurdle over this section that reads "Write views that actually do
something"

Here's the code I have so far, which is directly copied from the
tutorial or prescribed by the tutorial:

views.py:
"from django.template import Context, loader
from polls.models import Poll
from django.http import HttpResponse

def index(request):
   latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
   t = loader.get_template('polls/index.html')
   c = Context({
       'latest_poll_list': latest_poll_list,
   })
   return HttpResponse(t.render(c))"



settings.py:
"...
TEMPLATE_DIRS = (
   # Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
   # Always use forward slashes, even on Windows.
   # Don't forget to use absolute paths, not relative paths.
   'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/
base_site.html'
   'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/
index.html'
   'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/
index.html'
)
..."


index.html:
"{% if latest_poll_list %}
   <ul>
   {% for poll in latest_poll_list %}
       <li><a href="/polls/{{ poll.id }}/">{{ poll.question }}</a></
li>
   {% endfor %}
   </ul>
{% else %}
   <p>No polls are available.</p>
{% endif %}
"




I keep getting the same error, which reads:


TemplateDoesNotExist at /polls/

polls/index.html

Request Method:         GET
Request URL:            http://localhost:8000/polls/
Django Version:                 1.3.1
Exception Type:         TemplateDoesNotExist
Exception Value:

polls/index.html

Exception Location:     C:\Python27\lib\site-packages\django\template
\loader.py in find_template, line 138
Python Executable:      C:\Python27\python.exe
Python Version:         2.7.2
Python Path:

['C:\\Python27\\my_Djando_projects\\mysite',
 'C:\\Windows\\system32\\python27.zip',
 'C:\\Python27\\DLLs',
 'C:\\Python27\\lib',
 'C:\\Python27\\lib\\plat-win',
 'C:\\Python27\\lib\\lib-tk',
 'C:\\Python27',
 'C:\\Python27\\lib\\site-packages']

Server time:    Wed, 29 Feb 2012 11:32:54 -0800
Template-loader postmortem

Django tried loading these templates, in this order:

Using loader django.template.loaders.filesystem.Loader:
c:\python27\my_djando_projects\mysite\my_templates\admin
\base_site.html
c:\python27\my_djando_projects\mysite\my_templates\admin\index.html
c:\python27\my_djando_projects\mysite\my_templates\polls\index.html
\polls\index.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
c:\python27\lib\site-packages\django\contrib\admin\templates\polls
\index.html (File does not exist)




What on earth am I doing wrong here? I've so many different variations
of my settings.py, views.py, and index.html. Any help would be much
appreciated.


Thanks,

SB

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


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



--
Sami Balbaky
System Engineer - Ultrawave Labs

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

Re: Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/

You have to give template directories, not template names in the settings.py.
Thanks,
Anoop
atm
___
Life is short, Live it hard.




On 1 March 2012 01:16, Django_for_SB <sami.balbaky@gmail.com> wrote:
Hello All,

I'm going through the tutorial on djangoproject.com, and can't seem to
hurdle over this section that reads "Write views that actually do
something"

Here's the code I have so far, which is directly copied from the
tutorial or prescribed by the tutorial:

views.py:
"from django.template import Context, loader
from polls.models import Poll
from django.http import HttpResponse

def index(request):
   latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
   t = loader.get_template('polls/index.html')
   c = Context({
       'latest_poll_list': latest_poll_list,
   })
   return HttpResponse(t.render(c))"



settings.py:
"...
TEMPLATE_DIRS = (
   # Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
   # Always use forward slashes, even on Windows.
   # Don't forget to use absolute paths, not relative paths.
   'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/
base_site.html'
   'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/
index.html'
   'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/
index.html'
)
..."


index.html:
"{% if latest_poll_list %}
   <ul>
   {% for poll in latest_poll_list %}
       <li><a href="/polls/{{ poll.id }}/">{{ poll.question }}</a></
li>
   {% endfor %}
   </ul>
{% else %}
   <p>No polls are available.</p>
{% endif %}
"




I keep getting the same error, which reads:


TemplateDoesNotExist at /polls/

polls/index.html

Request Method:         GET
Request URL:            http://localhost:8000/polls/
Django Version:                 1.3.1
Exception Type:         TemplateDoesNotExist
Exception Value:

polls/index.html

Exception Location:     C:\Python27\lib\site-packages\django\template
\loader.py in find_template, line 138
Python Executable:      C:\Python27\python.exe
Python Version:         2.7.2
Python Path:

['C:\\Python27\\my_Djando_projects\\mysite',
 'C:\\Windows\\system32\\python27.zip',
 'C:\\Python27\\DLLs',
 'C:\\Python27\\lib',
 'C:\\Python27\\lib\\plat-win',
 'C:\\Python27\\lib\\lib-tk',
 'C:\\Python27',
 'C:\\Python27\\lib\\site-packages']

Server time:    Wed, 29 Feb 2012 11:32:54 -0800
Template-loader postmortem

Django tried loading these templates, in this order:

Using loader django.template.loaders.filesystem.Loader:
c:\python27\my_djando_projects\mysite\my_templates\admin
\base_site.html
c:\python27\my_djando_projects\mysite\my_templates\admin\index.html
c:\python27\my_djando_projects\mysite\my_templates\polls\index.html
\polls\index.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
c:\python27\lib\site-packages\django\contrib\admin\templates\polls
\index.html (File does not exist)




What on earth am I doing wrong here? I've so many different variations
of my settings.py, views.py, and index.html. Any help would be much
appreciated.


Thanks,

SB

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


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

Error on Tutorial Part 3 - https://docs.djangoproject.com/en/1.3/intro/tutorial03/

Hello All,

I'm going through the tutorial on djangoproject.com, and can't seem to
hurdle over this section that reads "Write views that actually do
something"

Here's the code I have so far, which is directly copied from the
tutorial or prescribed by the tutorial:

views.py:
"from django.template import Context, loader
from polls.models import Poll
from django.http import HttpResponse

def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
t = loader.get_template('polls/index.html')
c = Context({
'latest_poll_list': latest_poll_list,
})
return HttpResponse(t.render(c))"

settings.py:
"...
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/
django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/
base_site.html'
'C:/Python27/my_Djando_projects/mysite/My_Templates/admin/
index.html'
'C:/Python27/my_Djando_projects/mysite/My_Templates/polls/
index.html'
)
..."


index.html:
"{% if latest_poll_list %}
<ul>
{% for poll in latest_poll_list %}
<li><a href="/polls/{{ poll.id }}/">{{ poll.question }}</a></
li>
{% endfor %}
</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}
"


I keep getting the same error, which reads:


TemplateDoesNotExist at /polls/

polls/index.html

Request Method: GET
Request URL: http://localhost:8000/polls/
Django Version: 1.3.1
Exception Type: TemplateDoesNotExist
Exception Value:

polls/index.html

Exception Location: C:\Python27\lib\site-packages\django\template
\loader.py in find_template, line 138
Python Executable: C:\Python27\python.exe
Python Version: 2.7.2
Python Path:

['C:\\Python27\\my_Djando_projects\\mysite',
'C:\\Windows\\system32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages']

Server time: Wed, 29 Feb 2012 11:32:54 -0800
Template-loader postmortem

Django tried loading these templates, in this order:

Using loader django.template.loaders.filesystem.Loader:
c:\python27\my_djando_projects\mysite\my_templates\admin
\base_site.html
c:\python27\my_djando_projects\mysite\my_templates\admin\index.html
c:\python27\my_djando_projects\mysite\my_templates\polls\index.html
\polls\index.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
c:\python27\lib\site-packages\django\contrib\admin\templates\polls
\index.html (File does not exist)


What on earth am I doing wrong here? I've so many different variations
of my settings.py, views.py, and index.html. Any help would be much
appreciated.


Thanks,

SB

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

Keeping filters when adding in the admin interface

Hello, if I have the following Model:

class A:
name

class B:
name
a = models.ForeignKey(A)

class C:
name
b = models.ForeignKey(B)

And let's suppose that in the Admin Site I have a Filter in the C list
that refers to the A model. Is there a way to keep that filter when I
am going to add a new C object and use it to filter the combobox of
the b filed so that it will only show the b objects that are related
to the A model in the filter?
For example:
If the filter I choose points to the id=1 in the A model, the combobox
for the b field when I add a C object only has to show the B objects
that has a = 1

Is there a way to do this?
Thanks a lot for the help.
Greetings.
Mauro.

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

Re: Error while importing URLconf 'permitprint.urls': day is out of range for month

furby wrote:

> Caught it. Haha. What a funny bug. From models.py:
>
> 196 d = dt.datetime.today()
> 197 expires = d.replace(year=d.year+1)
>
> There is no Feb. 29th, 2013. So this breaks. Thx for the help!
>
> On Feb 29, 9:50 am, Tom Evans <tevans...@googlemail.com> wrote:
>> On Wed, Feb 29, 2012 at 3:33 PM, furby <jasonno...@gmail.com> wrote:
>> > The guy I built this for does not want to pay me to maintain it, so
>> > it's still on .96. And yet when something breaks randomly he wonders
>> > why. Debug enabled today for debugging. There is no dev
>> > environment. Only production for this.
>>
>> Customer is always right. Plus, job for life ;)
>>
>>
>>
>> > Here's the urlconf. I've literally commented out every urlpattern
>> > expect the top one on line 4. Still breaks:
>>
>> > 1 from django.conf.urls.defaults import *
>> > 2 from permitprint.app.models import *
>> > 3 urlpatterns = patterns('django.views.generic.simple',
>> > 4 (r'^/?$', 'direct_to_template', {'template': 'index.html'}),
>> > 5 """
>>
>> Hmmpf. One of the things improved since 0.96 is that error reporting
>> of this kind has improved. There is an import error coming from one of
>> the imports in the urlconf, and that is why it cannot import the
>> urlconf. Is there any date handling code in the top level of the
>> permitprint.app.models?
>>
>> Cheers
>>
>> Tom
>
Perhaps not entirely coincidentally, Michael Foord blogged about this today:

http://www.voidspace.org.uk/python/weblog/arch_d7_2012_02_25.shtml#e1235

Cheers,

Kev

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

Loading multi-line SQL as part of syncdb

The problem is: This doesn't work, as is well-known, because the current code breaks sql/<modelname>.sql files into lines, and that fails if the SQL statement is multiline.

The fix is generally noted to be, to quote mtredinnick on bug #3214:

> If you want to pass in complex SQL, catch the post-syncdb signal and work directly with a django.db.backend.cursor. You will know precisely what database you're talking to and can use the appropriate syntax and calling mechanisms.

Except the documentation of the post_syncdb signal says:

> It is important that handlers of this signal perform idempotent changes (e.g. no database alterations) as this may cause the flush management command to fail if it also ran during the syncdb command.

So, either the documentation is overstating the case, or the proposed solution is wrong. Any guidance as to the right way to apply multi-line SQL during syncdb?

Best,
--
-- Christophe Pettus
xof@thebuild.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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

DateField - format in Django 1.3.1

Hi,

I saw there was some problems in the format which is rendered,
validated and stored using a DateField in a form, and in a model. Are
they still unresolved in 1.3.1 versio?, it's not working for me ....

My form:
32 class EventForm(forms.Form):
33 name =
forms.CharField(label=_('name'),max_length=100,required=True)
34 startDate = forms.DateField(input_formats=['%d/%m/
%Y'],label=_('sta rtDate'),
required=False,initial=datetime.date.today)
35 endDate = forms.DateField(input_formats=['%d/%m/
%Y'],label=_('endDa te'),
required=False,initial=datetime.date.today)


My model:
34 class Event(models.Model):
35 eventID = models.AutoField(primary_key=True)
36 name = models.CharField(max_length=100,null=False,blank=False)
38 startDate = models.DateField('%d/%m/
%Y',null=True,blank=False,default=date.today)
39 endDate = models.DateField('%d/%m/
%Y',null=True,blank=False,default=date.today)

And the POST message:
POST:<QueryDict: {u'startDate': [u'01/01/2012'], u'endDate':
[u'31/12/2012'], u'name': [Year 2012']}>,

The render is properly drawn.

Tanks a lot,
Xavi

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

Re: facebook login problem

This might help you in managing the session. I had a similar problem a
year ago and used the following snippet:

http://djangosnippets.org/snippets/2065/

Cheers!

On Wed, Feb 29, 2012 at 5:29 PM, dummyman dummyman <tempovan@gmail.com> wrote:
> Hi , i am using django framework at the back end
>
> I have used facebook s social plugin login for authentication
>
> <html>
>     <head>
>       <title>My Facebook Login Page</title>
>     </head>
>     <body>
>       <div id="fb-root"></div>
>       <script src="http://connect.facebook.net/en_US/all.js"></script>
>       <script>
>          FB.init({
>             appId:'My_app_id', cookie:true,
>             status:true, xfbml:true
>          });
>       </script>
>       <fb:login-button>Login with Facebook</fb:login-button>
>     </body>
>  </html>
>
> I have replaced app_id with appropriate app id
>
> login button appears but when i click on the login button, a  window pops up
> and fb s signin form appears. wen i enter my email and pass it says "error
> occured.Please try again later"
> my app id is correct  and i want to proceed further on maintaining the
> session information about the logged in user. Please suggest me suitable
> reference for this and please help me in finding the error in fb  login
> button
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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

Re: Error while importing URLconf 'permitprint.urls': day is out of range for month

use something like >>> d + datetime.timedelta(days=365)



Cheers,
AT

On Wed, Feb 29, 2012 at 12:59 PM, furby <jasonnolen@gmail.com> wrote:
Caught it.  Haha.  What a funny bug.  From models.py:

196 d = dt.datetime.today()
197 expires = d.replace(year=d.year+1)

There is no Feb. 29th, 2013.  So this breaks.  Thx for the help!

On Feb 29, 9:50 am, Tom Evans <tevans...@googlemail.com> wrote:
> On Wed, Feb 29, 2012 at 3:33 PM, furby <jasonno...@gmail.com> wrote:
> > The guy I built this for does not want to pay me to maintain it, so
> > it's still on .96.  And yet when something breaks randomly he wonders
> > why.  Debug enabled today for debugging.  There is no dev
> > environment.  Only production for this.
>
> Customer is always right. Plus, job for life ;)
>
>
>
> > Here's the urlconf.  I've literally commented out every urlpattern
> > expect the top one on line 4.  Still breaks:
>
> >  1 from django.conf.urls.defaults import *
> >  2 from permitprint.app.models import *
> >  3 urlpatterns = patterns('django.views.generic.simple',
> >  4     (r'^/?$', 'direct_to_template', {'template': 'index.html'}),
> >  5 """
>
> Hmmpf. One of the things improved since 0.96 is that error reporting
> of this kind has improved. There is an import error coming from one of
> the imports in the urlconf, and that is why it cannot import the
> urlconf. Is there any date handling code in the top level of the
> permitprint.app.models?
>
> Cheers
>
> Tom

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


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

Re: Error while importing URLconf 'permitprint.urls': day is out of range for month

Caught it. Haha. What a funny bug. From models.py:

196 d = dt.datetime.today()
197 expires = d.replace(year=d.year+1)

There is no Feb. 29th, 2013. So this breaks. Thx for the help!

On Feb 29, 9:50 am, Tom Evans <tevans...@googlemail.com> wrote:
> On Wed, Feb 29, 2012 at 3:33 PM, furby <jasonno...@gmail.com> wrote:
> > The guy I built this for does not want to pay me to maintain it, so
> > it's still on .96.  And yet when something breaks randomly he wonders
> > why.  Debug enabled today for debugging.  There is no dev
> > environment.  Only production for this.
>
> Customer is always right. Plus, job for life ;)
>
>
>
> > Here's the urlconf.  I've literally commented out every urlpattern
> > expect the top one on line 4.  Still breaks:
>
> >  1 from django.conf.urls.defaults import *
> >  2 from permitprint.app.models import *
> >  3 urlpatterns = patterns('django.views.generic.simple',
> >  4     (r'^/?$', 'direct_to_template', {'template': 'index.html'}),
> >  5 """
>
> Hmmpf. One of the things improved since 0.96 is that error reporting
> of this kind has improved. There is an import error coming from one of
> the imports in the urlconf, and that is why it cannot import the
> urlconf. Is there any date handling code in the top level of the
> permitprint.app.models?
>
> Cheers
>
> Tom

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

Re: Error while importing URLconf 'permitprint.urls': day is out of range for month

On Wed, Feb 29, 2012 at 3:33 PM, furby <jasonnolen@gmail.com> wrote:
> The guy I built this for does not want to pay me to maintain it, so
> it's still on .96.  And yet when something breaks randomly he wonders
> why.  Debug enabled today for debugging.  There is no dev
> environment.  Only production for this.

Customer is always right. Plus, job for life ;)

>
> Here's the urlconf.  I've literally commented out every urlpattern
> expect the top one on line 4.  Still breaks:
>
>  1 from django.conf.urls.defaults import *
>  2 from permitprint.app.models import *
>  3 urlpatterns = patterns('django.views.generic.simple',
>  4     (r'^/?$', 'direct_to_template', {'template': 'index.html'}),
>  5 """

Hmmpf. One of the things improved since 0.96 is that error reporting
of this kind has improved. There is an import error coming from one of
the imports in the urlconf, and that is why it cannot import the
urlconf. Is there any date handling code in the top level of the
permitprint.app.models?

Cheers

Tom

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

Re: Error while importing URLconf 'permitprint.urls': day is out of range for month

The guy I built this for does not want to pay me to maintain it, so
it's still on .96. And yet when something breaks randomly he wonders
why. Debug enabled today for debugging. There is no dev
environment. Only production for this.

Here's the urlconf. I've literally commented out every urlpattern
expect the top one on line 4. Still breaks:

1 from django.conf.urls.defaults import *
2 from permitprint.app.models import *
3 urlpatterns = patterns('django.views.generic.simple',
4 (r'^/?$', 'direct_to_template', {'template': 'index.html'}),
5 """
6 (r'^contact/?$', 'direct_to_template', {'template':
'contact.html'}),
7 (r'^services/?$', 'direct_to_template', {'template':
'services.html'}),
8 (r'^cancel/?$', 'direct_to_template', {'template':
'cancel.html'}),
9
10 # Uncomment this for admin:
11 """
12 )
13 """
14 urlpatterns = patterns('',
15 (r'^register/(?P<community_id>\w+)/?$',
'permitprint.app.views.register'),
16 (r'^register/?$', 'permitprint.app.views.register'),
17 (r'^success/?$', 'permitprint.app.views.success'),
18 (r'^cancel/?$', 'permitprint.app.views.cancel'),
19 (r'^success-login/?$', 'permitprint.app.views.success_login'),
20 (r'^verify/?$', 'permitprint.app.views.verify'),
21 (r'^cancel-order-permits/?$',
'permitprint.app.views.cancel_order_permits'),
22 (r'^success-order-permits/?$',
'permitprint.app.views.success_order_permits'),
23 (r'^review-order-permits/?$',
'permitprint.app.views.review_order_permits'),
24 (r'^admin/app/parkingpermit/$',
'permitprint.app.admin.views.main.change_list',
{'app_label':'app','model_name':'ParkingPermit'}),
25 (r'^admin/app/userprofile/$',
'permitprint.app.admin.views.main.change_list',
{'app_label':'app','model_name':'UserProfile'}),
26 (r'^admin/app/orderpermits/$',
'permitprint.app.views.order_permits'),
27 (r'^admin/', include('permitprint.admin_urls')),
28 )
29 urlpatterns += patterns('django.views.generic.list_detail',
30 (r'^products/?$', 'object_list', product_list ),
31 (r'^products/(?P<slug>\w+)/?$', 'object_detail',
product_detail ),
32 (r'^links/?$', 'object_list', link_list ),
33 )
34 """


On Feb 29, 9:22 am, Tom Evans <tevans...@googlemail.com> wrote:
> On Wed, Feb 29, 2012 at 3:09 PM, furby <jasonno...@gmail.com> wrote:
> > A site I built several years ago is breaking randomly today due to the
> > extra leap year day.  Any help on this would be appreciated.  I can't
> > track it down.
>
> > Traceback (most recent call last):
> > File "/home/nolenjb/django/django_src/django/core/handlers/base.py" in
> > get_response
> >  68. callback, callback_args, callback_kwargs =
> > resolver.resolve(request.path)
> > File "/home/nolenjb/django/django_src/django/core/urlresolvers.py" in
> > resolve
> >  160. for pattern in self.urlconf_module.urlpatterns:
> > File "/home/nolenjb/django/django_src/django/core/urlresolvers.py" in
> > _get_urlconf_module
> >  180. raise ImproperlyConfigured, "Error while importing URLconf %r:
> > %s" % (self.urlconf_name, e)
>
> >  ImproperlyConfigured at /admin/
> >  Error while importing URLconf 'permitprint.urls': day is out of
> > range for month
>
> So, it is going wrong because something that is in your urlconf causes
> an exception, and so the urlconf cannot be imported. You need to show
> the code from your urlconf.
>
> Two other unrelated things:
>
> 1) You're running with DEBUG=True on a production site! Don't do that!
> 2) You seem to be using Django 0.96! Django 1.4 is about to be
> released, there are 'several' bugs fixed in between those two
> versions. Perhaps even something that causes this problem!
>
> Cheers
>
> Tom

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

facebook login problem

Hi , i am using django framework at the back end

I have used facebook s social plugin login for authentication

<html>
    <head>
      <title>My Facebook Login Page</title>
    </head>
    <body>
      <div id="fb-root"></div>
      <script src="http://connect.facebook.net/en_US/all.js"></script>
      <script>
         FB.init({ 
            appId:'My_app_id', cookie:true, 
            status:true, xfbml:true 
         });
      </script>
      <fb:login-button>Login with Facebook</fb:login-button>
    </body>
 </html>

I have replaced app_id with appropriate app id 

login button appears but when i click on the login button, a  window pops up and fb s signin form appears. wen i enter my email and pass it says "error occured.Please try again later"
my app id is correct  and i want to proceed further on maintaining the session information about the logged in user. Please suggest me suitable reference for this and please help me in finding the error in fb  login button

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

Re: Error while importing URLconf 'permitprint.urls': day is out of range for month

On Wed, Feb 29, 2012 at 3:09 PM, furby <jasonnolen@gmail.com> wrote:
> A site I built several years ago is breaking randomly today due to the
> extra leap year day.  Any help on this would be appreciated.  I can't
> track it down.
>
> Traceback (most recent call last):
> File "/home/nolenjb/django/django_src/django/core/handlers/base.py" in
> get_response
>  68. callback, callback_args, callback_kwargs =
> resolver.resolve(request.path)
> File "/home/nolenjb/django/django_src/django/core/urlresolvers.py" in
> resolve
>  160. for pattern in self.urlconf_module.urlpatterns:
> File "/home/nolenjb/django/django_src/django/core/urlresolvers.py" in
> _get_urlconf_module
>  180. raise ImproperlyConfigured, "Error while importing URLconf %r:
> %s" % (self.urlconf_name, e)
>
>  ImproperlyConfigured at /admin/
>  Error while importing URLconf 'permitprint.urls': day is out of
> range for month
>

So, it is going wrong because something that is in your urlconf causes
an exception, and so the urlconf cannot be imported. You need to show
the code from your urlconf.

Two other unrelated things:

1) You're running with DEBUG=True on a production site! Don't do that!
2) You seem to be using Django 0.96! Django 1.4 is about to be
released, there are 'several' bugs fixed in between those two
versions. Perhaps even something that causes this problem!

Cheers

Tom

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

Error while importing URLconf 'permitprint.urls': day is out of range for month

A site I built several years ago is breaking randomly today due to the
extra leap year day. Any help on this would be appreciated. I can't
track it down.

Traceback (most recent call last):
File "/home/nolenjb/django/django_src/django/core/handlers/base.py" in
get_response
68. callback, callback_args, callback_kwargs =
resolver.resolve(request.path)
File "/home/nolenjb/django/django_src/django/core/urlresolvers.py" in
resolve
160. for pattern in self.urlconf_module.urlpatterns:
File "/home/nolenjb/django/django_src/django/core/urlresolvers.py" in
_get_urlconf_module
180. raise ImproperlyConfigured, "Error while importing URLconf %r:
%s" % (self.urlconf_name, e)

ImproperlyConfigured at /admin/
Error while importing URLconf 'permitprint.urls': day is out of
range for month

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

Re: Post data Query Dict - Why not a list ?

Excuse my brainfart moment.. sets and dicts are not ordered!

On Wed, Feb 29, 2012 at 11:32 AM, Tom Evans <tevans.uk@googlemail.com> wrote:
On Wed, Feb 29, 2012 at 1:46 PM, Andre Terra <andreterra@gmail.com> wrote:
> I may be misunderstanding something, but for one reason lists are not
> ordered, so you'd never know which item to get, agreed?
>

Lists are ordered, I think you are confusing something :)

Cheers

Tom

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


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

Re: User actions logging app

The log entry model above is very much like what is used in the Admin.
You might want to investigate that model, too, for logging who-did-
what. It can be found from django.contrib.admin.models.

The reason why I use my own is that I usually have some extra columns
related to the audit trail handling.

- Anssi

On Feb 29, 3:12 pm, Mario Gudelj <mario.gud...@gmail.com> wrote:
> Wow. Legend! That's so much Annsi.
>
> On 29 February 2012 18:00, Babatunde Akinyanmi <tundeba...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Yes, they definitely will.
>
> > On 2/28/12, akaariai <akaar...@gmail.com> wrote:
> > > On Feb 28, 11:35 pm, Mario Gudelj <mario.gud...@gmail.com> wrote:
> > >> Hi list,
>
> > >> I was wandering if someone could recomend an easy django app for logging
> > >> user actions performed on models. I'd like to log changes logged in
> > users
> > >> make around the app.
>
> > > I think there are some apps out there. The first question however is
> > > do you want to log "user a changed object b" or do you need an audit
> > > trail also, that is do you need to have the information of user a
> > > changed object b's field c from value "foo" to value "bar".
>
> > > I really am not the one to tell you which app is the correct one. I
> > > usually have a small create_log_entry() method for creating entries
> > > for modifications, and database triggers for the audit trail. The
> > > create_log_entry is often the right way to go, as more often than not
> > > I want to set all changes to the "main" record. That is, if somebody
> > > changes an article's attachment, it is the article that needs to have
> > > the changed log entry, not the attachment.
>
> > > The log entry model is something like this:
> > > class LogEntry(object):
> > >     to_pk = models.IntegerField() #lets assume you are working only
> > > with integer primary keys
> > >     to_type = models.CharField(max_length=40, choices=(('article',
> > > 'Article'), ...))
> > >     mod_type = choices "INSERT/UPDATE/DELETE"
> > >     who = FK(user)
> > >     what = models.TextField() # A "comment" for the edit
> > >     when = models.DateTimeField()
> > >     @classmethod
> > >     def create_log_entry(cls, to_obj, edit_type, user, what_done):
> > >           ...
>
> > > Combined with database-level triggers you can get a good audit trail.
> > > I have some scripts to ease maintain the DB triggers for PostgreSQL
> > > when using Django. I hope I will have some time to polish them for
> > > release, I believe they could be some use for the community.
>
> > >  - Anssi
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscribe@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > Sent from my mobile device
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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

Re: Post data Query Dict - Why not a list ?

On Wed, Feb 29, 2012 at 1:46 PM, Andre Terra <andreterra@gmail.com> wrote:
> I may be misunderstanding something, but for one reason lists are not
> ordered, so you'd never know which item to get, agreed?
>

Lists are ordered, I think you are confusing something :)

Cheers

Tom

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

Jquery/ajax + django

Hello,

I've gotten this json object back from django.

I was wondering how do we use ajax/jquery to retrieve just the words that are highlighted?

I'm stumped.


{"new_list":{"blue": {"sub_datetime": "2012-02-29 22:14:44", "exp_datetime": "2012-03-07 22:14:44", "keyword": "blue"}, "teleport": {"sub_datetime": "2012-02-29 22:09:26", "exp_datetime": "2012-03-07 22:09:26", "keyword": "teleport"}, "blink182": {"sub_datetime": "2012-02-29 22:12:40", "exp_datetime": "2012-03-07 22:12:40", "keyword": "blink182"}, "a1": {"sub_datetime": "2012-02-29 22:13:31", "exp_datetime": "2012-03-07 22:13:31", "keyword": "a1"}, "jolie": {"sub_datetime": "2012-02-29 22:08:46", "exp_datetime": "2012-03-07 22:08:46", "keyword": "jolie"}, "santa claus": {"sub_datetime": "2012-02-29 22:14:13", "exp_datetime": "2012-03-07 22:14:13", "keyword": "santa claus"}}}


Here are the methods i've tried:

function updateKeywords(e) { e.preventDefault();
    var keyword_form = jQuery(e.target);
    alert("Yay Jquery is working!!!");
$.ajax({
url : keyword_form.attr('action'),
type : keyword_form.attr('method'),
data : keyword_form.serialize(),
dataType : 'json',
success : function(response) {alert("JSON Data: " + response.new_list.keyword);
},
});
}


});




Unfortunately, when i put the above, it returns an undefined json data.

When i just put response.new_list, it returns the whole chunk.

Do appreciate any help.



Best Regards,

Stanwin Siow



Re: Post data Query Dict - Why not a list ?

On Wed, Feb 29, 2012 at 5:46 AM, Szabo, Patrick (LNG-VIE) <patrick.szabo@lexisnexis.at> wrote:

Should I not get  lists ?

 

i.e:

 

[Monatsreport]

[2,29,42]



I may be misunderstanding something, but for one reason lists are not ordered, so you'd never know which item to get, agreed?


Cheers,
AT

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

Unicode lists and form submissions

Hi djangoers,

I've ran into an issue I'm not sure how to handle.

I have a form with 7 checkboxes representing 7 days of the week. I want to collect the submitted days and use them in rrule to generate some dates.

The form field looks like this:

weekly_interval = forms.MultipleChoiceField(label='Repeat on:', choices=EventSeries.weekly_interval,widget=forms.CheckboxSelectMultiple, required=False)

The choices are generated from this:

weekly_interval = (
        (rrule.SU, 'Sun'),
        (rrule.MO, 'Mon'),
        (rrule.TU, 'Tue'),
        (rrule.WE, 'Wed'),
        (rrule.TH, 'Thu'),
        (rrule.FR, 'Fri'),
        (rrule.SA, 'Sat')
    )

So, the form renders and everything is fine, but once I submit the form, the data is in incorrect format and I'm not sure how to fix it.

This is how I'm collecting the interval:

interval=form.cleaned_data['weekly_interval']

Then I'm using it in this line:

start_dates = list(rrule.rrule(rrule.WEEKLY, count=self.recurrences, byweekday=self.interval, dtstart=self.start_datetime))

My problem is in this byweekday=self.interval

If I test this form console with the following it works fine

start_dates = list(rrule.rrule(rrule.WEEKLY, count=a_s.recurrences, byweekday=(rrule.MO,rrule.TU), dtstart=appt.start_time))

But when I look at the interval submitted from the form using pdb it looks like this [u'WE', u'TH', u'SA']

I suspect that I need to convert this from unicode to objects. Does anyone know the best approach? And what it would be? 

Thanks a million!

-m

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

Re: User actions logging app

Wow. Legend! That's so much Annsi.

On 29 February 2012 18:00, Babatunde Akinyanmi <tundebabzy@gmail.com> wrote:
Yes, they definitely will.

On 2/28/12, akaariai <akaariai@gmail.com> wrote:
> On Feb 28, 11:35 pm, Mario Gudelj <mario.gud...@gmail.com> wrote:
>> Hi list,
>>
>> I was wandering if someone could recomend an easy django app for logging
>> user actions performed on models. I'd like to log changes logged in users
>> make around the app.
>
> I think there are some apps out there. The first question however is
> do you want to log "user a changed object b" or do you need an audit
> trail also, that is do you need to have the information of user a
> changed object b's field c from value "foo" to value "bar".
>
> I really am not the one to tell you which app is the correct one. I
> usually have a small create_log_entry() method for creating entries
> for modifications, and database triggers for the audit trail. The
> create_log_entry is often the right way to go, as more often than not
> I want to set all changes to the "main" record. That is, if somebody
> changes an article's attachment, it is the article that needs to have
> the changed log entry, not the attachment.
>
> The log entry model is something like this:
> class LogEntry(object):
>     to_pk = models.IntegerField() #lets assume you are working only
> with integer primary keys
>     to_type = models.CharField(max_length=40, choices=(('article',
> 'Article'), ...))
>     mod_type = choices "INSERT/UPDATE/DELETE"
>     who = FK(user)
>     what = models.TextField() # A "comment" for the edit
>     when = models.DateTimeField()
>     @classmethod
>     def create_log_entry(cls, to_obj, edit_type, user, what_done):
>           ...
>
> Combined with database-level triggers you can get a good audit trail.
> I have some scripts to ease maintain the DB triggers for PostgreSQL
> when using Django. I hope I will have some time to polish them for
> release, I believe they could be some use for the community.
>
>  - Anssi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

--
Sent from my mobile device

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


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

Re: Learning Django: DjangoProject Poll application

On Wed, Feb 29, 2012 at 6:07 AM, WuWoot <dwu207@gmail.com> wrote:
> https://docs.djangoproject.com/en/dev/intro/tutorial01/
>
> I'm using the Djangostack (Python 2.7.2+; Django 1.3.1-1) from Bitnami
> ran on Ubuntu 11.10 with PostgreSQL 9.1.2
>

You're doing the dev/trunk tutorial but have django 1.3 installed.

Either use the django 1.3 tutorial, or install the beta of the next
release. If you are a beginner, stick to released software.

Cheers

Tom

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

Re: Is it able to nest block in a conditional tag in the template of Django 1.3?

On Wed, Feb 29, 2012 at 7:20 AM, Patto <pat.inside@gmail.com> wrote:
> Here is my need:
>
> {% if request.user.is_csr %}
>       {% block csr_block %}
>
>
>
> {% endif %}
>

No. Inside child templates, most nodes outside of blocks are ignored.
You can do this instead:

{% block csr_block %}
{% if request.user.is_csr %}
...
{% else %}
{{ block.super }}
{% endif %}
{% endblock %}

Cheers

Tom

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