Re: Access data associated to a primary key

2017-10-03 Thread Gourav Chawla
Glad, you worked it out. You can use them whenever you want. Function based 
views require you to write more code but give you more clarity on what's 
happening. On the other hand CBV help you keep the codebase cleaner.

At the end of the day, it's you who has to decide what to use.

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


Django DateTimeRangeField used with date_hierarchy

2017-10-03 Thread Laurence Sonnenberg
Hi 

It's great that with 1.11 django.contrib.admin and django.contrib.postgres 
have brought the ability to use date_hierarchy with fields from other 
connected tables.

I was wondering if the ability to to create a transform on a given table 
existed so that fields other than DateField or DateTimeField could be used? 
For example DateTimeTZRange. Or perhaps it could be done in the postgresql 
backend?

A transform example might be: 

@admin.register(models.MyModel)
class MyModelAdmin(AdvancedModelAdmin):

date_hierarchy = 'date_range_to_datetime'

def date_range_to_datetime(instance):
"""
Return a datetime from django date range.
"""
return instance.range.lower

Is there anyone who might have some insight into how this could be done?

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


Re: Access data associated to a primary key

2017-10-03 Thread tango ward
thanks Gourav. I really appreciate your inputs.

On Tue, Oct 3, 2017 at 9:16 PM, Gourav Chawla <
gauravchawla.chawla...@gmail.com> wrote:

> Glad, you worked it out. You can use them whenever you want. Function
> based views require you to write more code but give you more clarity on
> what's happening. On the other hand CBV help you keep the codebase cleaner.
>
> At the end of the day, it's you who has to decide what to use.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/efdec957-131b-4cfd-a0fc-0a37e52d3ea5%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


There is any way to prevent cascade delete on FK field, without using signal?

2017-10-03 Thread Fellipe Henrique
There is any way to prevent cascade delete on FK field, without using
signal?

I need to block the Delete process, not to set NULL on field..

Regards!


T.·.F.·.A.·. S+F
*Fellipe Henrique P. Soares*

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
*Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
*
*Blog: *http:www.fellipeh.eti.br
*GitHub: https://github.com/fellipeh *
*Twitter: @fh_bash*

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


RE: There is any way to prevent cascade delete on FK field, without using signal?

2017-10-03 Thread Matthew Pava
Have you checked the arguments for on_delete on ForeignKey?
https://docs.djangoproject.com/en/1.11/ref/models/fields/#arguments

There’s models.SET_NULL, models.SET_DEFAULT, models.DO_NOTHING, etc…

If you need to prevent someone from deleting something, you should use view 
permissions.


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Fellipe Henrique
Sent: Tuesday, October 3, 2017 11:29 AM
To: Django Users
Subject: There is any way to prevent cascade delete on FK field, without using 
signal?

There is any way to prevent cascade delete on FK field, without using signal?

I need to block the Delete process, not to set NULL on field..

Regards!


T.·.F.·.A.·. S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
Blog: http:www.fellipeh.eti.br
GitHub: https://github.com/fellipeh
Twitter: @fh_bash
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF1jwZH4s%3DSnCaS3hqCiZPQd%3D4vvZPYU1EH7oEp1ixpNrg5ERw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

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


Re: There is any way to prevent cascade delete on FK field, without using signal?

2017-10-03 Thread Fabio C. Barrionuevo da Luz
explicitly define what to do when there is a deletion.

use the "on_delete" parameter of ForeignKey/OneToOneField

on django <=1.11, on_delete is optional, and its default value is CASCADE.

after django >- 2.0, it is mandatory to set "on_delete"


https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.ForeignKey.on_delete

https://medium.com/@ajrbyers/django-fk-on-delete-defaults-to-cascade-1c1506aae7c7


2017-10-03 13:28 GMT-03:00 Fellipe Henrique :

> There is any way to prevent cascade delete on FK field, without using
> signal?
>
> I need to block the Delete process, not to set NULL on field..
>
> Regards!
>
>
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \
> 's/(.)/chr(ord($1)-2*3)/ge'
> *Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
> *
> *Blog: *http:www.fellipeh.eti.br
> *GitHub: https://github.com/fellipeh *
> *Twitter: @fh_bash*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAF1jwZH4s%3DSnCaS3hqCiZPQd%
> 3D4vvZPYU1EH7oEp1ixpNrg5ERw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Fábio C. Barrionuevo da Luz
Palmas - Tocantins - Brasil - América do Sul

http://pythonclub.com.br/

Blog colaborativo sobre Python e tecnologias Relacionadas, mantido
totalmente no https://github.com/pythonclub/pythonclub.github.io .

Todos são livres para publicar. É só fazer fork, escrever sua postagem e
mandar o pull-request. Leia mais sobre como publicar em README.md e
contributing.md.
Regra básica de postagem:
"Você" acha interessante? É útil para "você"? Pode ser utilizado com Python
ou é útil para quem usa Python? Está esperando o que? Publica logo, que
estou louco para ler...

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


Re: Auth Password Change template not working

2017-10-03 Thread naitik gala

Yes that method worked. it showed all the physical location where it looked 
for the template file. Thanks.

Is there a way to configure the order in which django looks for the 
template files?

On Sunday, October 1, 2017 at 12:30:44 AM UTC+5:30, Tim Graham wrote:
>
> I'd temporarily remove the built-in template that's being loaded so that 
> TemplateDoesNotExist is raised. The debug page will show the locations that 
> Django searched for the template.
>
> On Wednesday, September 27, 2017 at 7:10:54 AM UTC-4, naitik gala wrote:
>>
>> Hi all,
>>
>> I am trying to add my own designed html to Auth urls.
>>
>> One way obviously is to create my own view and implement Auth urls for 
>> them. Here, I will explicitly mention the html template that i have 
>> created. It would be like any other view that we would create.
>>
>> But, there seems to be an alternate method. We can reuse the views 
>> already created in Auth module. 
>>
>> By reference of documentations, I made following steps:
>>
>> 1. created an html template 
>> 'myproject/myapp/templates/registration/login.html'
>> 2. updated 'myproject/myproject/urls.py' with following
>>
>> urlpatterns = [
>> url(r'^admin/', admin.site.urls),
>> url('', include('django.contrib.auth.urls')),
>> url(r'^', include('myapp.urls')),
>> ]
>>
>> This successfully worked for /login/ i.e. it showed my custom template.
>>
>> It however now fails if I created for /password_change/ as i created 2 
>> files for that 
>> 'myporject/myapp/templates/registration/password_change_form.html' and 
>> 'myporject/myapp/templates/registration/password_change_done.html'
>>
>> Is this a bug or I am missing something? Please help.
>>
>

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