Re: django statics

2013-07-15 Thread Phang Mulianto
Hi,

Better not use hard coded url path for static, use {{ STATIC_URL }} in your
link ;
eg : 




On Mon, Jul 15, 2013 at 7:28 AM, Sébastien Billion <
sebastien.bill...@gmail.com> wrote:

> Hi,
>
> In your project folder, you can create a folder media zith a subfolder
> css, an other img, js, whatever.
> In your settings.py, you can use this line to get the absolute path
> dynamically:
>
> from os import path
> PROJECT_ROOT = path.dirname(path.abspath(__file__))
>
> After, you need to specify your MEDIA_ROOT and MEDIA_URL
>
>
> MEDIA_ROOT = path.join(PROJECT_ROOT,'media')
>
> MEDIA_URL = '/media/'
>
> In your template, if you want to get your css or your js, img, etc... you
> just need to do
> 
>
> Regards,
> Seb
>
>
> 2013/7/15 Kakar Arunachal Service 
>
>> Hello,
>> I read the django docs, but my still confused. How do i use the static
>> files, for css?
>> Thank you.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




client side tests

2013-07-15 Thread Larry Martell
There's no way, using the django unit tests, to effect something
client side, is there?

For example, in one of my django apps the user can filter the data on
the client side. This is done with javascript. Using the unit tests,
there doesn't seem to be a way I emulate that for testing. How do
folks write tests for situations like this?


Thanks!
-larry

-- 
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: django statics

2013-07-15 Thread Tomas Ehrlich
Hi there,
first, there's a difference between MEDIA files and STATIC files (since
1.3, I think). Media files are files uploaded by users, while static
files are usually persistent files on the server from the beginning,
eg. stylesheets, images, javascripts, robots.txt, etc.

It's good to keep these files separated, since static files are usualy
in VCS, while media files not.


As others said, it's convinient to use {{ MEDIA_URL }} and
{{ STATIC_URL }} variables in your templates. Just don't forget to use
RequestContext with proper context processor while rendering template:
https://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-static


Django should't server static/media files in production. They should be
served using your http server (nginx, apache, ...). In development,
however, you can add static files handler to your urls:

# your_project/urls.py
from django.conf.urls import patterns, include, url

urlpatterns = patterns('',
... # your url patterns
)

# Serve static and media files in development
from django.conf import settings
if settings.DEBUG:
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
media = static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns = (media + staticfiles_urlpatterns() + urlpatterns)


Cheers,
  Tom


Dne Mon, 15 Jul 2013 17:54:24 +0800
Phang Mulianto  napsal(a):

> Hi,
> 
> Better not use hard coded url path for static, use {{ STATIC_URL }} in your
> link ;
> eg : 
> 
> 
> 
> 
> On Mon, Jul 15, 2013 at 7:28 AM, Sébastien Billion <
> sebastien.bill...@gmail.com> wrote:
> 
> > Hi,
> >
> > In your project folder, you can create a folder media zith a subfolder
> > css, an other img, js, whatever.
> > In your settings.py, you can use this line to get the absolute path
> > dynamically:
> >
> > from os import path
> > PROJECT_ROOT = path.dirname(path.abspath(__file__))
> >
> > After, you need to specify your MEDIA_ROOT and MEDIA_URL
> >
> >
> > MEDIA_ROOT = path.join(PROJECT_ROOT,'media')
> >
> > MEDIA_URL = '/media/'
> >
> > In your template, if you want to get your css or your js, img, etc... you
> > just need to do
> > 
> >
> > Regards,
> > Seb
> >
> >
> > 2013/7/15 Kakar Arunachal Service 
> >
> >> Hello,
> >> I read the django docs, but my still confused. How do i use the static
> >> files, for css?
> >> Thank you.
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Django users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send an
> >> email to django-users+unsubscr...@googlegroups.com.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> Visit this group at http://groups.google.com/group/django-users.
> >> For more options, visit https://groups.google.com/groups/opt_out.
> >>
> >>
> >>
> >
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> >
> 

-- 
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: client side tests

2013-07-15 Thread Jonathan D. Baker
Check out functional testing with selenium.

Sent from my iPhone

On Jul 15, 2013, at 4:00 AM, Larry Martell  wrote:

> There's no way, using the django unit tests, to effect something
> client side, is there?
> 
> For example, in one of my django apps the user can filter the data on
> the client side. This is done with javascript. Using the unit tests,
> there doesn't seem to be a way I emulate that for testing. How do
> folks write tests for situations like this?
> 
> 
> Thanks!
> -larry
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

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




Re: client side tests

2013-07-15 Thread Luiz A. Menezes Filho
Complementing Jonathan's response: you can use django's
LiveServerTestCase[1] instead of the usual TestCase. To access your site as
a browser would do there is selenium [2].

Att,

[1]
https://docs.djangoproject.com/en/dev/topics/testing/overview/#django.test.LiveServerTestCase
[2] http://selenium-python.readthedocs.org/en/latest/api.html



On Mon, Jul 15, 2013 at 8:41 AM, Jonathan D. Baker <
jonathandavidba...@gmail.com> wrote:

> Check out functional testing with selenium.
>
> Sent from my iPhone
>
> On Jul 15, 2013, at 4:00 AM, Larry Martell 
> wrote:
>
> > There's no way, using the django unit tests, to effect something
> > client side, is there?
> >
> > For example, in one of my django apps the user can filter the data on
> > the client side. This is done with javascript. Using the unit tests,
> > there doesn't seem to be a way I emulate that for testing. How do
> > folks write tests for situations like this?
> >
> >
> > Thanks!
> > -larry
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Luiz Menezes

-- 
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: image rendering on the template

2013-07-15 Thread sahitya pavurala
Hi john ,


I searched for what you told me, but I could not find any . Could you 
provide a link for that .


Thanks

On Saturday, July 13, 2013 10:14:34 AM UTC-4, John wrote:
>
> On 12/07/13 22:12, sahitya pavurala wrote: 
> > however if i directly return the value i get the image .But i need to 
> > render the image to a different page . How can i do this ? -- 
> I answered a question a few days ago that was very similar to this that 
> would give you a route to take. Search in this list for matplotlib in 
> the last week. 
>
> John 
>

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




Mysterious WHERE clause when updating an object

2013-07-15 Thread J. Barber
I am having trouble updating an existing table using django on ms sql 
server. Here is the query I am using:

>>> c = Candidacy.objects.get(id_num=610020956, stage__in=('150  ', '350 
 '))
>>> c.enroll_dep_amt = 146
>>> c.save()

But the SQL query sent to the server does not look as it should. Instead, I 
get this (note especially the WHERE clause):

>>> print connection.queries[-1]
{'time': '0.079', 'sql': u'UPDATE [CANDIDACY] SET [CUR_CANDIDACY] = Y, 
[STAGE] =
 150  , [ENROLL_FEE_TYPE] = help?, [ENROLL_DEP_DTE] = 2013-07-15 13:12:01, 
[enro
ll_dep_amt] = 146 WHERE [CANDIDACY].[YR_CDE] = 2013 '}

Thus, instead of updating a single row, the sql updates over 1000 rows. 
Below is my model:

class Candidacy(models.Model):
id_num = models.IntegerField(primary_key=True, db_column=u"ID_NUM")
trm_cde = models.CharField(max_length=2, primary_key=True, 
   db_column=u"TRM_CDE")
yr_cde = models.CharField(max_length=4, primary_key=True, 
  db_column=u"YR_CDE")
cur_candidacy = models.CharField(max_length=1, 
db_column=u"CUR_CANDIDACY")
stage = models.CharField(max_length=5, db_column=u"STAGE")
enroll_fee_type = models.CharField(max_length=5, 
   db_column=u"ENROLL_FEE_TYPE")
enroll_dep_dte = models.DateTimeField(db_column=u"ENROLL_DEP_DTE")
enroll_dep_amt = models.DecimalField(max_digits=6, decimal_places=2)

class Meta:
db_table = u'CANDIDACY'

Thanks in advance to anyone who can point me in the right direction.

Justin

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




showing the checked item alone in template

2013-07-15 Thread Sivaram R
forms.py

PERSON_ACTIONS = (
('1', '01.Allowed to rest and returned to class'),
('2', '02.Contacted parents /guardians'),
('3', '02a.- Unable to Contact'),
('4', '02b.Unavailable - left message'),)
class PersonActionsForm(forms.ModelForm):
   action = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple(), 
choices=PERSON_ACTIONS, required=False, label= u"Actions")


models.py

class Actions(models.Model):
reportperson = models.ForeignKey(ReportPerson)
action =  models.IntegerField('Action type')

template.html

{{ actionform.as_p}}

The PersonActionsForm contains the items with multichoice checkbox. In 
report registration page,the user can select any one or more item.The 
checked items are saved in models as integer values.

Since i am rendering the whole form it is showing the entire form with 
checked and unchecked item.

In print page,i want to show only the checked item alone without checkbox.

How to do this in django.

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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: client side tests

2013-07-15 Thread bobhaugen
Any current faves for client-side testing that do not require Java?
>
>   

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

2013-07-15 Thread Ernesto Pulgaron
alguna recomendacion para mi " lio de Templates" con respecto a lo otro, yo 
ya utilice el syncdb y me creo las tablas de usuarios sin problema, pero a 
la hora de utilizar change_password_form es el lio yo utilizo la del login 
sin problema alguno, incluso la de aditar usuario, pero las demas no hay 
forma, no se si la mejor forma es utilizarlas directo en el url.py ,o sea, 
sin definar nada en la vista, funcionará??

El jueves, 11 de julio de 2013 14:31:29 UTC-4, vicherot escribió:
>
> Evidentemente tenes un lio de Templates ... no te encuentra el 
> "registration/password_
> change_done.html"
>
> Por la segunda pregunta... con forms hechos a mano supongo? fijate cuando 
> haces el syncdb y habilitaste el middleware de usuarios te crea las 
> tablas... 
> Fijate por acá:
> https://docs.djangoproject.com/en/1.5/topics/auth/default/#user-objects
>
>
> 2013/7/11 Ernesto Pulgaron >
>
>> hola, estoy introduciendome en django por lo que tengo algunas dudas, 
>> quisiera sabes como es que se usa UserChangeForm ya que cdo trato de 
>> accecer al link de 
>>  password = ReadOnlyPasswordHashField(label=_("Password"),
>> help_text=_("Raw passwords are not stored, so there is no way to 
>> see "
>> "this user's password, but you can change the 
>> password "
>> "using this form."))
>>
>> me muestra el sgte error :Exception Type: TemplateDoesNotExist
>>   Exception 
>> Value:registration/password_change_done.html
>>   Exception Location: 
>> C:\Python27\lib\site-packages\django\template\loader.py in find_template, 
>> line 139
>>
>> esta es mi view.py:
>> #Editar usuarios
>> @login_required(login_url='/ingresar')
>> def editar_usuario(request):
>> if request.method == 'POST':
>> formulario = UserChangeForm(request.POST)
>> if formulario.is_valid():
>> formulario.save()
>> return HttpResponseRedirect('/')
>> else:
>> formulario = UserChangeForm()
>> return 
>> render_to_response('nuevousuario.html',{'formulario':formulario},context_instance=RequestContext(request))
>>
>> el html:
>> {% extends 'baseAdmin.html' %}
>>
>> {% block content %}
>> 
>> {% csrf_token %}
>> 
>> {{ formulario }}
>> 
>> 
>> 
>> 
>> {% endblock %}
>>
>> el url:
>> urlpatterns = patterns('',
>>
>> url(r'^usuario/nuevo$','Administracion.views.nuevo_usuario'),
>>
>> url(r'^usuario/editar$','Administracion.views.editar_usuario'),
>>
>> url(r'^ingresar/$','Administracion.views.ingresar'),
>>url(r'^privado/$','Administracion.views.privado'),
>>url(r'^cerrar/$', 'Administracion.views.cerrar'),
>>url(r'^password/$', 
>> 'django.contrib.auth.views.password_change_done'),
>>
>> Tambien me surge la duda sobre PasswordChangeForm da el mismo error y por 
>> ultimo pero no menos importante quisiera saber si existe una forma de 
>> gestionar los usuarios (eliminar, insertar y modificar) qu no sea 
>> habilitando el modulo de administracion, lo mismo para los grupos
>> gracias
>>
>> -- 
>> 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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Rafael E. Ferrero
> Claro: (03562) 15514856 
>

-- 
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: client side tests

2013-07-15 Thread Larry Martell
On Mon, Jul 15, 2013 at 6:10 AM, Luiz A. Menezes Filho
 wrote:
> Complementing Jonathan's response: you can use django's
> LiveServerTestCase[1] instead of the usual TestCase. To access your site as
> a browser would do there is selenium [2].
>
> Att,
>
> [1]
> https://docs.djangoproject.com/en/dev/topics/testing/overview/#django.test.LiveServerTestCase
> [2] http://selenium-python.readthedocs.org/en/latest/api.html

Thanks! I will investigate these.


>
> On Mon, Jul 15, 2013 at 8:41 AM, Jonathan D. Baker
>  wrote:
>>
>> Check out functional testing with selenium.
>>
>> Sent from my iPhone
>>
>> On Jul 15, 2013, at 4:00 AM, Larry Martell 
>> wrote:
>>
>> > There's no way, using the django unit tests, to effect something
>> > client side, is there?
>> >
>> > For example, in one of my django apps the user can filter the data on
>> > the client side. This is done with javascript. Using the unit tests,
>> > there doesn't seem to be a way I emulate that for testing. How do
>> > folks write tests for situations like this?
>> >
>> >
>> > Thanks!
>> > -larry
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Django users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an email to django-users+unsubscr...@googlegroups.com.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > Visit this group at http://groups.google.com/group/django-users.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
>
>
>
> --
> Luiz Menezes
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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




Re: client side tests

2013-07-15 Thread Jonathan Baker
Also, here is a detailed (and recent) intro on integrating
LiveServerTestCase into your Django project:
http://lincolnloop.com/blog/2012/nov/2/introduction-django-selenium-testing/


On Mon, Jul 15, 2013 at 8:43 AM, Larry Martell wrote:

> On Mon, Jul 15, 2013 at 6:10 AM, Luiz A. Menezes Filho
>  wrote:
> > Complementing Jonathan's response: you can use django's
> > LiveServerTestCase[1] instead of the usual TestCase. To access your site
> as
> > a browser would do there is selenium [2].
> >
> > Att,
> >
> > [1]
> >
> https://docs.djangoproject.com/en/dev/topics/testing/overview/#django.test.LiveServerTestCase
> > [2] http://selenium-python.readthedocs.org/en/latest/api.html
>
> Thanks! I will investigate these.
>
>
> >
> > On Mon, Jul 15, 2013 at 8:41 AM, Jonathan D. Baker
> >  wrote:
> >>
> >> Check out functional testing with selenium.
> >>
> >> Sent from my iPhone
> >>
> >> On Jul 15, 2013, at 4:00 AM, Larry Martell 
> >> wrote:
> >>
> >> > There's no way, using the django unit tests, to effect something
> >> > client side, is there?
> >> >
> >> > For example, in one of my django apps the user can filter the data on
> >> > the client side. This is done with javascript. Using the unit tests,
> >> > there doesn't seem to be a way I emulate that for testing. How do
> >> > folks write tests for situations like this?
> >> >
> >> >
> >> > Thanks!
> >> > -larry
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups "Django users" group.
> >> > To unsubscribe from this group and stop receiving emails from it, send
> >> > an email to django-users+unsubscr...@googlegroups.com.
> >> > To post to this group, send email to django-users@googlegroups.com.
> >> > Visit this group at http://groups.google.com/group/django-users.
> >> > For more options, visit https://groups.google.com/groups/opt_out.
> >> >
> >> >
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an
> >> email to django-users+unsubscr...@googlegroups.com.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> Visit this group at http://groups.google.com/group/django-users.
> >> For more options, visit https://groups.google.com/groups/opt_out.
> >>
> >>
> >
> >
> >
> >
> > --
> > Luiz Menezes
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
Jonathan D. Baker
Developer
http://jonathandbaker.com

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




Re: Django-Ajax Issue

2013-07-15 Thread Subodh Nijsure
I am not sure what you mean by taking you to post view of the function.

That aside, you need to include  csrfmiddlewaretoken: '{{ csrf_token
}}' in your data: section.

   data: {
 'keyword': search_for,
 'filter': rval,
csrfmiddlewaretoken: '{{ csrf_token }}'
},

-Subodh

On Sun, Jul 14, 2013 at 8:19 AM, vijay shanker  wrote:
> Hey all
> I am trying to make a simple ajax call to show items retrieved from
> database.
> I am displaying bunch of fields like a text input for keyword and radio
> button for filter in a form like this:
>
> {% csrf_token %}
> 
>  Search 
> 
> 
> 
>  checked='checked'/>All
>  value="paying"/>Paying
>  value="uploaded"/>Uploaded
>  />Staff Pick
>  
> 
>
> This form is displayed by a function which inherits generic View class, from
> its get method.
>
> class Home(View):
> def get(self,request, *args, **kwargs):
> return render_to_response('items/search_page.html', context_instance
> = RequestContext(request) )
> def post(self, request, *args, **kwargs):
> print 'in home post'
>
> What puzzles me is that when i am trying to submit the form data via ajax
> call (on same page) with jquery when someone clicks on search button, it
> takes me to post view of Home and not on to other function i have defined.
> The javascript on the html page is:
> 
>function search(e) {
> e.preventDefault();
> search_for = $("#search").val()
> rval = $('input:radio[name=fancy_radio]:checked').val()
> $.ajax({
> url:"/search/",
> method : "POST",
> data : { 'keyword': search_for, 'filter': rval },
> success:function(result){
> alert(result)
> }
> });
>}
> 
>
> why is this happening ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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




or-ing to QuerySets turns INNER into LEFT OUTER joins?

2013-07-15 Thread Carsten Fuchs

Hi all,

we have two queries/QuerySets Q_a and Q_b, each of which use INNER joins 
in the generated SQL when evaluated individually.


When I use a Q object to "OR" these two QuerySets, the INNER joins turn 
into LEFT OUTER joins -- which in turn cause a huge performance drop 
(several hundred times slower than with INNER joins).


Why is this, and can I do anything against it at the Django ORM level?


Details:

My environment:
Django 1.5.1 on Ubuntu 10.04 (Python 2.6.5) with Oracle database 10g


FirstDay = date(2013, 5, 1)
LastDay = date(2013, 5, 31)
SomeDep = ...   # the department with ID == 1


Q_a = Staff.objects. \
  filter(bereiche=SomeDep).distinct()

Q_b = Staff.objects. \
  filter(erfasst__datum__gte=FirstDay,
 erfasst__datum__lte=LastDay,
 erfasst__bereich=SomeDep).distinct()

Q_a_or_b = Staff.objects. \
  filter(Q(bereiche=SomeDep) |
 Q(erfasst__datum__gte=FirstDay,
   erfasst__datum__lte=LastDay,
   erfasst__bereich=SomeDep)).distinct()


In the following output, to improve readability I used the "*" to 
manually shorten the list of selected fields:



print Q_a.query

SELECT DISTINCT "STAFF".* FROM "STAFF"
INNER JOIN "STAFF_BEREICHE" ON ("STAFF"."ID" = "STAFF_BEREICHE"."STAFF_ID")
WHERE "STAFF_BEREICHE"."BEREICH_ID" = 1


print Q_b.query

SELECT DISTINCT "STAFF".* FROM "STAFF"
INNER JOIN "ERFASST" ON ("STAFF"."KEY" = "ERFASST"."KEY")
WHERE ("ERFASST"."DATUM" <= 2013-05-31  AND "ERFASST"."DATUM" >= 
2013-05-01  AND "ERFASST"."BEREICH_ID" = 1 )



print Q_a_or_b.query

SELECT DISTINCT "STAFF".* FROM "STAFF"
LEFT OUTER JOIN "STAFF_BEREICHE" ON ("STAFF"."ID" = 
"STAFF_BEREICHE"."STAFF_ID")

LEFT OUTER JOIN "ERFASST" ON ("STAFF"."KEY" = "ERFASST"."KEY")
WHERE ("STAFF_BEREICHE"."BEREICH_ID" = 1  OR ("ERFASST"."DATUM" <= 
2013-05-31  AND "ERFASST"."DATUM" >= 2013-05-01  AND 
"ERFASST"."BEREICH_ID" = 1 ))



In the last SQL statement, when I replace "LEFT OUTER JOIN" with "INNER 
JOIN" and manually run it, the result seems to be the same, but the 
query completes one hundred to several hundred times faster.


So, from the above observations, I was wondering if the use of "LEFT 
OUTER JOIN" is what is supposed to happen for Q_a_or_b in the first 
place? Is it the expected behavior?

And if so, can it be changed via the Django ORM?

Many thanks for your help!

Best regards,
Carsten



--
Dipl.-Inf. Carsten Fuchs

Carsten Fuchs Software
Industriegebiet 3, c/o Rofu, 55768 Hoppstädten-Weiersbach, Germany
Internet: http://www.cafu.de | E-Mail: i...@cafu.de

Cafu - the open-source game and graphics engine for multiplayer 3D action

--
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: Calling ffmpeg doesn't work on apache server

2013-07-15 Thread Chad Vernon
The issue turns on to be a bug in Python regarding sub-interpreters:

http://stackoverflow.com/questions/8309465/popen-does-not-work-anymore-with-apache-wsgi-and-python-2-7-2

Adding this to my http conf fixed it:

WSGIApplicationGroup %{GLOBAL}


On Thursday, June 20, 2013 4:51:10 PM UTC-7, ovnicraft wrote:
>
>
>
>
> On Wed, Jun 19, 2013 at 6:01 PM, Chad Vernon 
> > wrote:
>
>> I'm trying to use ffmpeg to generate a thumbnail for a video.  It works 
>> just fine when I call it from a python shell and when I test it in "python 
>> manage.py shell".  However when I try to run from the apache server running 
>> locally, I get an error:
>>
>> # normally I call subprocess.call, but for debug here I'm calling 
>> check_call
>> response = subprocess.check_call(['ffmpeg', '-i', self.file.path], 
>> stderr=fh)
>>
>> # actual path taken out for brevity
>> Command '['ffmpeg', '-i', u'...']' returned non-zero exit status -6
>>
>>
> Can you pastebin de output, when use ffmpeg as subprocess (i did it) you 
> can get in output what happens, check_output can help you if you want 
> output in response var.
>
> Regards,
>  
>
>> I've verified that the video path is correct.
>>
>> Any suggestions?
>>
>> Thanks!
>> Chad
>>
>> -- 
>> 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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Cristian Salamea
> @ovnicraft 
>

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




Treebeard Hierarchical Form

2013-07-15 Thread Cody Scott
I am trying to create a hierarchical form with nodes in django-treebeard.
I am using code from the docs, but it doesn't reset when I have another 
root node, it should be on the left side if it has a depth of 1.


Also how would you make it expand when I click Products to expand products.

I organised my data into a tree so that displaying it in a hierarchical form 
would be easier. Is there a better way to do this?



{% for item, info in annotated_list %}
{% if not item.is_leaf %}

{% if info.open %}

{% else %}

{% endif %}
{{item}} - {{item.get_depth}}

{% for close in info.close %}

{% endfor %}
{%endif%}{% endfor %}



   - Products - 1
  - Computers - 2
 - Desktops - 3
 - Laptops - 3
- Net books - 4
- Tablets - 3
- Tablet Accessories - 4
- Services - 1
   - Replacement Parts - 2
  - Hard drives - 3
  - Monitors - 3
 - LCD - 4
 - Keyboards - 3
 - Contact - 1
  



-- 
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: Submit a form but stay on the page and the form changes

2013-07-15 Thread Cody Scott
I don't care if the page reloads, how do I change the form?


On Sat, Jul 13, 2013 at 1:19 AM, Babatunde Akinyanmi
wrote:

> I'm assuming you want the form to morph on the screen without a page
> reload. If that's the case, you need JavaScript like jQuery. let the view
> you are submitting your POST to return the data you need in JSON and use
> jQuery to remove the form and add the results or url
>
> Sent from my Windows Phone
> --
> From: Cody Scott
> Sent: 7/12/2013 11:51 PM
> To: django-users@googlegroups.com
> Subject: Re: Submit a form but stay on the page and the form changes
>
> The code works, I can submit the form and go back to the page I came from
> with the HTTP_REFERER , what I need help is getting the form to change, to
> be the results.
>
> For the syntax highlighting I submit my code to bpaste and then copy into
> the message here.
>
>
> On Fri, Jul 12, 2013 at 10:43 AM, Sergiy Khohlov wrote:
>
>> Hello Cody,
>>
>>  I would like to help.
>>  1 ) could you please check if POST is going from  your browser to
>>  django (I hope yes)
>> 2)  First candidate for investigation is  function post in
>> class PollFormMixin
>>  I 'm proposing verify this by  adding
>>  print  "form status",  form.is_valid()
>>  after string form = PollForm(request.POST, instance=self.get_object())
>>
>>
>>  P.S. How are you adding so nice formatting to your letter ?
>>
>>
>> Many thanks,
>>
>> Serge
>>
>>
>> +380 636150445
>> skype: skhohlov
>>
>>
>> On Thu, Jul 11, 2013 at 11:50 PM, Cody Scott wrote:
>>
>>> I would like to put a Poll Voting Form on any page like a blog post page
>>> or the homepage.
>>> Here is the page that I display the form and the view that it gets
>>> posted to in the form action attribute.
>>> I would like to be able to submit the form but stay on that page and
>>> have the form change into the results or a link to the results.
>>>
>>> class DetailView(PublishedMixin, generic.DetailView):
>>> model = Poll
>>> template_name = 'polls/detail.html'
>>>
>>> def get_context_data(self, **kwargs):
>>> context = super(DetailView, self).get_context_data(**kwargs)
>>> context['form'] = PollForm(instance=self.get_object())
>>> return context
>>> {% csrf_token 
>>> %}{{form.as_p}}
>>>
>>>
>>>
>>>
>>> class VoteView(PublishedMixin, generic.DetailView):
>>> model = Poll
>>>
>>> '''def get_form(self, *args, **kwargs):form = 
>>> PollForm(instance=self.get_object())#return super(VoteView, 
>>> self).get_form(*args, **kwargs)return form'''
>>> @property
>>> def success_url(self):
>>> return reverse(
>>> 'polls:results', args=(self.get_object().id,))
>>>
>>> def post(self, request, *args, **kwargs):
>>> form = PollForm(request.POST, instance=self.get_object())
>>> if form.is_valid():
>>> selected_choice = form.cleaned_data['choice']
>>> selected_choice.votes += 1
>>> selected_choice.save()
>>>
>>>
>>> return HttpResponseRedirect(request.META['HTTP_REFERER'])
>>>
>>>
>>>
>>>
>>>
>>>
>>> I also thought about doing a mixin on the page, but I can't just render the 
>>> page with the form attribute equal to something else, becuase I would need 
>>> to redirect to avoid the refresh problem.
>>>
>>>
>>>
>>> class PollFormMixin(SingleObjectMixin):"""puts form and "view 
>>> results link" in contextand validates and saves the form"""
>>> model = Polldef get_context_data(self, **kwargs):context = 
>>> super(PollFormMixin, self).get_context_data(**kwargs)form = 
>>> PollForm(instance=self.get_object())context['form'] = form
>>> return contextdef post(self, request, *args, **kwargs):form = 
>>> PollForm(request.POST, instance=self.get_object())if 
>>> form.is_valid():form.save()return 
>>> HttpResponseRedirect(self.success_url)else:return 
>>> render(request, self.template_name,{'form': form, 'poll': 
>>> self.get_object()})
>>>
>>>
>>> class VoteView(PublishedPollMixin, PollFormMixin, DetailView):"""
>>> Vote on a poll"""model = Polltemplate_name = 
>>> 'polls/detail.html'@propertydef success_url(self):return 
>>> reverse('polls:results', args=(self.get_object().id,))
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>>
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django user

Re: duda

2013-07-15 Thread Rafael E. Ferrero
Fijate aca
https://docs.djangoproject.com/en/1.5/topics/auth/default/#module-django.contrib.auth.viewsque
tenes herramientas para usar en las vistas para cambiar las passwords,
etc... entiendo que pretendés darle un aspecto personalizado al formulario
de cambiar claves, login, etc... yo crearía mis propios forms con mis
propios templates y usaría una vista propia que haga uso de esas funciones
para hacer la tarea de administracion de usuarios.

hay algo más aca
https://docs.djangoproject.com/en/1.5/topics/auth/customizing/

Saludos, espero te sirva.


El 15 de julio de 2013 11:38, Ernesto Pulgaron
escribió:

> alguna recomendacion para mi " lio de Templates" con respecto a lo otro,
> yo ya utilice el syncdb y me creo las tablas de usuarios sin problema, pero
> a la hora de utilizar change_password_form es el lio yo utilizo la del
> login sin problema alguno, incluso la de aditar usuario, pero las demas no
> hay forma, no se si la mejor forma es utilizarlas directo en el url.py ,o
> sea, sin definar nada en la vista, funcionará??
>
> El jueves, 11 de julio de 2013 14:31:29 UTC-4, vicherot escribió:
>>
>> Evidentemente tenes un lio de Templates ... no te encuentra el
>> "registration/password_
>> change_done.html"
>>
>> Por la segunda pregunta... con forms hechos a mano supongo? fijate cuando
>> haces el syncdb y habilitaste el middleware de usuarios te crea las
>> tablas...
>> Fijate por acá:
>> https://docs.djangoproject.**com/en/1.5/topics/auth/**
>> default/#user-objects
>>
>>
>> 2013/7/11 Ernesto Pulgaron 
>>
>>> hola, estoy introduciendome en django por lo que tengo algunas dudas,
>>> quisiera sabes como es que se usa UserChangeForm ya que cdo trato de
>>> accecer al link de
>>>  password = ReadOnlyPasswordHashField(**label=_("Password"),
>>> help_text=_("Raw passwords are not stored, so there is no way to
>>> see "
>>> "this user's password, but you can change the
>>> password "
>>> "using this form."))
>>>
>>> me muestra el sgte error :Exception Type: TemplateDoesNotExist
>>>   **Exception
>>> Value:registration/password_**change_done.html
>>>   **Exception Location:
>>> C:\Python27\lib\site-packages\**django\template\loader.py in
>>> find_template, line 139
>>>
>>> esta es mi view.py:
>>> #Editar usuarios
>>> @login_required(login_url='/**ingresar')
>>> def editar_usuario(request):
>>> if request.method == 'POST':
>>> formulario = UserChangeForm(request.POST)
>>> if formulario.is_valid():
>>> formulario.save()
>>> return HttpResponseRedirect('/')
>>> else:
>>> formulario = UserChangeForm()
>>> return render_to_response('**nuevousuario.html',{'**
>>> formulario':formulario},**context_instance=**RequestContext(request))
>>>
>>> el html:
>>> {% extends 'baseAdmin.html' %}
>>>
>>> {% block content %}
>>> 
>>> {% csrf_token %}
>>> 
>>> {{ formulario }}
>>> 
>>> 
>>> 
>>> 
>>> {% endblock %}
>>>
>>> el url:
>>> urlpatterns = patterns('',
>>>url(r'^usuario/nuevo$','**
>>> Administracion.views.nuevo_**usuario'),
>>>url(r'^usuario/editar$','**
>>> Administracion.views.editar_**usuario'),
>>>url(r'^ingresar/$','**
>>> Administracion.views.ingresar'**),
>>>url(r'^privado/$','**
>>> Administracion.views.privado')**,
>>>url(r'^cerrar/$', 'Administracion.views.cerrar')*
>>> *,
>>>url(r'^password/$', 'django.contrib.auth.views.**
>>> password_change_done'),
>>>
>>> Tambien me surge la duda sobre PasswordChangeForm da el mismo error y
>>> por ultimo pero no menos importante quisiera saber si existe una forma de
>>> gestionar los usuarios (eliminar, insertar y modificar) qu no sea
>>> habilitando el modulo de administracion, lo mismo para los grupos
>>> gracias
>>>
>>>  --
>>> 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
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> Rafael E. Ferrero
>> Claro: (03562) 15514856
>>
>  --
> 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

Unable to start project using enthought

2013-07-15 Thread Joshua Phillips
Hello All,
   New to Django but excited about the utilities I see. Having a bit of 
trouble getting the initial set-up to work using enthought. When I run 
startproject it seems to just immediately open up enthought with several 
blank files. I don't have extensive experience with web-stacks but I do 
know this probably isn't what I want. No [project-name] folder was created 
in the deployed folder but I can save the blank files if I'd like

Any advice from anyone who has experienced similar issues? 

Thanks for your thoughts :)
- Joshua 

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




First-time user: Creating first project in tutorial

2013-07-15 Thread Joshua Phillips
Hello All,
   I'm running django for the first time using the enthought canopy IDE for 
python. I'm trying to work through the tutorial and although the cmd line 
tells me I have successfully installed django 1.5.1 . But when I try running 
django-admin.py 
startproject [sitename] it just opens up the init file in enthought and 
skips all the rest. No [sitename] directory is created, none of the other 
files in the tutorial either. Have tried several Google searches against 
this, getting bad results. 


Has anyone experienced anything similar? Are there any obvious mistakes I 
may be making?

Maybe pathnames which must be added? 

-- 
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: Submit a form but stay on the page and the form changes

2013-07-15 Thread Bill Freeman
Render a different form

  or

Render the body tag with a different class or classes that hide some parts
of your grander form and reveal others

  or

Render a script tag setting a value in a variable that your JavaScript uses
to decide how to make the form look.


If you want to control how your page looks there's rarely a substitute for
controlling how your page looks.


On Mon, Jul 15, 2013 at 4:37 PM, Cody Scott wrote:

> I don't care if the page reloads, how do I change the form?
>
>
> On Sat, Jul 13, 2013 at 1:19 AM, Babatunde Akinyanmi  > wrote:
>
>> I'm assuming you want the form to morph on the screen without a page
>> reload. If that's the case, you need JavaScript like jQuery. let the view
>> you are submitting your POST to return the data you need in JSON and use
>> jQuery to remove the form and add the results or url
>>
>> Sent from my Windows Phone
>> --
>> From: Cody Scott
>> Sent: 7/12/2013 11:51 PM
>> To: django-users@googlegroups.com
>> Subject: Re: Submit a form but stay on the page and the form changes
>>
>> The code works, I can submit the form and go back to the page I came from
>> with the HTTP_REFERER , what I need help is getting the form to change, to
>> be the results.
>>
>> For the syntax highlighting I submit my code to bpaste and then copy into
>> the message here.
>>
>>
>> On Fri, Jul 12, 2013 at 10:43 AM, Sergiy Khohlov wrote:
>>
>>> Hello Cody,
>>>
>>>  I would like to help.
>>>  1 ) could you please check if POST is going from  your browser to
>>>  django (I hope yes)
>>> 2)  First candidate for investigation is  function post in
>>> class PollFormMixin
>>>  I 'm proposing verify this by  adding
>>>  print  "form status",  form.is_valid()
>>>  after string form = PollForm(request.POST, instance=self.get_object())
>>>
>>>
>>>  P.S. How are you adding so nice formatting to your letter ?
>>>
>>>
>>> Many thanks,
>>>
>>> Serge
>>>
>>>
>>> +380 636150445
>>> skype: skhohlov
>>>
>>>
>>> On Thu, Jul 11, 2013 at 11:50 PM, Cody Scott 
>>> wrote:
>>>
 I would like to put a Poll Voting Form on any page like a blog post
 page or the homepage.
 Here is the page that I display the form and the view that it gets
 posted to in the form action attribute.
 I would like to be able to submit the form but stay on that page and
 have the form change into the results or a link to the results.

 class DetailView(PublishedMixin, generic.DetailView):
 model = Poll
 template_name = 'polls/detail.html'

 def get_context_data(self, **kwargs):
 context = super(DetailView, self).get_context_data(**kwargs)
 context['form'] = PollForm(instance=self.get_object())
 return context
 {% csrf_token 
 %}{{form.as_p}}





 class VoteView(PublishedMixin, generic.DetailView):
 model = Poll

 '''def get_form(self, *args, **kwargs):form = 
 PollForm(instance=self.get_object())#return super(VoteView, 
 self).get_form(*args, **kwargs)return form'''
 @property
 def success_url(self):
 return reverse(
 'polls:results', args=(self.get_object().id,))

 def post(self, request, *args, **kwargs):
 form = PollForm(request.POST, instance=self.get_object())
 if form.is_valid():
 selected_choice = form.cleaned_data['choice']
 selected_choice.votes += 1
 selected_choice.save()


 return HttpResponseRedirect(request.META['HTTP_REFERER'])






 I also thought about doing a mixin on the page, but I can't just render 
 the page with the form attribute equal to something else, becuase I would 
 need to redirect to avoid the refresh problem.



 class PollFormMixin(SingleObjectMixin):"""puts form and "view 
 results link" in contextand validates and saves the form"""
 model = Polldef get_context_data(self, **kwargs):context = 
 super(PollFormMixin, self).get_context_data(**kwargs)form = 
 PollForm(instance=self.get_object())context['form'] = form
 return contextdef post(self, request, *args, **kwargs):form = 
 PollForm(request.POST, instance=self.get_object())if 
 form.is_valid():form.save()return 
 HttpResponseRedirect(self.success_url)else:return 
 render(request, self.template_name,{'form': form, 'poll': 
 self.get_object()})


 class VoteView(PublishedPollMixin, PollFormMixin, DetailView):"""
 Vote on a poll"""model = Polltemplate_name = 
 'polls/detail.html'@propertydef success_url(self):return 
 reverse('polls:results', args=(self.get_object().id,))

  --
 You 

Re: Django Tastypie: Getting MultipleObjects returned

2013-07-15 Thread Rene Zelaya
Hey everyone,

So I figured out what was going on in my code - apparently, when adding 
items to a ToManyField through the API, this requires a specific format, 
namely: 

   
["api/v1/exampleResource/1/","api/v1/exampleResource/2/","api/v1/exampleResource/3/"]

Note the lack of any spacing, the quotations around each resource URI, and 
the enclosing brackets.  I had to fiddle around with my JavaScript code so 
that this was the format it returned to the API when posting the related 
resource.  Hope this will help someone if they get stuck in the same place!

Rene 

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




New to django, trying to implement a comment system, and rather uncertain about how to go about it

2013-07-15 Thread Ben Spatafora


Okay, I'm pretty new to django (and coding in general), so please bear with 
me. I'm trying to create the most basic features of a forum, and I had a 
few questions about how to go about doing this. So far, I've set up a 
post-only (i.e., no way to comment) project that consists of a single app 
using only class-based, generic views: a list view for the "feed" of posts, 
and detail, create, and delete views for individual posts.


What I'm trying to do next is get comments working, more or less from 
scratch. I've considered alternatives to this, but the django comments 
framework is (from what I understand) set to become deprecated in the next 
release, and there doesn't seem to be a third-party app that is 
well-regarded and regularly updated. (I would ultimately like to include 
django-mptt (which takes the hard part out of implementing a modified 
pre-order traversal tree) in order to create a nested comment system, but 
it seems like the first step is getting a regular comment system set up.)


My first question is whether it seems like I'm thinking about this whole 
thing in a reasonable way based on the last two paragraphs (I don't have 
any friends or acquaintances who code that I can run things like this by, 
and sometimes I wonder if my dazed wanderings are leading me in exactly the 
wrong direction).


If I am, my next question is this: what is the best way to implement a 
(detail-type) view that will let me display a single posting and all of the 
comments that are related to that posting (which I assume I should do via 
foreign key)? If possible, I'd like to do this via a (presumably 
non-generic) class-based view, since I get the sense from reading things 
from people who really know django that, in general, CBVs should be favored 
over functional views (being this new to the framework, I have to take a 
lot of things on faith).


Tangential to this question is how to access a post's comments in a 
template. Would something like this suffice?


{% for comment in posting.comment_set.all() %}



  {{ comment }}

  {{ comment.user }}




And if I later want to sort comments based on an algorithm that includes a 
few pieces of information, is the best place to put this code in the 
comments model as a method?


Finally, it seems that in system of nested comments, where you can reply to 
not only the post but also to any comment at any level, it would not make 
sense to implement a view to create a comment in django alone. It would 
seem necessary to use some Javascript to create "Reply" links that, on 
click, open up to a form with a text area and "Submit" button. My question, 
then, is whether it makes sense to use a django view for this at all, or 
whether this would be better done entirely in some AJAX framework.


(Oh, one more thing: I'm holding off on implementing the actual django user 
authentication app until I've got this stuff worked out, because I figure 
it'll be easy enough to go back and add it in afterward. Is this a mistake?)


Okay, I think that's all I've got for now. As you can see, I might be in 
over my head here, but it's important to me to do what I'm trying to do, 
and I can't afford to have someone do it for me. Any tips, thoughts, 
reprimands, advice, or pointings-in-the-right-direction are appreciated.

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




Python 2.7 + Django 1.4 + apache 2.4

2013-07-15 Thread maiquel
How to set up django on Apache

I'm using django 1.4
and apache 2.4
and Python 2.7
My configuration is well

in httpd.conf

WSGIScriptAlias / C :/ xampp / htdocs / My_blog / My_blog / wsgi.py
WSGIPythonPath / C :/ xampp / htdocs / My_blog /



Order deny, allow
Allow from all



Does anyone know what is wrong?

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




Re: New to django, trying to implement a comment system, and rather uncertain about how to go about it

2013-07-15 Thread carlos
Hi ben you are try with this app http://disqus.com/ or you can use comment
contrib app read this tutorial http://lightbird.net/dbe/blog.html#comments

Cheers


On Mon, Jul 15, 2013 at 2:52 PM, Ben Spatafora  wrote:

> Okay, I'm pretty new to django (and coding in general), so please bear
> with me. I'm trying to create the most basic features of a forum, and I had
> a few questions about how to go about doing this. So far, I've set up a
> post-only (i.e., no way to comment) project that consists of a single app
> using only class-based, generic views: a list view for the "feed" of posts,
> and detail, create, and delete views for individual posts.
>
>
> What I'm trying to do next is get comments working, more or less from
> scratch. I've considered alternatives to this, but the django comments
> framework is (from what I understand) set to become deprecated in the next
> release, and there doesn't seem to be a third-party app that is
> well-regarded and regularly updated. (I would ultimately like to include
> django-mptt (which takes the hard part out of implementing a modified
> pre-order traversal tree) in order to create a nested comment system, but
> it seems like the first step is getting a regular comment system set up.)
>
>
> My first question is whether it seems like I'm thinking about this whole
> thing in a reasonable way based on the last two paragraphs (I don't have
> any friends or acquaintances who code that I can run things like this by,
> and sometimes I wonder if my dazed wanderings are leading me in exactly the
> wrong direction).
>
>
> If I am, my next question is this: what is the best way to implement a
> (detail-type) view that will let me display a single posting and all of the
> comments that are related to that posting (which I assume I should do via
> foreign key)? If possible, I'd like to do this via a (presumably
> non-generic) class-based view, since I get the sense from reading things
> from people who really know django that, in general, CBVs should be favored
> over functional views (being this new to the framework, I have to take a
> lot of things on faith).
>
>
> Tangential to this question is how to access a post's comments in a
> template. Would something like this suffice?
>
>
> {% for comment in posting.comment_set.all() %}
>
> 
>
>   {{ comment }}
>
>   {{ comment.user }}
>
> 
>
>
> And if I later want to sort comments based on an algorithm that includes a
> few pieces of information, is the best place to put this code in the
> comments model as a method?
>
>
> Finally, it seems that in system of nested comments, where you can reply
> to not only the post but also to any comment at any level, it would not
> make sense to implement a view to create a comment in django alone. It
> would seem necessary to use some Javascript to create "Reply" links that,
> on click, open up to a form with a text area and "Submit" button. My
> question, then, is whether it makes sense to use a django view for this at
> all, or whether this would be better done entirely in some AJAX framework.
>
>
> (Oh, one more thing: I'm holding off on implementing the actual django
> user authentication app until I've got this stuff worked out, because I
> figure it'll be easy enough to go back and add it in afterward. Is this a
> mistake?)
>
>
> Okay, I think that's all I've got for now. As you can see, I might be in
> over my head here, but it's important to me to do what I'm trying to do,
> and I can't afford to have someone do it for me. Any tips, thoughts,
> reprimands, advice, or pointings-in-the-right-direction are appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Python 2.7 + Django 1.4 + apache 2.4

2013-07-15 Thread carlos
where is the error ??


On Mon, Jul 15, 2013 at 5:11 PM, maiquel  wrote:

> How to set up django on Apache
>
> I'm using django 1.4
> and apache 2.4
> and Python 2.7
> My configuration is well
>
> in httpd.conf
>
> WSGIScriptAlias / C :/ xampp / htdocs / My_blog / My_blog / wsgi.py
> WSGIPythonPath / C :/ xampp / htdocs / My_blog /
>
> 
> 
> Order deny, allow
> Allow from all
> 
> 
>
> Does anyone know what is wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: showing the checked item alone in template

2013-07-15 Thread Sivaram R
Hi,can i get any answer or let me know the way to do this.

Thanks

On Monday, July 15, 2013 7:46:43 PM UTC+5:30, Sivaram R wrote:
>
> forms.py
>
> PERSON_ACTIONS = (
> ('1', '01.Allowed to rest and returned to class'),
> ('2', '02.Contacted parents /guardians'),
> ('3', '02a.- Unable to Contact'),
> ('4', '02b.Unavailable - left message'),)
> class PersonActionsForm(forms.ModelForm):
>action = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple(), 
> choices=PERSON_ACTIONS, required=False, label= u"Actions")
>
>
> models.py
>
> class Actions(models.Model):
> reportperson = models.ForeignKey(ReportPerson)
> action =  models.IntegerField('Action type')
>
> template.html
>
> {{ actionform.as_p}}
>
> The PersonActionsForm contains the items with multichoice checkbox. In 
> report registration page,the user can select any one or more item.The 
> checked items are saved in models as integer values.
>
> Since i am rendering the whole form it is showing the entire form with 
> checked and unchecked item.
>
> In print page,i want to show only the checked item alone without checkbox.
>
> How to do this in django.
>
> 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.
For more options, visit https://groups.google.com/groups/opt_out.