Looking for a Django co-founder

2019-03-14 Thread Deepak sharma
Hi Zack, 

find me on finddeepak.com

Good to connect with you on this.

-- 
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/e745bfb5-9ea2-45de-aa86-3b9b98bc80b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Looking for a Django co-founder

2019-03-14 Thread Zack Amaral
Harish, I need an experienced developer.

On Thu, Mar 14, 2019 at 10:52 PM Harish Chaudhary 
wrote:

> Hello Zack
> Good to see your post,
> Do you want experienced developer or fresher will also do??
>
> On Fri, 15 Mar, 2019, 9:11 AM Zack Amaral, 
> wrote:
>
>> Django users,
>>
>> I'm looking for a Django developer that can commit to working 10 hours a
>> week on the weekend. We work Friday and Saturday at 12AM EST. I'm looking
>> to bring on another developer that's willing to work for equity in my
>> company. We are building a web application similar to twitch.tv. We are
>> using React for the front end and Django for the backend. Everything is on
>> AWS. I can go into more details if you are interested. I can also send you
>> a copy of my business plan.
>>
>> If you are interested please let me know and I'll set up a call with you
>> to see if it's a good fit.
>>
>> Thank you for your time,
>>
>> Zack
>>
>> --
>> 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/ed9c69bc-e3b0-4cfb-9a7b-f78a80393e95%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/Tygq1Ds1hJw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALxqzK5mLVnDdSNNBV2brNuJkqZkuOFbLGr_HQJJDyqE3bOdGQ%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/CANG%3DrDk1Zw5nGreLdHbbNS5qgcP0oOkrL8Qq0H%2BPySFiQ9krBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Looking for a Django co-founder

2019-03-14 Thread Harish Chaudhary
Hello Zack
Good to see your post,
Do you want experienced developer or fresher will also do??

On Fri, 15 Mar, 2019, 9:11 AM Zack Amaral,  wrote:

> Django users,
>
> I'm looking for a Django developer that can commit to working 10 hours a
> week on the weekend. We work Friday and Saturday at 12AM EST. I'm looking
> to bring on another developer that's willing to work for equity in my
> company. We are building a web application similar to twitch.tv. We are
> using React for the front end and Django for the backend. Everything is on
> AWS. I can go into more details if you are interested. I can also send you
> a copy of my business plan.
>
> If you are interested please let me know and I'll set up a call with you
> to see if it's a good fit.
>
> Thank you for your time,
>
> Zack
>
> --
> 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/ed9c69bc-e3b0-4cfb-9a7b-f78a80393e95%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/CALxqzK5mLVnDdSNNBV2brNuJkqZkuOFbLGr_HQJJDyqE3bOdGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Looking for a Django co-founder

2019-03-14 Thread Anh Nguyen
Hi Zack, it’s good to see your post.
Now I think i can do that.
You can check my own blog and production in ‘adaoalive.com’ and ‘chuthe.com
’.
Thanks.

On Fri, Mar 15, 2019 at 10:41 AM Zack Amaral 
wrote:

> Django users,
>
> I'm looking for a Django developer that can commit to working 10 hours a
> week on the weekend. We work Friday and Saturday at 12AM EST. I'm looking
> to bring on another developer that's willing to work for equity in my
> company. We are building a web application similar to twitch.tv. We are
> using React for the front end and Django for the backend. Everything is on
> AWS. I can go into more details if you are interested. I can also send you
> a copy of my business plan.
>
> If you are interested please let me know and I'll set up a call with you
> to see if it's a good fit.
>
> Thank you for your time,
>
> Zack
>
> --
> 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/ed9c69bc-e3b0-4cfb-9a7b-f78a80393e95%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/CAKaoNbSDcaqGteeELjAiTOvzf5%2Bi_UPhPbJ%2BbNz%3Di77FNQ3mPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why use CustomUserManager.create_user and not CustomUserManager.create?

2019-03-14 Thread Peter of the Norse
The biggest difference is that when you call create_user, it creates a hash of 
the password.  Eventually, create_user does call create, but only after setting 
all the values properly.

Sent from my iPad

> On Feb 17, 2019, at 4:30 AM, Maarten Nieber  wrote:
> 
> Hi,
> 
> the Django guidelines tell us to implement CustomUserManager.create_user. 
> However, this seems to introduce some ambiguity between
> CustomUserManager.create_user and CustomUserManager.create, since both these 
> methods can be expected to create a User. In fact,
> it would be easy to accidentically call the wrong method from source code.
> 
> Is there any reason why the create_user function exists at all? Why doesn't 
> Django tell us to override CustomUserManager.create?
> 
> Or alternatively, I could imagine that Django could have a hook function that 
> is called by CustomUserManager.create, where the hook can be used
> to implemented custom behaviour (so that at least we have only 1 function to 
> create users). Would this be a better design? Or is the current
> design the correct one, and am I missing something? (in that case, please 
> elaborate)
> 
> Best regards,
> Maarten
> 
> 
> -- 
> 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/b934b1a4-a295-4e83-be9c-b787785e5fc6%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/E560F7DD-84E1-485F-92E4-D89E9240188D%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Looking for a Django co-founder

2019-03-14 Thread Zack Amaral
Django users,

I'm looking for a Django developer that can commit to working 10 hours a 
week on the weekend. We work Friday and Saturday at 12AM EST. I'm looking 
to bring on another developer that's willing to work for equity in my 
company. We are building a web application similar to twitch.tv. We are 
using React for the front end and Django for the backend. Everything is on 
AWS. I can go into more details if you are interested. I can also send you 
a copy of my business plan.

If you are interested please let me know and I'll set up a call with you to 
see if it's a good fit.

Thank you for your time,

Zack

-- 
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/ed9c69bc-e3b0-4cfb-9a7b-f78a80393e95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What step am I missing?

2019-03-14 Thread Joseph Jones
Hi,
yes Thank you so much those video tutorial helped me quite a bit. I was
able to create a new directory, as the "introduction to django" tutorial
suggested I've made sure its title is project specific. However, I seem to
have run into a problem creating a path to my new directory. when last I
ran the command I received an Command error stating that my project name
was not valid. Any thoughts on what detail I am overlooking would be very
appreciated,
Thank you

On Tue, Mar 12, 2019 at 8:30 AM Suresh Kannan  wrote:

> Hi,
>
> You can watch these videos. I think this might help you.
>
> https://www.youtube.com/watch?v=FNQxxpM1yOs (windows)
>
>
> https://www.youtube.com/watch?v=oT1A1KKf0SI=PLxxA5z-8B2xk4szCgFmgonNcCboyNneMD
> (linux)
>
> On Mon, 11 Mar 2019 at 09:35, Joseph Jones  wrote:
>
>> Thank you so much, does one bring up the cd command in the python
>> terminal?
>>
>> On Mon, Mar 11, 2019 at 8:07 AM Kayode Oladipo 
>> wrote:
>>
>>> You have to be in the project level directory to access 'manage.py'.
>>> Use the 'cd' command in the terminal to do this.
>>>
>>> On Sun, Mar 10, 2019, 23:23 Joseph Jones >>
 Hello all!
 I have been reading
 https://www.packtpub.com/application-development/learn-python-programming-second-edition
  Since
 November, so I am very much new to the Python community. I am currently on
 chapter 14 "Web development" which suggests completing the tutorial on
 djangoproject.com after installing Django of course. When I've run the
 first two commands in the cmd of my PC I get the output the tutorial would
 indicate. However when I run the command .../> py manage.py runserver I
 receive a command error that no such file exists. My question is what
 mistake am I making? I'm hypothesizing one is to create a file entitled
 "manage.py' before beginning, however unless I'm misreading the text in the
 tutorial the command .../> django-admin startproject runserver
 auto-generates said file. Any suggestions on what I'm doing wrong would be
 immensely appreciated. Let me apologize in advance if I either, ask for
 clarification in any responses(again I am new), or mess up again through
 out the course of the tutorial and again reach out to the community. Thank
 you for any help,
 Joseph

 --
 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/CAJGsC5OzcyMwrW%3D-EmU%2B-3o8esQ2JeVQoJScq%3DHy_mtsxKRuKQ%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/CA%2BARzD8BiTZ8Rzfi9twFF7GTzYpBZqpCdpR3K_tGW5b1Rfsdrw%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/CAJGsC5N2poHoALgwHLkk%3D9o9jGeUZ1NStedbnBS-oLdYgVzSQA%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 

error information in Django forms template

2019-03-14 Thread Mike Rankin
I'm new to Django and I'm trying an experiment using material.io. The 
problem I'm having is that the formfield injects the error messages and the 
label directly into the page instead of sending it to the widget template. 
Because of the way material.io builds controls, it would be nice to have 
that information available in the template so you can attach classes and 
logic to the various divs that surround a control. I was able to supress 
the injected items with css, but I can't find a way to get the error 
conditions and messages into the template. Am I just thinking about the 
widgets 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e9c25cc5-9221-4c10-a940-0f1f8651c0f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django credit card redaction app - - MultiValueDictKeyError

2019-03-14 Thread drone4four


Thank you Ahmed for this clarification. This makes sense.

I have two further questions for you (or anyone else still reading this 
thread):


   1. 
   
   Is there a way of checking for the presence of the data with GET which 
   is more Pythonic and aligns with better practices?
   


   1. 
   
   On an unrelated note, I attempted to reduce my issue in this testcase as 
   best I could. I think I did an OK job. But would there be a better way for 
   me to ask my question to attract more responses? What would any of you 
   recommend in terms of advice for me to refine and refine the way I ask 
   similar questions in the future on this message board?
   


On Thursday, March 14, 2019 at 2:13:35 PM UTC-4, Ahmed Ishtiaque wrote:
>
> When a user requests your home page's URL the first time in order to load 
> your home.html file, the GET request they send to your server does not 
> contain the 'ccEntry' parameter, which raised the MultiValueDictKeyError 
> whenever your view was executing. However, in your edited view, you take 
> care of that by first checking whether the GET request contains 'ccEntry', 
> which is why it is working correctly now. 
>
> On Thu, Mar 14, 2019 at 9:57 AM drone4four  > wrote:
>
>> I’ve discovered a ‘hack’ to correct the issue. I committed and pushed my 
>> changes up to my GitHub repo for those curious enough to try it out 
>> yourself. 
>>
>> My problem now is that I don’t really understand why it works. Here I 
>> will explain what I do know and then my ask would be for you people to fill 
>> in the gaps in my explanation.  First I share my working code. 
>>
>> Here is my views.py which includes the relevant function I use:
>>
>> from django.http import HttpResponse
>>
>>
>>
>> from django.shortcuts import render
>>
>>
>> def home(request):
>>
>>if 'ccEntry' in request.GET:
>>
>>number = request.GET['ccEntry']
>>
>>redacted_num = '   {}'.format(number[-4:])
>>
>>return render(request, 'home.html', {'number':number, 
>> 'redacted_num':redacted_num})
>>
>>else:
>>
>>return render(request, 'home.html')
>>
>>
>>
>>
>> Here is my lucid, cerebral explanation of the above Python code in plain 
>> English: At line 4 I am defining the `home` function. Then there is a 
>> conditional referring to the ‘ccEntry’ string inside the template. If 
>> ccEntry is present in the GET request, then a `number` variable is declared 
>> based on the user input on the web page. Then a `redacted_num` variable is 
>> declared which will appear as a string (‘   ’ with the last 4 
>> characters lopped off (the slice). If all of the above is in order, then 
>> the render function will be returned:
>>
>>- 
>>
>>with the standard request,
>>- 
>>
>>with reference to the home.html template, 
>>- 
>>
>>along with a dictionary with a ‘number’ string matching up with the 
>>`number` variable. Ditto for the redact_num.
>>
>> However if the above condition is false, then the render function will 
>> return the standard request and home.html template without a dictionary. 
>> That’s pretty much everything I understand.  
>>
>> I’m not sure why a conditional as it appears above is necessary. 
>>
>> Would someone here care to explain, if you can?
>>
>>
>> On Thursday, March 7, 2019 at 4:05:28 PM UTC-5, drone4four wrote:
>>>
>>> This is a long shot, but I thought I would share a link to my source 
>>> code hosted on GitHub with a requirements.txt included. If any of you would 
>>> like to test this out yourself, I am accepting pull requests. Here it is: 
>>> https://github.com/Angeles4four/CC_Redact
>>>
>>>
>>> On Thursday, March 7, 2019 at 4:03:37 PM UTC-5, drone4four wrote:

 I am taking a course on Udemy and the instructor doesn’t include a 
 method attribute in the form tag.  But as you suggested, Deepak, I went 
 ahead and added method="get" to my form tag in my home.html template. So 
 line 7 now reads: 

 I am still encountering the MultiValueDictKeyError. 

 Here is the traceback again:

 MultiValueDictKeyError at /

 'ccEntry'

 Request Method: GET

 Request URL: http://127.0.0.1:8000/

 Django Version: 2.0.2

 Exception Type: MultiValueDictKeyError

 Exception Value: 

 'ccEntry'

 Exception Location: 
 /home//.local/lib/python3.7/site-packages/django/utils/datastructures.py
  
 in __getitem__, line 79

 Python Executable: /usr/sbin/python

 Python Version: 3.7.2

 Python Path: 


 ['/home//dev/projects/python/2018-and-2019/cel2fah-original_with_CC-redact-project-_Django202/first_project_attempt',

 '/usr/lib/python37.zip',

 '/usr/lib/python3.7',

 '/usr/lib/python3.7/lib-dynload',

 '/home//.local/lib/python3.7/site-packages',

 '/usr/lib/python3.7/site-packages',

 

Re: Generic CBV DeleteView GET csrf_token

2019-03-14 Thread Chetan Ganji
Frameworks dont work as we want them too :P
We have to understand how the defaults are implemented then make the
changes as necessary ;-)
If it can be customized, great! otherwise learn and use a different
framework, LOLZ ;-)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in



I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Mar 15, 2019 at 1:02 AM B  wrote:

> Thanks. I have things working fine under Ajax. This particular scenario is
> an "odd one" since performing a GET on a delete view isn't common, but it
> is implemented by Django. It is helpful for testing, but perhaps the right
> approach is to "disable" get for the DeleteView and be done with it. My
> main concern was for Django to behave "out of box" as intended without
> overrides.
>
> On Thursday, March 14, 2019 at 3:24:46 PM UTC-4, Chetan Ganji wrote:
>>
>> https://www.django-rest-framework.org/topics/ajax-csrf-cors/
>> https://docs.djangoproject.com/en/2.1/ref/csrf/#ajax
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji@gmail.com
>> http://ryucoder.in
>>
>>
>>
>> 
>>  I’m
>> protected online with Avast Free Antivirus. Get it here — it’s free
>> forever.
>> 
>> <#m_8157490019364007879_CAMKMUjuRMSAqgVxdtNPHEt+RpSzM-VAx9rTgJf7CBqZ91UFtrg@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Fri, Mar 15, 2019 at 12:34 AM B  wrote:
>>
>>> I'm implementing a DeleteView, and for completion I would like to
>>> provide the functionality indicated here:
>>>
>>>
>>> https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/#deleteview
>>>
>>> *If this view is fetched via GET, it will display a confirmation page
>>> that should contain a form that POSTs to the same URL.*
>>>
>>> However, by default a GET will not include the required context to the
>>> template for {% csrf_token %}. How do I include the appropriate context
>>> information for a plain DeleteView CBV?
>>>
>>> --
>>> 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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/213ca896-0973-4b64-9345-50de5cd9e5d7%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/98106b93-47ac-4cbb-8c89-d3291d52b2a5%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/CAMKMUjvEymdFUtQ0qeaPHsie0PsjeuvwkdQC_kkHuHdoeMi8zw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generic CBV DeleteView GET csrf_token

2019-03-14 Thread B
Thanks. I have things working fine under Ajax. This particular scenario is 
an "odd one" since performing a GET on a delete view isn't common, but it 
is implemented by Django. It is helpful for testing, but perhaps the right 
approach is to "disable" get for the DeleteView and be done with it. My 
main concern was for Django to behave "out of box" as intended without 
overrides.

On Thursday, March 14, 2019 at 3:24:46 PM UTC-4, Chetan Ganji wrote:
>
> https://www.django-rest-framework.org/topics/ajax-csrf-cors/
> https://docs.djangoproject.com/en/2.1/ref/csrf/#ajax
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji@gmail.com 
> http://ryucoder.in
>
>
>
> 
>  I’m 
> protected online with Avast Free Antivirus. Get it here — it’s free 
> forever. 
> 
>  
> <#CAMKMUjuRMSAqgVxdtNPHEt+RpSzM-VAx9rTgJf7CBqZ91UFtrg@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Fri, Mar 15, 2019 at 12:34 AM B > wrote:
>
>> I'm implementing a DeleteView, and for completion I would like to provide 
>> the functionality indicated here:
>>
>>
>> https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/#deleteview
>>
>> *If this view is fetched via GET, it will display a confirmation page 
>> that should contain a form that POSTs to the same URL.*
>>
>> However, by default a GET will not include the required context to the 
>> template for {% csrf_token %}. How do I include the appropriate context 
>> information for a plain DeleteView CBV?
>>
>> -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/213ca896-0973-4b64-9345-50de5cd9e5d7%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/98106b93-47ac-4cbb-8c89-d3291d52b2a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generic CBV DeleteView GET csrf_token

2019-03-14 Thread Chetan Ganji
https://www.django-rest-framework.org/topics/ajax-csrf-cors/
https://docs.djangoproject.com/en/2.1/ref/csrf/#ajax

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in



I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Mar 15, 2019 at 12:34 AM B  wrote:

> I'm implementing a DeleteView, and for completion I would like to provide
> the functionality indicated here:
>
>
> https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/#deleteview
>
> *If this view is fetched via GET, it will display a confirmation page that
> should contain a form that POSTs to the same URL.*
>
> However, by default a GET will not include the required context to the
> template for {% csrf_token %}. How do I include the appropriate context
> information for a plain DeleteView CBV?
>
> --
> 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/213ca896-0973-4b64-9345-50de5cd9e5d7%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/CAMKMUjuRMSAqgVxdtNPHEt%2BRpSzM-VAx9rTgJf7CBqZ91UFtrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Generic CBV DeleteView GET csrf_token

2019-03-14 Thread B
I'm implementing a DeleteView, and for completion I would like to provide 
the functionality indicated here:

https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/#deleteview

*If this view is fetched via GET, it will display a confirmation page that 
should contain a form that POSTs to the same URL.*

However, by default a GET will not include the required context to the 
template for {% csrf_token %}. How do I include the appropriate context 
information for a plain DeleteView CBV?

-- 
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/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django credit card redaction app - - MultiValueDictKeyError

2019-03-14 Thread Ahmed Ishtiaque
When a user requests your home page's URL the first time in order to load
your home.html file, the GET request they send to your server does not
contain the 'ccEntry' parameter, which raised the MultiValueDictKeyError
whenever your view was executing. However, in your edited view, you take
care of that by first checking whether the GET request contains 'ccEntry',
which is why it is working correctly now.

On Thu, Mar 14, 2019 at 9:57 AM drone4four  wrote:

> I’ve discovered a ‘hack’ to correct the issue. I committed and pushed my
> changes up to my GitHub repo for those curious enough to try it out
> yourself.
>
> My problem now is that I don’t really understand why it works. Here I will
> explain what I do know and then my ask would be for you people to fill in
> the gaps in my explanation.  First I share my working code.
>
> Here is my views.py which includes the relevant function I use:
>
> from django.http import HttpResponse
>
>
>
> from django.shortcuts import render
>
>
> def home(request):
>
>if 'ccEntry' in request.GET:
>
>number = request.GET['ccEntry']
>
>redacted_num = '   {}'.format(number[-4:])
>
>return render(request, 'home.html', {'number':number,
> 'redacted_num':redacted_num})
>
>else:
>
>return render(request, 'home.html')
>
>
>
>
> Here is my lucid, cerebral explanation of the above Python code in plain
> English: At line 4 I am defining the `home` function. Then there is a
> conditional referring to the ‘ccEntry’ string inside the template. If
> ccEntry is present in the GET request, then a `number` variable is declared
> based on the user input on the web page. Then a `redacted_num` variable is
> declared which will appear as a string (‘   ’ with the last 4
> characters lopped off (the slice). If all of the above is in order, then
> the render function will be returned:
>
>-
>
>with the standard request,
>-
>
>with reference to the home.html template,
>-
>
>along with a dictionary with a ‘number’ string matching up with the
>`number` variable. Ditto for the redact_num.
>
> However if the above condition is false, then the render function will
> return the standard request and home.html template without a dictionary.
> That’s pretty much everything I understand.
>
> I’m not sure why a conditional as it appears above is necessary.
>
> Would someone here care to explain, if you can?
>
>
> On Thursday, March 7, 2019 at 4:05:28 PM UTC-5, drone4four wrote:
>>
>> This is a long shot, but I thought I would share a link to my source code
>> hosted on GitHub with a requirements.txt included. If any of you would like
>> to test this out yourself, I am accepting pull requests. Here it is:
>> https://github.com/Angeles4four/CC_Redact
>>
>>
>> On Thursday, March 7, 2019 at 4:03:37 PM UTC-5, drone4four wrote:
>>>
>>> I am taking a course on Udemy and the instructor doesn’t include a
>>> method attribute in the form tag.  But as you suggested, Deepak, I went
>>> ahead and added method="get" to my form tag in my home.html template. So
>>> line 7 now reads: 
>>>
>>> I am still encountering the MultiValueDictKeyError.
>>>
>>> Here is the traceback again:
>>>
>>> MultiValueDictKeyError at /
>>>
>>> 'ccEntry'
>>>
>>> Request Method: GET
>>>
>>> Request URL: http://127.0.0.1:8000/
>>>
>>> Django Version: 2.0.2
>>>
>>> Exception Type: MultiValueDictKeyError
>>>
>>> Exception Value:
>>>
>>> 'ccEntry'
>>>
>>> Exception Location: 
>>> /home//.local/lib/python3.7/site-packages/django/utils/datastructures.py
>>> in __getitem__, line 79
>>>
>>> Python Executable: /usr/sbin/python
>>>
>>> Python Version: 3.7.2
>>>
>>> Python Path:
>>>
>>>
>>> ['/home//dev/projects/python/2018-and-2019/cel2fah-original_with_CC-redact-project-_Django202/first_project_attempt',
>>>
>>> '/usr/lib/python37.zip',
>>>
>>> '/usr/lib/python3.7',
>>>
>>> '/usr/lib/python3.7/lib-dynload',
>>>
>>> '/home//.local/lib/python3.7/site-packages',
>>>
>>> '/usr/lib/python3.7/site-packages',
>>>
>>> '/usr/lib/python3.7/site-packages/setuptools-40.6.2-py3.7.egg']
>>>
>>> Server time: Thu, 7 Mar 2019 20:11:44 +
>>>
>>> Environment:
>>>
>>>
>>> Request Method: GET
>>>
>>> Request URL: http://127.0.0.1:8000/
>>>
>>> Django Version: 2.0.2
>>>
>>> Python Version: 3.7.2
>>>
>>> Installed Applications:
>>>
>>> ['django.contrib.admin',
>>>
>>> 'django.contrib.auth',
>>>
>>> 'django.contrib.contenttypes',
>>>
>>> 'django.contrib.sessions',
>>>
>>> 'django.contrib.messages',
>>>
>>> 'django.contrib.staticfiles']
>>>
>>> Installed Middleware:
>>>
>>> ['django.middleware.security.SecurityMiddleware',
>>>
>>> 'django.contrib.sessions.middleware.SessionMiddleware',
>>>
>>> 'django.middleware.common.CommonMiddleware',
>>>
>>> 'django.middleware.csrf.CsrfViewMiddleware',
>>>
>>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>>
>>> 'django.contrib.messages.middleware.MessageMiddleware',
>>>
>>> 'django.middleware.clickjacking.XFrameOptionsMiddleware']
>>>

Re: image didn't upload

2019-03-14 Thread omar ahmed
i want to post image in news page

On Thursday, March 14, 2019 at 6:26:26 PM UTC+2, AbsolutEdge findout wrote:
>
> Hello omar,
>
> I don't see that you're uploading the picture anywhere, you haven't used a 
> form to upload the image, your template is just trying to display the 
> image, where are the views? and where's the form by which you uploaded the 
> image?
>
> Post all of these please.
>
> Thanks,
> Majid
>

-- 
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/bb675a3f-ba89-4353-8899-48a3996517e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: image didn't upload

2019-03-14 Thread AbsolutEdge findout
Hello omar,

I don't see that you're uploading the picture anywhere, you haven't used a 
form to upload the image, your template is just trying to display the 
image, where are the views? and where's the form by which you uploaded the 
image?

Post all of these please.

Thanks,
Majid

-- 
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/ad0f36c3-d867-4340-8783-647f2d7372b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread Chetan Ganji
OK.

One work around could be to fire the signal manually just after you
set/delete the value? I have not checked it yet :P

Do one thing, implement pre_delete and post_delete signals and check the
values of  instance, sender and using. It might give you more information
about what is happening.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in



I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 9:15 PM mccc  wrote:

>
>
> On Thursday, March 14, 2019 at 4:22:15 PM UTC+1, Chetan Ganji wrote:
>>
>> Why do you need to do any calculations in the model code?
>>
>> I would do any calculations in the views and store them using models.
>> That will remove the getters and setters from model.
>> Everything should work fine then.
>>
>> Hope it helps.
>>
>
> No, nothing would work fine: in that case I would need to remember
> constantly to either copy the code to handle the behaviour or make a call
> to *a view* each time and in any place that handles those fields.
> Plus the tests would need to check over and over for the same behaviour
> every time the field was involved.
>
> I'm sorry, but it really doesn't 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/ed1853bb-402a-4688-9061-63054c44ce63%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/CAMKMUjuXZaAQXtM0ac%3DX7icsk76-eTcWnKSCgYp9iR_crQP%3D6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


LDAP autentication do not protect my site

2019-03-14 Thread emmanuel . ferro
Hi every one,
My ldap login is not protect my site. One can access just typing a url. 
What is wrong?
These site is just a set of html templates.

---
settings.py
---
AUTH_LDAP_SERVER_URI = "ldap://ldap.city.company;
AUTH_LDAP_BIND_DN = "uid=host,ou=wan,ou=corp,dc=company,dc=gov,dc=br"
AUTH_LDAP_BIND_PASSWORD = 'password'
AUTH_LDAP_USER_SEARCH = LDAPSearch(
'dc=company,dc=gov,dc=br',
ldap.SCOPE_SUBTREE,
'(uid=%(user)s)',
)
AUTH_LDAP_USER_ATTR_MAP = {
"full_name": "cn",
"username": "uid",
"mail": "mail",
}

# This is the default, but I like to be explicit.
AUTH_LDAP_ALWAYS_UPDATE_USER = True

# Cache distinguised names and group memberships for an hour to minimize
# LDAP traffic.
AUTH_LDAP_CACHE_TIMEOUT = 3600

# Keep ModelBackend around for per-user permissions and maybe a local
# superuser.
AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)

---
view.py
---
from django.contrib.auth.decorators import login_required
from django.views.decorators.cache import never_cache
from django.utils.decorators import method_decorator
from django.views.generic import TemplateView

decorators = [never_cache, login_required]

@method_decorator(decorators, name='dispatch')
class ProtectedView(TemplateView):
template_name = 'Racks.html'

@method_decorator(never_cache, name='dispatch')
@method_decorator(login_required, name='dispatch')
class ProtectedView(TemplateView):
template_name = 'Racks.html'

---
urls.py
---
from django.urls import path
from django.contrib import admin
from django.contrib.auth.views import LoginView 
from . import views
from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
path(r'', LoginView.as_view(template_name='login.html'), name='redes'),
path(r'redes/', LoginView.as_view(template_name='login.html'), 
name='redes'),
path(r'Racks/', 
views.ProtectedView.as_view(template_name='Racks.html'), name='racks'),
...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

-- 
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/b7c68fcf-c9e2-4d95-975b-a12076afadab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: image didn't upload

2019-03-14 Thread Chetan Ganji
See this works or not.


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

STATIC_URL = '/static/'
MEDIA_URL = '/media/'

STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]

MEDIAFILES_DIRS = [
os.path.join(BASE_DIR, 'media'),
]

STATIC_ROOT = os.path.join(BASE_DIR, 'static-root')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media-root')




Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in



I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 9:16 PM omar ahmed  wrote:

> thanks but it doesn't work
> MEDIA_URL = '/media/'
> MEDIA_ROOT = 'media'
>
> On Thursday, March 14, 2019 at 2:36:35 PM UTC+2, Chetan Ganji wrote:
>>
>> Did you setup MEDIA-ROOT location in your settings.py
>> For reference -
>> https://docs.djangoproject.com/en/2.1/ref/settings/#media-root
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji@gmail.com
>> http://ryucoder.in
>>
>>
>>
>> 
>>  I’m
>> protected online with Avast Free Antivirus. Get it here — it’s free
>> forever.
>> 
>> <#m_7758653622765414323_CAMKMUjvxSdyNqJan2MjVcsR+igpMsj-+xZonEUTLt8HKoXBnKA@mail.gmail.com_m_4678954581711788864_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Thu, Mar 14, 2019 at 5:43 PM omar ahmed  wrote:
>>
>>> this is my model
>>> class LeagueNews(models.Model):
>>> ...
>>> news_image = models.ImageField(upload_to='core/media/core',max_length=
>>> 255, null=True,blank=True)
>>>
>>>
>>> and this is my template
>>>
>>>
>>> {% block content %}
>>>
>>> {{ article.news_title }}
>>>
>>> {{ article.publication_date }}
>>>
>>> {{ article.news_text }}
>>>
>>> 
>>>
>>> {% endblock %}
>>> the view
>>>
>>> def newsdetail(request, news_id):
>>> article = get_object_or_404(LeagueNews,pk=news_id)
>>> return render(request, 'core/newsdetail.html',{'article':article})
>>>
>>> --
>>> 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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/1d4123b8-c5bc-4bed--51bb142f21b0%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> 
>>  I’m
>> protected online with Avast Free Antivirus. Get it here — it’s free
>> forever.
>> 
>> <#m_7758653622765414323_CAMKMUjvxSdyNqJan2MjVcsR+igpMsj-+xZonEUTLt8HKoXBnKA@mail.gmail.com_m_4678954581711788864_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
> --
> 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/0a3a9cd6-83e8-4c58-ae74-2173886ae8f5%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 

Re: image didn't upload

2019-03-14 Thread omar ahmed
thanks but it doesn't work
MEDIA_URL = '/media/'
MEDIA_ROOT = 'media'

On Thursday, March 14, 2019 at 2:36:35 PM UTC+2, Chetan Ganji wrote:
>
> Did you setup MEDIA-ROOT location in your settings.py
> For reference - 
> https://docs.djangoproject.com/en/2.1/ref/settings/#media-root
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji@gmail.com 
> http://ryucoder.in
>
>
>
> 
>  I’m 
> protected online with Avast Free Antivirus. Get it here — it’s free 
> forever. 
> 
>  
> <#CAMKMUjvxSdyNqJan2MjVcsR+igpMsj-+xZonEUTLt8HKoXBnKA@mail.gmail.com_m_4678954581711788864_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Thu, Mar 14, 2019 at 5:43 PM omar ahmed  > wrote:
>
>> this is my model
>> class LeagueNews(models.Model):
>> ...
>> news_image = models.ImageField(upload_to='core/media/core',max_length=255, 
>> null=True,blank=True)
>>
>>
>> and this is my template
>>
>>
>> {% block content %}
>>
>> {{ article.news_title }}
>>
>> {{ article.publication_date }}
>>
>> {{ article.news_text }}
>>
>> 
>>
>> {% endblock %}
>> the view
>>
>> def newsdetail(request, news_id):
>> article = get_object_or_404(LeagueNews,pk=news_id)
>> return render(request, 'core/newsdetail.html',{'article':article})
>>
>> -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/1d4123b8-c5bc-4bed--51bb142f21b0%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> 
>  I’m 
> protected online with Avast Free Antivirus. Get it here — it’s free 
> forever. 
> 
>  
> <#CAMKMUjvxSdyNqJan2MjVcsR+igpMsj-+xZonEUTLt8HKoXBnKA@mail.gmail.com_m_4678954581711788864_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>

-- 
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/0a3a9cd6-83e8-4c58-ae74-2173886ae8f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread mccc


On Thursday, March 14, 2019 at 4:22:15 PM UTC+1, Chetan Ganji wrote:
>
> Why do you need to do any calculations in the model code? 
>
> I would do any calculations in the views and store them using models. That 
> will remove the getters and setters from model. 
> Everything should work fine then.
>
> Hope it helps.
>

No, nothing would work fine: in that case I would need to remember 
constantly to either copy the code to handle the behaviour or make a call 
to *a view* each time and in any place that handles those fields.
Plus the tests would need to check over and over for the same behaviour 
every time the field was involved.

I'm sorry, but it really doesn't 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/ed1853bb-402a-4688-9061-63054c44ce63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread Chetan Ganji
That approach is not working for the original poster. So I gave him a
solution that solves the problem.

I meant, its my opinion to keep models slim and write utils to make the
controllers slim.
You don't have to follow it ;-)  Follow what makes sense to you. I prefer
it that way.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in



I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 9:01 PM Sithembewena L. Dube 
wrote:

> There is nothing wrong with having logic in models.
>
> This is the principle of object orientation - encapsulating methods and
> properties in a class definition to group related behaviours and attributes
> of a specified type of entity.
>
> See the section titled "Make ‘em Fat" here:
> https://django-best-practices.readthedocs.io/en/latest/applications.html
>
>
> Kind regards,
> Sithembewena
>
>
> *Sent with Shift
> *
>
> On Thu, Mar 14, 2019 at 5:21 PM Chetan Ganji 
> wrote:
>
>> Why do you need to do any calculations in the model code?
>>
>> I would do any calculations in the views and store them using models.
>> That will remove the getters and setters from model.
>> Everything should work fine then.
>>
>> Hope it helps.
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>>
>> 
>>  I’m
>> protected online with Avast Free Antivirus. Get it here — it’s free
>> forever.
>> 
>> <#m_3800371179043208066_m_7932060366693994324_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Thu, Mar 14, 2019 at 8:31 PM mccc  wrote:
>>
>>> Hello,
>>>
>>> I have set up this nice model:
>>> class CustomGroup(models.Model):
>>>
>>> name = models.CharField(max_length=255)
>>> _parent = models.ForeignKey(
>>> "self", on_delete=models.CASCADE, null=True,
>>> related_name="descendants", db_column="parent"
>>> )
>>> _depth = models.IntegerField(default=1)
>>>
>>> @property
>>> def parent(self):
>>> return self._parent
>>>
>>> @property
>>> def depth(self):
>>> return self._depth
>>>
>>> @parent.setter
>>> def parent(self, value):
>>> if self == value:
>>> raise ValueError("parent must be different from self")
>>> p = value
>>> while value is not None:
>>> if self == value.parent:
>>> raise ValueError("parent cannot be a descendant")
>>> value = value.parent
>>> self._parent = p
>>> self.depth = (p.depth + 1) if p is not None else 1
>>>
>>> @depth.setter
>>> def depth(self, value):
>>> if value > MAX_GROUPS_DEPTH:
>>> raise ValueError("Too many nested groups")
>>>
>>> for descendant in self.descendants.all():
>>> descendant.depth = value + 1
>>> descendant.save()
>>> self._depth = value
>>>
>>>
>>> and the CASCADE function is not getting fired when the parent gets
>>> deleted;
>>> I tried adding another field without the property modifiers, and that
>>> worked as expected.
>>>
>>> Is there any way I can have both my custom getter and setter, and the
>>> on_delete behaviour?
>>>
>>> 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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/292cfb9d-c605-46ef-bb4a-5d69a8ecbb6b%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> 
>>  I’m
>> protected online with Avast Free Antivirus. Get it here — it’s free

Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread Sithembewena L. Dube
There is nothing wrong with having logic in models.

This is the principle of object orientation - encapsulating methods and
properties in a class definition to group related behaviours and attributes
of a specified type of entity.

See the section titled "Make ‘em Fat" here:
https://django-best-practices.readthedocs.io/en/latest/applications.html


Kind regards,
Sithembewena


*Sent with Shift
*

On Thu, Mar 14, 2019 at 5:21 PM Chetan Ganji  wrote:

> Why do you need to do any calculations in the model code?
>
> I would do any calculations in the views and store them using models. That
> will remove the getters and setters from model.
> Everything should work fine then.
>
> Hope it helps.
>
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
>
> 
>  I’m
> protected online with Avast Free Antivirus. Get it here — it’s free
> forever.
> 
> <#m_7932060366693994324_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Thu, Mar 14, 2019 at 8:31 PM mccc  wrote:
>
>> Hello,
>>
>> I have set up this nice model:
>> class CustomGroup(models.Model):
>>
>> name = models.CharField(max_length=255)
>> _parent = models.ForeignKey(
>> "self", on_delete=models.CASCADE, null=True,
>> related_name="descendants", db_column="parent"
>> )
>> _depth = models.IntegerField(default=1)
>>
>> @property
>> def parent(self):
>> return self._parent
>>
>> @property
>> def depth(self):
>> return self._depth
>>
>> @parent.setter
>> def parent(self, value):
>> if self == value:
>> raise ValueError("parent must be different from self")
>> p = value
>> while value is not None:
>> if self == value.parent:
>> raise ValueError("parent cannot be a descendant")
>> value = value.parent
>> self._parent = p
>> self.depth = (p.depth + 1) if p is not None else 1
>>
>> @depth.setter
>> def depth(self, value):
>> if value > MAX_GROUPS_DEPTH:
>> raise ValueError("Too many nested groups")
>>
>> for descendant in self.descendants.all():
>> descendant.depth = value + 1
>> descendant.save()
>> self._depth = value
>>
>>
>> and the CASCADE function is not getting fired when the parent gets
>> deleted;
>> I tried adding another field without the property modifiers, and that
>> worked as expected.
>>
>> Is there any way I can have both my custom getter and setter, and the
>> on_delete behaviour?
>>
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/292cfb9d-c605-46ef-bb4a-5d69a8ecbb6b%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> 
>  I’m
> protected online with Avast Free Antivirus. Get it here — it’s free
> forever.
> 
> <#m_7932060366693994324_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> --
> 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/CAMKMUjuRrwxkKGtNEKDibHMaMm4pUEP_YX2rvxZcCGJzPfDxng%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this 

Re: on_delete not getting called when ForeignKey is a property

2019-03-14 Thread Chetan Ganji
Why do you need to do any calculations in the model code?

I would do any calculations in the views and store them using models. That
will remove the getters and setters from model.
Everything should work fine then.

Hope it helps.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in



I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 8:31 PM mccc  wrote:

> Hello,
>
> I have set up this nice model:
> class CustomGroup(models.Model):
>
> name = models.CharField(max_length=255)
> _parent = models.ForeignKey(
> "self", on_delete=models.CASCADE, null=True,
> related_name="descendants", db_column="parent"
> )
> _depth = models.IntegerField(default=1)
>
> @property
> def parent(self):
> return self._parent
>
> @property
> def depth(self):
> return self._depth
>
> @parent.setter
> def parent(self, value):
> if self == value:
> raise ValueError("parent must be different from self")
> p = value
> while value is not None:
> if self == value.parent:
> raise ValueError("parent cannot be a descendant")
> value = value.parent
> self._parent = p
> self.depth = (p.depth + 1) if p is not None else 1
>
> @depth.setter
> def depth(self, value):
> if value > MAX_GROUPS_DEPTH:
> raise ValueError("Too many nested groups")
>
> for descendant in self.descendants.all():
> descendant.depth = value + 1
> descendant.save()
> self._depth = value
>
>
> and the CASCADE function is not getting fired when the parent gets deleted;
> I tried adding another field without the property modifiers, and that
> worked as expected.
>
> Is there any way I can have both my custom getter and setter, and the
> on_delete behaviour?
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/292cfb9d-c605-46ef-bb4a-5d69a8ecbb6b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

-- 
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/CAMKMUjuRrwxkKGtNEKDibHMaMm4pUEP_YX2rvxZcCGJzPfDxng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


on_delete not getting called when ForeignKey is a property

2019-03-14 Thread mccc
Hello,

I have set up this nice model:
class CustomGroup(models.Model):

name = models.CharField(max_length=255)
_parent = models.ForeignKey(
"self", on_delete=models.CASCADE, null=True, 
related_name="descendants", db_column="parent"
)
_depth = models.IntegerField(default=1)

@property
def parent(self):
return self._parent

@property
def depth(self):
return self._depth

@parent.setter
def parent(self, value):
if self == value:
raise ValueError("parent must be different from self")
p = value
while value is not None:
if self == value.parent:
raise ValueError("parent cannot be a descendant")
value = value.parent
self._parent = p
self.depth = (p.depth + 1) if p is not None else 1

@depth.setter
def depth(self, value):
if value > MAX_GROUPS_DEPTH:
raise ValueError("Too many nested groups")

for descendant in self.descendants.all():
descendant.depth = value + 1
descendant.save()
self._depth = value


and the CASCADE function is not getting fired when the parent gets deleted;
I tried adding another field without the property modifiers, and that 
worked as expected.

Is there any way I can have both my custom getter and setter, and the 
on_delete behaviour?

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/292cfb9d-c605-46ef-bb4a-5d69a8ecbb6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django credit card redaction app - - MultiValueDictKeyError

2019-03-14 Thread drone4four


I’ve discovered a ‘hack’ to correct the issue. I committed and pushed my 
changes up to my GitHub repo for those curious enough to try it out 
yourself. 

My problem now is that I don’t really understand why it works. Here I will 
explain what I do know and then my ask would be for you people to fill in 
the gaps in my explanation.  First I share my working code. 

Here is my views.py which includes the relevant function I use:

from django.http import HttpResponse



from django.shortcuts import render


def home(request):

   if 'ccEntry' in request.GET:

   number = request.GET['ccEntry']

   redacted_num = '   {}'.format(number[-4:])

   return render(request, 'home.html', {'number':number, 'redacted_num':
redacted_num})

   else:

   return render(request, 'home.html')




Here is my lucid, cerebral explanation of the above Python code in plain 
English: At line 4 I am defining the `home` function. Then there is a 
conditional referring to the ‘ccEntry’ string inside the template. If 
ccEntry is present in the GET request, then a `number` variable is declared 
based on the user input on the web page. Then a `redacted_num` variable is 
declared which will appear as a string (‘   ’ with the last 4 
characters lopped off (the slice). If all of the above is in order, then 
the render function will be returned:

   - 
   
   with the standard request,
   - 
   
   with reference to the home.html template, 
   - 
   
   along with a dictionary with a ‘number’ string matching up with the 
   `number` variable. Ditto for the redact_num.
   
However if the above condition is false, then the render function will 
return the standard request and home.html template without a dictionary. 
That’s pretty much everything I understand.  

I’m not sure why a conditional as it appears above is necessary. 

Would someone here care to explain, if you can?


On Thursday, March 7, 2019 at 4:05:28 PM UTC-5, drone4four wrote:
>
> This is a long shot, but I thought I would share a link to my source code 
> hosted on GitHub with a requirements.txt included. If any of you would like 
> to test this out yourself, I am accepting pull requests. Here it is: 
> https://github.com/Angeles4four/CC_Redact
>
>
> On Thursday, March 7, 2019 at 4:03:37 PM UTC-5, drone4four wrote:
>>
>> I am taking a course on Udemy and the instructor doesn’t include a method 
>> attribute in the form tag.  But as you suggested, Deepak, I went ahead and 
>> added method="get" to my form tag in my home.html template. So line 7 now 
>> reads: 
>>
>> I am still encountering the MultiValueDictKeyError. 
>>
>> Here is the traceback again:
>>
>> MultiValueDictKeyError at /
>>
>> 'ccEntry'
>>
>> Request Method: GET
>>
>> Request URL: http://127.0.0.1:8000/
>>
>> Django Version: 2.0.2
>>
>> Exception Type: MultiValueDictKeyError
>>
>> Exception Value: 
>>
>> 'ccEntry'
>>
>> Exception Location: 
>> /home//.local/lib/python3.7/site-packages/django/utils/datastructures.py
>>  
>> in __getitem__, line 79
>>
>> Python Executable: /usr/sbin/python
>>
>> Python Version: 3.7.2
>>
>> Python Path: 
>>
>>
>> ['/home//dev/projects/python/2018-and-2019/cel2fah-original_with_CC-redact-project-_Django202/first_project_attempt',
>>
>> '/usr/lib/python37.zip',
>>
>> '/usr/lib/python3.7',
>>
>> '/usr/lib/python3.7/lib-dynload',
>>
>> '/home//.local/lib/python3.7/site-packages',
>>
>> '/usr/lib/python3.7/site-packages',
>>
>> '/usr/lib/python3.7/site-packages/setuptools-40.6.2-py3.7.egg']
>>
>> Server time: Thu, 7 Mar 2019 20:11:44 +
>>
>> Environment:
>>
>>
>> Request Method: GET
>>
>> Request URL: http://127.0.0.1:8000/
>>
>> Django Version: 2.0.2
>>
>> Python Version: 3.7.2
>>
>> Installed Applications:
>>
>> ['django.contrib.admin',
>>
>> 'django.contrib.auth',
>>
>> 'django.contrib.contenttypes',
>>
>> 'django.contrib.sessions',
>>
>> 'django.contrib.messages',
>>
>> 'django.contrib.staticfiles']
>>
>> Installed Middleware:
>>
>> ['django.middleware.security.SecurityMiddleware',
>>
>> 'django.contrib.sessions.middleware.SessionMiddleware',
>>
>> 'django.middleware.common.CommonMiddleware',
>>
>> 'django.middleware.csrf.CsrfViewMiddleware',
>>
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>
>> 'django.contrib.messages.middleware.MessageMiddleware',
>>
>> 'django.middleware.clickjacking.XFrameOptionsMiddleware']
>>
>>
>>
>> Traceback:
>>
>> File 
>> "/home//.local/lib/python3.7/site-packages/django/utils/datastructures.py"
>>  
>> in __getitem__
>>
>>  77. list_ = super().__getitem__(key)
>>
>> During handling of the above exception ('ccEntry'), another exception 
>> occurred:
>>
>> File 
>> "/home//.local/lib/python3.7/site-packages/django/core/handlers/exception.py"
>>  
>> in inner
>>
>>  35. response = get_response(request)
>>
>> File 
>> "/home//.local/lib/python3.7/site-packages/django/core/handlers/base.py"
>>  
>> in _get_response
>>
>>  128. response = 

RE: Bug in Django 2.1 on ModelMultipleChoiceField

2019-03-14 Thread Matthew Pava
Well, it is raising an error.  It’s a Python error. Basically, you were passing 
a keyword argument (empty_label), and the class was passing the same keyword 
argument called empty_label. Expanded out, this is what was happening:

field = forms.ModelMultipleChoiceField( queryset = Imodelclass.objects.all(), 
empty_label='' )
= ModelMultipleChoiceField(queryset= Imodelclass.objects.all(), 
empty_label=None, empty_label='')

When you read the error, you see that is actually very clear in this context: 
You passed two arguments for the same keyword.
typeError " __init__() got multiple values for keyword argument 'empty_label'

I think it would be wise to mention this in the documentation; perhaps even 
providing a rationale why ModelMultipleChoiceField should not have an empty 
label. But if there is no rationale behind it, then the clear solution is to do 
exactly as you did: remove the empty_label keyword argument from the super call.

From: Odile Lambert [mailto:pisc...@laposte.net]
Sent: Thursday, March 14, 2019 2:10 AM
To: django-users@googlegroups.com; Matthew Pava
Subject: Re: Bug in Django 2.1 on ModelMultipleChoiceField


Hello

If this is by design Django should raise an error indicating that 
ModelMultipleChoiceField does not allow an empty_label attribute

The present error message in the __init__ of the super_class is not coherent 
and very difficult to understand for beginners. I would strongly suggest that 
it is filed as a bug to improve the code either by allowing the empty label or 
by raising the propoer error.

Modifying the documentation does not seem sufficient from my point of view.

Thanks for your suggestion for creating a specific class.

Odile Lambert


Le 13/03/2019 à 22:06, Matthew Pava a écrit :
Looking at it, I would say that this is by design. You shouldn’t use an empty 
label on a multiple choice field. Perhaps this should be clarified in the docs.
Saying that, if you really want an empty label on a multiple choice field, you 
could create your own class that initializes empty_label however you want it.

From: 'Odile Lambert' via Django users [mailto:django-users@googlegroups.com]
Sent: Wednesday, March 13, 2019 1:57 PM
To: Django users
Subject: Bug in Django 2.1 on ModelMultipleChoiceField


Hello,

I believe Bugs in Django are to be reported in this user list. Below is a 
report for a bug which does not seem to be already filed.

In the documentation reference on the ModelMultipleChoiceField there is no 
restrictios mentioned on the empty_label attribute.

Whenever you declare an attribute empy_label for a ModelMultipleChoiceField, it 
generates an error during the system_checks

 typeError " __init__() got multiple values for keyword argument 'empty_label

To reproduce the bug : :

class MyForm(forms.Form):
field = forms.ModelMultipleChoiceField(
queryset = Imodelclass.objects.all(),)
empty_label=(''))

Another user on stackoverflow encountered  this same problem see here : 
https://stackoverflow.com/questions/52263426/django-empty-label-for-modelmultiplechoicefield-multiple-values-for-keyword-arg

The cause of the error is the following :

the code ( see fdjango/forms/models.py line 1266 sets the empty_label attribute 
to None while calling the super_class (ModelChoiceField):

super().__init__(queryset, empty_label=None, **kwargs)

while the super_class.__init__ sets the empy_label to "-".

removing the empty_label= None in the call to the super_class solved the 
problem for me.

best regards

Odile Lambert

--
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/063841b4-5b58-4931-6ea3-29188ccc8171%40laposte.net.
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 

Re: Using sessions key variables as a url argument

2019-03-14 Thread Perchouli
Hi Gavin,

You passed pk from URL.

class TeamInfo(APIView):
#...
def get(self, request, pk): # Add pk to params
club_pk = self.kwargs.get('pk') # get the pk
#...
return Response({
 'club_pk': club_pk
 })

Will pass the pk into this template.

Team


BR,

Alvaro

On Wed, Mar 13, 2019 at 8:27 AM GavinB841  wrote:

> Hi Alvaro/Ranganath,
>
> Appreciate your feedback, I understand what you are recommending but I can
> seem to get it working.
>
> Please see the below hopefully it will make more sense:
>
> *View sample for team:*
>
> class TeamInfo(APIView):
> renderer_classes = [TemplateHTMLRenderer]
> template_name = 'teams.html'
>
> def get(self, request):
> club_pk = request.session.get('pk')
> form = TeamForm()
> teams = Team.objects.filter(club_id=club_pk)
> return Response({'form': form,
>  'teams': teams,
>  'club_pk': club_pk
>  })
>
>
> *Urls: *
>
> urlpatterns = [
> path('', views.club_home, name='club_home'),
> path('/', views.club_home, name='club_home_with_pk'),
> path('/teams/', views.TeamInfo.as_view(), name='teams'),
> ]
>
>
> *In my nav bar in the template: *
>
> Team
>
>
> How can I pass that session key argument into this template?
>
> Thanks
>
> Gavin
>
>
> On Sunday, 10 March 2019 14:57:43 UTC, GavinB841 wrote:
>>
>> Hi all,
>>
>> I am not sure if this is possible as I could find nothing online but
>> would appreciate any alternative solution.
>>
>>- In my view I obtain a pk which is set as a session key
>>- I need to pass that session key variable into the url argument.
>>
>> e.g. http://127.0.0.1:8000/club_home//teams/
>>
>> Code below, any other samples of code needed let me know
>>
>> Thanks
>> Gav
>>
>> *Main Urls*
>>
>> urlpatterns = [
>> url('admin/', admin.site.urls),
>> url(r'^club_home/', include('clubkit.clubs.urls'), name='clubs'),
>> ]
>>
>> *Urls.py*
>>
>> urlpatterns = [
>> path('', views.club_home, name='club_home'),
>> path('teams/', views.TeamInfo.as_view(), name='teams'),
>> path('pitches/', views.PitchInfo.as_view(), name='pitches'),
>> ]
>>
>> *View.py:*
>>
>> def club_home(request, pk=None):
>> if pk:
>> request.session['pk'] = pk
>> club = ClubInfo.objects.filter(pk=pk)
>> club_posts = ClubPosts.objects.filter(club_id=club[0])
>> else:
>> club_pk = request.session.get('pk')
>> club = ClubInfo.objects.filter(pk=club_pk)
>> club_posts = ClubPosts.objects.filter(club_id=club[0])
>> args = {'club': club,
>> 'club_posts': club_posts
>> }
>> return render(request, 'club_home_page.html', args)
>>
>>
>> *Séanadh Ríomhphoist/Email DisclaimerTá an ríomhphost seo agus aon
>> chomhad a sheoltar leis faoi rún agus is lena úsáid ag an seolaí agus sin
>> amháin é. Is féidir tuilleadh a léamh anseo.
>> 
>> This e-mail and any
>> files transmitted with it are confidential and are intended solely for use
>> by the addressee. Read more here.
>>  *
>>
>>
> *Séanadh Ríomhphoist/Email DisclaimerTá an ríomhphost seo agus aon chomhad
> a sheoltar leis faoi rún agus is lena úsáid ag an seolaí agus sin amháin
> é. Is féidir tuilleadh a léamh anseo.
> 
> This e-mail and any
> files transmitted with it are confidential and are intended solely for use
> by the addressee. Read more here.
>  *
>
> --
> 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/7c47d2e6-d1be-49f4-84c2-a12536164105%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 

Re: Very much begineer

2019-03-14 Thread Chetan Ganji
Look no further codingforentrepreneurs
Start with trydjango 1.8 project. See his youtube channel.

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in



I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 6:29 PM AhenTheBegineer 
wrote:

> Hello,
> I'm very new to the software and pretty much know about python(less than
> basics) so I want to explore django.
> And want to know how it works, what software are needed for it and how do
> I start with the softwae to be handy with it.
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5fda8787-9841-4b9f-885d-f43e4e0e5d41%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/CAMKMUjvfuF88sDq39PL8tk8CY73MGp%3DGzJnfyoRXjeiiO3mL_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Very much begineer

2019-03-14 Thread AhenTheBegineer
Hello,
I'm very new to the software and pretty much know about python(less than 
basics) so I want to explore django.
And want to know how it works, what software are needed for it and how do I 
start with the softwae to be handy with it.
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5fda8787-9841-4b9f-885d-f43e4e0e5d41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: image didn't upload

2019-03-14 Thread Chetan Ganji
Did you setup MEDIA-ROOT location in your settings.py
For reference -
https://docs.djangoproject.com/en/2.1/ref/settings/#media-root

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in



I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#m_4678954581711788864_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Thu, Mar 14, 2019 at 5:43 PM omar ahmed  wrote:

> this is my model
> class LeagueNews(models.Model):
> ...
> news_image = models.ImageField(upload_to='core/media/core',max_length=255,
> null=True,blank=True)
>
>
> and this is my template
>
>
> {% block content %}
>
> {{ article.news_title }}
>
> {{ article.publication_date }}
>
> {{ article.news_text }}
>
> 
>
> {% endblock %}
> the view
>
> def newsdetail(request, news_id):
> article = get_object_or_404(LeagueNews,pk=news_id)
> return render(request, 'core/newsdetail.html',{'article':article})
>
> --
> 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/1d4123b8-c5bc-4bed--51bb142f21b0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.

<#m_4678954581711788864_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

-- 
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/CAMKMUjvxSdyNqJan2MjVcsR%2BigpMsj-%2BxZonEUTLt8HKoXBnKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


image didn't upload

2019-03-14 Thread omar ahmed
this is my model
class LeagueNews(models.Model):
...
news_image = models.ImageField(upload_to='core/media/core',max_length=255, 
null=True,blank=True)


and this is my template


{% block content %}

{{ article.news_title }}

{{ article.publication_date }}

{{ article.news_text }}



{% endblock %}
the view

def newsdetail(request, news_id):
article = get_object_or_404(LeagueNews,pk=news_id)
return render(request, 'core/newsdetail.html',{'article':article})

-- 
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/1d4123b8-c5bc-4bed--51bb142f21b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: migrating from sqlite to mysql breaks the site

2019-03-14 Thread Anh Nguyen
I see 2 ways to handle.
1: would you want to try postgresql ?, if this get the same trouble. We got
the big problems.
2: try to create a blank project start from django-admin ... it’s not
greater then 20mins.



On Thu, Mar 14, 2019 at 5:26 PM Ayser shuhaib 
wrote:

> In your settings, you put the port is 3306 but in the url it’s 8000.
> I think the problem is there.
>
> On Thu, 14 Mar 2019 at 12:07, Pedram Badakhchani <
> pedrambadakhch...@gmail.com> wrote:
>
>> Hi Anh,
>>
>> yes, everything works fine, the only problem is once I switched from
>> sqlite to mysql,
>>
>> I am able to access the admin backend and create a post...
>>
>> I am able to view the list of posts created, however when I click a given
>> post, with SQLite I can navigate to
>> a page showing the post details as expected.
>>
>> However, switching to mysql breaks the redirecting to post details. I get No
>> Post matches the given query.
>>
>> I am not sure why this happens. I thought the Django ORM means that the
>> code should work regardless of the
>> database used. So I am confused why this happens.
>>
>> best
>>
>> Pedram
>>
>>
>> On Wednesday, 13 March 2019 15:47:54 UTC, Anh Nguyen wrote:
>>>
>>> Could you insert a post on admin panel ?
>>>
>>> On Wed, Mar 13, 2019 at 10:38 PM Pedram Badakhchani <
>>> pedramba...@gmail.com> wrote:
>>>
 bump

 On Wednesday, 6 March 2019 10:44:56 UTC, Pedram Badakhchani wrote:
>
> specifically in the get_absolute_url method.
>>
>
> I don't understand why this works fine with sqlite but breaks in mysql.
>
> thanks for any 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...@googlegroups.com.
 To post to this group, send email to django...@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/4db98bc9-72f6-4914-8d48-7ae60308a14e%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/3be89d40-170d-4c7f-9d5b-c7417543a540%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/CAE0AZGKY21FDNCXDWq2OLKz8hyr8i0Gm1oSZcBV0aYRBwn2AJQ%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/CAKaoNbQ9-%3D02ASscLkVZ6DSQKvrWd2zw37uyn3B82JqWx3wt_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: migrating from sqlite to mysql breaks the site

2019-03-14 Thread Ayser shuhaib
In your settings, you put the port is 3306 but in the url it’s 8000.
I think the problem is there.

On Thu, 14 Mar 2019 at 12:07, Pedram Badakhchani <
pedrambadakhch...@gmail.com> wrote:

> Hi Anh,
>
> yes, everything works fine, the only problem is once I switched from
> sqlite to mysql,
>
> I am able to access the admin backend and create a post...
>
> I am able to view the list of posts created, however when I click a given
> post, with SQLite I can navigate to
> a page showing the post details as expected.
>
> However, switching to mysql breaks the redirecting to post details. I get No
> Post matches the given query.
>
> I am not sure why this happens. I thought the Django ORM means that the
> code should work regardless of the
> database used. So I am confused why this happens.
>
> best
>
> Pedram
>
>
> On Wednesday, 13 March 2019 15:47:54 UTC, Anh Nguyen wrote:
>>
>> Could you insert a post on admin panel ?
>>
>> On Wed, Mar 13, 2019 at 10:38 PM Pedram Badakhchani <
>> pedramba...@gmail.com> wrote:
>>
>>> bump
>>>
>>> On Wednesday, 6 March 2019 10:44:56 UTC, Pedram Badakhchani wrote:

 specifically in the get_absolute_url method.
>

 I don't understand why this works fine with sqlite but breaks in mysql.

 thanks for any 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/4db98bc9-72f6-4914-8d48-7ae60308a14e%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/3be89d40-170d-4c7f-9d5b-c7417543a540%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/CAE0AZGKY21FDNCXDWq2OLKz8hyr8i0Gm1oSZcBV0aYRBwn2AJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: migrating from sqlite to mysql breaks the site

2019-03-14 Thread Pedram Badakhchani
Hi Anh,

yes, everything works fine, the only problem is once I switched from sqlite 
to mysql, 

I am able to access the admin backend and create a post...

I am able to view the list of posts created, however when I click a given 
post, with SQLite I can navigate to 
a page showing the post details as expected.

However, switching to mysql breaks the redirecting to post details. I get No 
Post matches the given query.

I am not sure why this happens. I thought the Django ORM means that the 
code should work regardless of the 
database used. So I am confused why this happens.

best

Pedram


On Wednesday, 13 March 2019 15:47:54 UTC, Anh Nguyen wrote:
>
> Could you insert a post on admin panel ?
>
> On Wed, Mar 13, 2019 at 10:38 PM Pedram Badakhchani  > wrote:
>
>> bump
>>
>> On Wednesday, 6 March 2019 10:44:56 UTC, Pedram Badakhchani wrote:
>>>
>>> specifically in the get_absolute_url method.

>>>
>>> I don't understand why this works fine with sqlite but breaks in mysql.
>>>
>>> thanks for any 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...@googlegroups.com .
>> To post to this group, send email to django...@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/4db98bc9-72f6-4914-8d48-7ae60308a14e%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/3be89d40-170d-4c7f-9d5b-c7417543a540%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bug in Django 2.1 on ModelMultipleChoiceField

2019-03-14 Thread 'Odile Lambert' via Django users

  
  
Hello
If this is by design Django should raise an error indicating that
  ModelMultipleChoiceField does not allow an empty_label attribute 

The present error message in the __init__ of the super_class is
  not coherent and very difficult to understand for beginners. I
  would strongly suggest that it is filed as a bug to improve the
  code either by allowing the empty label or by raising the propoer
  error.
Modifying the documentation does not seem sufficient from my
  point of view.

Thanks for your suggestion for creating a specific class.
Odile Lambert



Le 13/03/2019 à 22:06, Matthew Pava a
  écrit :


  
  
  
  
Looking
at it, I would say that this is by design. You shouldn’t use
an empty label on a multiple choice field. Perhaps this
should be clarified in the docs.
Saying
that, if you really want an empty label on a multiple choice
field, you could create your own class that initializes
empty_label however you want it.

 

  
From:
'Odile Lambert' via Django users
[mailto:django-users@googlegroups.com]

Sent: Wednesday, March 13, 2019 1:57 PM
To: Django users
Subject: Bug in Django 2.1 on
ModelMultipleChoiceField
  

 
Hello,
I believe Bugs in Django are to be reported in this user
  list. Below is a report for a bug which does not seem to be
  already filed.
In the documentation reference on the
  ModelMultipleChoiceField there is no restrictios mentioned on
  the empty_label attribute.
  
Whenever you declare an attribute empy_label for a
  ModelMultipleChoiceField, it generates an error during the
  system_checks
 typeError " __init__() got multiple values for keyword argument 'empty_label
To reproduce the bug : :
class MyForm(forms.Form):
      field = forms.ModelMultipleChoiceField(
      queryset = Imodelclass.objects.all(),)
      empty_label=(''))
Another user on stackoverflow encountered  this same problem
  see here : 
https://stackoverflow.com/questions/52263426/django-empty-label-for-modelmultiplechoicefield-multiple-values-for-keyword-arg
  
The cause of the error is the following :
the code ( see fdjango/forms/models.py line 1266 sets the
  empty_label attribute to None while calling the super_class
  (ModelChoiceField):
super().__init__(queryset, empty_label=None, **kwargs)
while the super_class.__init__ sets the empy_label to
  "-". 
removing the empty_label= None in the call to the super_class
  solved the problem for me.
  
best regards
Odile Lambert
 
-- 
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/063841b4-5b58-4931-6ea3-29188ccc8171%40laposte.net.
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/c6be6380098a49b6bab737a85e1b5d5b%40iss2.ISS.LOCAL.
  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/d1387fdf-7729-fc81-f311-0b4919fff6c0%40laposte.net.
For more options, visit https://groups.google.com/d/optout.