Re: How to run django server locally, if there are multiple settings file in Django Project. if the repo is cloned from Office work space to local(newly hired as intern) (no requirements.txt)

2020-04-21 Thread chaitanya orakala
Thanks, I will definitely look into it.

On Tue, Apr 21, 2020 at 5:13 PM ELMER IBAYAN  wrote:

> Hi Chaitan,
>
> After some googling around, i found this article which I believe would
> help you.
>
> https://simpleisbetterthancomplex.com/tips/2017/07/03/django-tip-20-working-with-multiple-settings-modules.html
>
> By the way, i find the project seems interesting from looking at the
> settings. Would you mind sharing the link to the project?..Thanks.
>
> Regards,
> Elmer
>
> On Wednesday, 22 April 2020 08:36:08 UTC+10, chaitan wrote:
>>
>> Hi Django Aspirants,
>> I am trying to run localhost:8000 to run the server after the cloning the
>> project. from GitHub. I figured out the process to follow after downloading
>> the project. I can open all files from the sublime text editor and saw
>> multiple settings.py files in the main project. I am a beginner I had only
>> knowledge about how to play with single settings.py file. Other settings.py
>> files are importing common settings file..
>> So my question is do need to create another settings file like others to
>> start the server ?? or is there any process to follow.
>> Please ignore my English and level of knowledge. Any help is much
>> appreciated
>> Database: Postgres
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/30f306fe-beeb-4ecf-9974-de0afce11c65%40googlegroups.com
> 
> .
>

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


Re: save() got an unexpected keyword argument 'force_insert'

2020-04-21 Thread Motaz Hejaze
nice to know, good luck

On Wed, Apr 22, 2020 at 5:35 AM Ahmed Khairy 
wrote:

> Thank you so much it is realyy helpfull. Fixed it
>
> On Tuesday, April 21, 2020 at 11:23:10 PM UTC-4, Motaz Hejaze wrote:
>>
>> check this out
>>
>> https://wsvincent.com/django-allauth-tutorial-custom-user-model/
>>
>> On Wed, Apr 22, 2020 at 5:18 AM Ahmed Khairy 
>> wrote:
>>
>>> What do you mean ?
>>>
>>> On Tuesday, April 21, 2020 at 11:13:16 PM UTC-4, Motaz Hejaze wrote:

 did you define managers ?

 On Wed, Apr 22, 2020 at 5:06 AM Ahmed Khairy 
 wrote:

> Model Form
>
> UserCreationForm
>
> On Tuesday, April 21, 2020 at 11:02:13 PM UTC-4, Motaz Hejaze wrote:
>>
>> what kind of forms is this ? regular form or model form ?
>>
>>
>> On Wed, Apr 22, 2020 at 4:57 AM Ahmed Khairy 
>> wrote:
>>
>>> Hi all,
>>>
>>> Got this unexpected error all of a sudden, how to fix it.
>>>
>>> save() got an unexpected keyword argument 'force_insert'
>>>
>>>
>>>
>>> def register(request):
>>> if request.method == 'POST':
>>> form = UserRegisterForm(request.POST)
>>> if form.is_valid():
>>> form.save()
>>> username = form.cleaned_data.get('username')
>>> messages.success(
>>> request, f
>>> 'Your account has been created! You are now able to log in')
>>> return redirect('login')
>>> else:
>>> form = UserRegisterForm()
>>> return render(request, 'register.html', {'form': form})
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/be6de004-4a69-4346-8a12-99eced8d76a3%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4a164104-3cab-4d97-a6ac-47b9a3ed98dd%40googlegroups.com
> 
> .
>
 --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/affd82c8-1b8c-46a0-85c0-a3a5c6939abe%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3983161c-10b7-4e0d-b2ba-8dbf83e3b890%40googlegroups.com
> 
> .
>

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


While executing a Celery Task : 'AsyncResult' object is not iterable

2020-04-21 Thread Dilipkumar Noone


I am Using Celery to perform a task in the background on form submission. 
As soon as form is submitted during POST request, I have created a task to 
execute in the back ground using delay method. This task processes some 
click operations on some other web using selenium web driver and return two 
python lists after task execution. Based on list content I want to display 
pop up message.

When I execute the task using celery and run the Django web development 
server on form submit , I am getting error message: 'AsyncResult' object is 
not iterable”.

Please suggest how to resolve this issue and proceed further.

Here is my code snippet: sample List content which obtained through 
selenium operations on web page is as shown below:


board_not_used_list = ['16123','14960']
board_mgr_permissions_not_present_list = [ '23456','45678']

 views.py:
 
def conclude_key_issue_form(request, id=None):
if id:
action = 'edit'
model = get_object_or_404(ConcludeKeyIssues, pk=id)

else:
action = 'submit'
model = ConcludeKeyIssues()

message = ""   


if request.method == 'POST':

form = ConcludeKeyIssuesForm(request.POST, instance=model)

selected_model_name = request.POST.get('registered_model')  


if form.is_valid():

new_key_issue_request = form.save(commit=False)
new_key_issue_request.integrator_id = request.user.username

integrator_username = new_key_issue_request.integrator_id
integrator_password = form.cleaned_data['integrator_pwd']

new_key_issue_request.integrator_pwd = integrator_password

new_key_issue_request.save()
form.save_m2m()

created_pk = new_key_issue_request.pk

if id is None:
board_not_used_list,
   board_mgr_permissions_not_present_list=  
   
  task_check_board_availability_and_permissions.delay(created_pk)

if board_not_used_list and 
board_mgr_permissions_not_present_list:
alert_flag = True
alert_message = "SAS Board ID's:{} in Not Used state."
context = {'form': form, 'registered_model_data': 
registered_models,   
   'alert': alert_flag, 'alert_message': 
json.dumps(alert_message)}
return render(request, 'ConcludeKeyIssue.html', context)

elif not board_not_used_list and 
board_mgr_permissions_not_present_list:
alert_flag = True
alert_message = "You don't have Board Manager Permissions"
context = {'form': form, 'registered_model_data': 
registered_models,
   'alert': alert_flag, 'alert_message': 
json.dumps(alert_message)}
return render(request, 'ConcludeKeyIssue.html', context)

return HttpResponseRedirect('/swatapp/ConcludeKeyIssueList')
else:
print("Fill Conclude Key Issues")
form = ConcludeKeyIssuesForm(instance=model)

context = {'form': form,'Message': message, 'action': action}

return render(request, 'ConcludeKeyIssue.html', context)
Tasks.py:@app.task(name="task_check_board_availability_and_permissions")def
 task_check_board_availability_and_permissions(created_pk):
print("From tasks.py conclude_key_issue_through_selenium")

print("Conclude Key Issue Through Selenium")

latest_record_pk = created_pk

# Get the instances of ConcludeKeyIssues
conclude_key_issue_obj_list = ConcludeKeyIssues.objects.all()

# Get the latest created record details
get_created_record_details = 
ConcludeKeyIssues.objects.get(pk=latest_record_pk)

# Get the id or location value of selected from SAS URL
sas_board_ids = get_created_record_details.sas_ids

# Get SAS Board IDs in list
sas_board_ids_list = sas_board_ids.split(",")


# Input username and password
username = get_created_record_details.integrator_id
password = get_created_record_details.integrator_pwd

board_not_used_list, board_mgr_permissions_not_present_list = \

check_board_availability_and_permissions_for_all_requested_sas(sas_board_ids_list,
 username, 
   password)


return board_not_used_list, board_mgr_permissions_not_present_list



settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
'swatapp',
'django_celery_results',]
CELERY_BROKER_URL = 'amqp://guest:guest@localhost:5672//'
CELERY_RESULT_BACKEND = 'django-db'

1.Please suggest how to resolve this error and proceed further.

2.How to retrieve the 2 lists [ 

Re: save() got an unexpected keyword argument 'force_insert'

2020-04-21 Thread Ahmed Khairy
Thank you so much it is realyy helpfull. Fixed it 

On Tuesday, April 21, 2020 at 11:23:10 PM UTC-4, Motaz Hejaze wrote:
>
> check this out
>
> https://wsvincent.com/django-allauth-tutorial-custom-user-model/
>
> On Wed, Apr 22, 2020 at 5:18 AM Ahmed Khairy  > wrote:
>
>> What do you mean ? 
>>
>> On Tuesday, April 21, 2020 at 11:13:16 PM UTC-4, Motaz Hejaze wrote:
>>>
>>> did you define managers ?
>>>
>>> On Wed, Apr 22, 2020 at 5:06 AM Ahmed Khairy  
>>> wrote:
>>>
 Model Form 

 UserCreationForm

 On Tuesday, April 21, 2020 at 11:02:13 PM UTC-4, Motaz Hejaze wrote:
>
> what kind of forms is this ? regular form or model form ?
>
>
> On Wed, Apr 22, 2020 at 4:57 AM Ahmed Khairy  
> wrote:
>
>> Hi all, 
>>
>> Got this unexpected error all of a sudden, how to fix it. 
>>
>> save() got an unexpected keyword argument 'force_insert'
>>
>>
>>
>> def register(request):
>> if request.method == 'POST':
>> form = UserRegisterForm(request.POST)
>> if form.is_valid():
>> form.save()
>> username = form.cleaned_data.get('username')
>> messages.success(
>> request, f
>> 'Your account has been created! You are now able to log in')
>> return redirect('login')
>> else:
>> form = UserRegisterForm()
>> return render(request, 'register.html', {'form': form})
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/be6de004-4a69-4346-8a12-99eced8d76a3%40googlegroups.com
>>  
>> 
>> .
>>
> -- 
 You received this message because you are subscribed to the Google 
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to django...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/4a164104-3cab-4d97-a6ac-47b9a3ed98dd%40googlegroups.com
  
 
 .

>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/affd82c8-1b8c-46a0-85c0-a3a5c6939abe%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3983161c-10b7-4e0d-b2ba-8dbf83e3b890%40googlegroups.com.


Re: save() got an unexpected keyword argument 'force_insert'

2020-04-21 Thread Ahmed Khairy
Thank you so much it realyy helpfull. Fixed it 

On Tuesday, April 21, 2020 at 11:23:10 PM UTC-4, Motaz Hejaze wrote:
>
> check this out
>
> https://wsvincent.com/django-allauth-tutorial-custom-user-model/
>
> On Wed, Apr 22, 2020 at 5:18 AM Ahmed Khairy  > wrote:
>
>> What do you mean ? 
>>
>> On Tuesday, April 21, 2020 at 11:13:16 PM UTC-4, Motaz Hejaze wrote:
>>>
>>> did you define managers ?
>>>
>>> On Wed, Apr 22, 2020 at 5:06 AM Ahmed Khairy  
>>> wrote:
>>>
 Model Form 

 UserCreationForm

 On Tuesday, April 21, 2020 at 11:02:13 PM UTC-4, Motaz Hejaze wrote:
>
> what kind of forms is this ? regular form or model form ?
>
>
> On Wed, Apr 22, 2020 at 4:57 AM Ahmed Khairy  
> wrote:
>
>> Hi all, 
>>
>> Got this unexpected error all of a sudden, how to fix it. 
>>
>> save() got an unexpected keyword argument 'force_insert'
>>
>>
>>
>> def register(request):
>> if request.method == 'POST':
>> form = UserRegisterForm(request.POST)
>> if form.is_valid():
>> form.save()
>> username = form.cleaned_data.get('username')
>> messages.success(
>> request, f
>> 'Your account has been created! You are now able to log in')
>> return redirect('login')
>> else:
>> form = UserRegisterForm()
>> return render(request, 'register.html', {'form': form})
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/be6de004-4a69-4346-8a12-99eced8d76a3%40googlegroups.com
>>  
>> 
>> .
>>
> -- 
 You received this message because you are subscribed to the Google 
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to django...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/4a164104-3cab-4d97-a6ac-47b9a3ed98dd%40googlegroups.com
  
 
 .

>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/affd82c8-1b8c-46a0-85c0-a3a5c6939abe%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2633ef13-a6a3-449e-ae91-f175cf7ea37a%40googlegroups.com.


Re: save() got an unexpected keyword argument 'force_insert'

2020-04-21 Thread Motaz Hejaze
check this out

https://wsvincent.com/django-allauth-tutorial-custom-user-model/

On Wed, Apr 22, 2020 at 5:18 AM Ahmed Khairy 
wrote:

> What do you mean ?
>
> On Tuesday, April 21, 2020 at 11:13:16 PM UTC-4, Motaz Hejaze wrote:
>>
>> did you define managers ?
>>
>> On Wed, Apr 22, 2020 at 5:06 AM Ahmed Khairy 
>> wrote:
>>
>>> Model Form
>>>
>>> UserCreationForm
>>>
>>> On Tuesday, April 21, 2020 at 11:02:13 PM UTC-4, Motaz Hejaze wrote:

 what kind of forms is this ? regular form or model form ?


 On Wed, Apr 22, 2020 at 4:57 AM Ahmed Khairy 
 wrote:

> Hi all,
>
> Got this unexpected error all of a sudden, how to fix it.
>
> save() got an unexpected keyword argument 'force_insert'
>
>
>
> def register(request):
> if request.method == 'POST':
> form = UserRegisterForm(request.POST)
> if form.is_valid():
> form.save()
> username = form.cleaned_data.get('username')
> messages.success(
> request, f
> 'Your account has been created! You are now able to log in')
> return redirect('login')
> else:
> form = UserRegisterForm()
> return render(request, 'register.html', {'form': form})
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/be6de004-4a69-4346-8a12-99eced8d76a3%40googlegroups.com
> 
> .
>
 --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/4a164104-3cab-4d97-a6ac-47b9a3ed98dd%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/affd82c8-1b8c-46a0-85c0-a3a5c6939abe%40googlegroups.com
> 
> .
>

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


Re: save() got an unexpected keyword argument 'force_insert'

2020-04-21 Thread Ahmed Khairy
What do you mean ? 

On Tuesday, April 21, 2020 at 11:13:16 PM UTC-4, Motaz Hejaze wrote:
>
> did you define managers ?
>
> On Wed, Apr 22, 2020 at 5:06 AM Ahmed Khairy  > wrote:
>
>> Model Form 
>>
>> UserCreationForm
>>
>> On Tuesday, April 21, 2020 at 11:02:13 PM UTC-4, Motaz Hejaze wrote:
>>>
>>> what kind of forms is this ? regular form or model form ?
>>>
>>>
>>> On Wed, Apr 22, 2020 at 4:57 AM Ahmed Khairy  
>>> wrote:
>>>
 Hi all, 

 Got this unexpected error all of a sudden, how to fix it. 

 save() got an unexpected keyword argument 'force_insert'



 def register(request):
 if request.method == 'POST':
 form = UserRegisterForm(request.POST)
 if form.is_valid():
 form.save()
 username = form.cleaned_data.get('username')
 messages.success(
 request, f
 'Your account has been created! You are now able to log in')
 return redirect('login')
 else:
 form = UserRegisterForm()
 return render(request, 'register.html', {'form': form})

 -- 
 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...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/be6de004-4a69-4346-8a12-99eced8d76a3%40googlegroups.com
  
 
 .

>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/4a164104-3cab-4d97-a6ac-47b9a3ed98dd%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/affd82c8-1b8c-46a0-85c0-a3a5c6939abe%40googlegroups.com.


Re: save() got an unexpected keyword argument 'force_insert'

2020-04-21 Thread Motaz Hejaze
did you define managers ?

On Wed, Apr 22, 2020 at 5:06 AM Ahmed Khairy 
wrote:

> Model Form
>
> UserCreationForm
>
> On Tuesday, April 21, 2020 at 11:02:13 PM UTC-4, Motaz Hejaze wrote:
>>
>> what kind of forms is this ? regular form or model form ?
>>
>>
>> On Wed, Apr 22, 2020 at 4:57 AM Ahmed Khairy 
>> wrote:
>>
>>> Hi all,
>>>
>>> Got this unexpected error all of a sudden, how to fix it.
>>>
>>> save() got an unexpected keyword argument 'force_insert'
>>>
>>>
>>>
>>> def register(request):
>>> if request.method == 'POST':
>>> form = UserRegisterForm(request.POST)
>>> if form.is_valid():
>>> form.save()
>>> username = form.cleaned_data.get('username')
>>> messages.success(
>>> request, f
>>> 'Your account has been created! You are now able to log in')
>>> return redirect('login')
>>> else:
>>> form = UserRegisterForm()
>>> return render(request, 'register.html', {'form': form})
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/be6de004-4a69-4346-8a12-99eced8d76a3%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4a164104-3cab-4d97-a6ac-47b9a3ed98dd%40googlegroups.com
> 
> .
>

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


Re: save() got an unexpected keyword argument 'force_insert'

2020-04-21 Thread Ahmed Khairy
Model Form 

UserCreationForm

On Tuesday, April 21, 2020 at 11:02:13 PM UTC-4, Motaz Hejaze wrote:
>
> what kind of forms is this ? regular form or model form ?
>
>
> On Wed, Apr 22, 2020 at 4:57 AM Ahmed Khairy  > wrote:
>
>> Hi all, 
>>
>> Got this unexpected error all of a sudden, how to fix it. 
>>
>> save() got an unexpected keyword argument 'force_insert'
>>
>>
>>
>> def register(request):
>> if request.method == 'POST':
>> form = UserRegisterForm(request.POST)
>> if form.is_valid():
>> form.save()
>> username = form.cleaned_data.get('username')
>> messages.success(
>> request, f
>> 'Your account has been created! You are now able to log in')
>> return redirect('login')
>> else:
>> form = UserRegisterForm()
>> return render(request, 'register.html', {'form': form})
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/be6de004-4a69-4346-8a12-99eced8d76a3%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4a164104-3cab-4d97-a6ac-47b9a3ed98dd%40googlegroups.com.


Re: save() got an unexpected keyword argument 'force_insert'

2020-04-21 Thread Motaz Hejaze
what kind of forms is this ? regular form or model form ?


On Wed, Apr 22, 2020 at 4:57 AM Ahmed Khairy 
wrote:

> Hi all,
>
> Got this unexpected error all of a sudden, how to fix it.
>
> save() got an unexpected keyword argument 'force_insert'
>
>
>
> def register(request):
> if request.method == 'POST':
> form = UserRegisterForm(request.POST)
> if form.is_valid():
> form.save()
> username = form.cleaned_data.get('username')
> messages.success(
> request, f
> 'Your account has been created! You are now able to log in')
> return redirect('login')
> else:
> form = UserRegisterForm()
> return render(request, 'register.html', {'form': form})
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/be6de004-4a69-4346-8a12-99eced8d76a3%40googlegroups.com
> 
> .
>

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


save() got an unexpected keyword argument 'force_insert'

2020-04-21 Thread Ahmed Khairy
Hi all, 

Got this unexpected error all of a sudden, how to fix it. 

save() got an unexpected keyword argument 'force_insert'



def register(request):
if request.method == 'POST':
form = UserRegisterForm(request.POST)
if form.is_valid():
form.save()
username = form.cleaned_data.get('username')
messages.success(
request, f
'Your account has been created! You are now able to log in')
return redirect('login')
else:
form = UserRegisterForm()
return render(request, 'register.html', {'form': form})

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/be6de004-4a69-4346-8a12-99eced8d76a3%40googlegroups.com.


Whats the best package for Django-admin styling

2020-04-21 Thread suman patel
Hi,
   We are having Django admin used extensively in our project. Any
suggestions for adding more style and features to it. I searched Django-
grappelli.
Anyone using it. Any feedback and basic features you have used so far.

Thx
patel

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


Re: Getting approval from Admin first before posting a blog in Django

2020-04-21 Thread Motaz Hejaze
in post model add a  boolean field ( approved : default = false ) ..
and in your views filter only approved posts before showing them ...
this way admin can login to admin panel , check the latest posts and
approve them ( make approve = True ) then and only then they will be viewed
in your templates

On Wed, Apr 22, 2020 at 3:04 AM Ahmed Khairy 
wrote:

> Hi all,
>
> I have made a blog as a project and I have set users to submit posts for
> the blog directly but i want to direct this post to the admin first for
> approval before showing on the website. here is the Post Create View Class.
>
> class PostCreateView(CreateView):
> model = Post
> fields = ['title', 'content']
> template_name = "post_form.html"
>
> def form_valid(self, form):
> form.instance.author = self.request.user
> return super().form_valid(form)
>
> Thank you in Advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/95facfb3-dedb-476d-957f-80ef2eb72e44%40googlegroups.com
> 
> .
>

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


Getting approval from Admin first before posting a blog in Django

2020-04-21 Thread Ahmed Khairy
Hi all, 

I have made a blog as a project and I have set users to submit posts for 
the blog directly but i want to direct this post to the admin first for 
approval before showing on the website. here is the Post Create View Class. 

class PostCreateView(CreateView):
model = Post
fields = ['title', 'content']
template_name = "post_form.html"

def form_valid(self, form):
form.instance.author = self.request.user
return super().form_valid(form)

Thank you in Advance 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/95facfb3-dedb-476d-957f-80ef2eb72e44%40googlegroups.com.


Re: How to run django server locally, if there are multiple settings file in Django Project. if the repo is cloned from Office work space to local(newly hired as intern) (no requirements.txt)

2020-04-21 Thread ELMER IBAYAN
Hi Chaitan,

After some googling around, i found this article which I believe would help 
you.
https://simpleisbetterthancomplex.com/tips/2017/07/03/django-tip-20-working-with-multiple-settings-modules.html

By the way, i find the project seems interesting from looking at the 
settings. Would you mind sharing the link to the project?..Thanks.

Regards,
Elmer

On Wednesday, 22 April 2020 08:36:08 UTC+10, chaitan wrote:
>
> Hi Django Aspirants,
> I am trying to run localhost:8000 to run the server after the cloning the 
> project. from GitHub. I figured out the process to follow after downloading 
> the project. I can open all files from the sublime text editor and saw 
> multiple settings.py files in the main project. I am a beginner I had only 
> knowledge about how to play with single settings.py file. Other settings.py 
> files are importing common settings file..
> So my question is do need to create another settings file like others to 
> start the server ?? or is there any process to follow.
> Please ignore my English and level of knowledge. Any help is much 
> appreciated
> Database: Postgres
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/30f306fe-beeb-4ecf-9974-de0afce11c65%40googlegroups.com.


Django pdfs

2020-04-21 Thread Perceval Maturure
Hi Django Users

I am developing a Django document management system which will cater for pdf 
file uploads. What is the best resource to use (tutorial) as I want to have the 
pdfs accessible from admin. Can I do this with Django filer

Regards

Perceval

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/B912F6EC-E628-49E8-91AB-8442B25A7E34%40gmail.com.


How to run django server locally, if there are multiple settings file in Django Project. if the repo is cloned from Office work space to local(newly hired as intern) (no requirements.txt)

2020-04-21 Thread chaitan sai
Hi Django Aspirants,
I am trying to run localhost:8000 to run the server after the cloning the 
project. from GitHub. I figured out the process to follow after downloading 
the project. I can open all files from the sublime text editor and saw 
multiple settings.py files in the main project. I am a beginner I had only 
knowledge about how to play with single settings.py file. Other settings.py 
files are importing common settings file..
So my question is do need to create another settings file like others to 
start the server ?? or is there any process to follow.
Please ignore my English and level of knowledge. Any help is much 
appreciated
Database: Postgres

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/df8d6e63-0aec-4f12-899b-789be147f82b%40googlegroups.com.
ADMINS = ()
BRIDGE_VERSION = "3.6.1 Build 202003.2" 

MANAGERS = ADMINS

TIME_ZONE = 'America/Vancouver'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1

USE_I18N = True
USE_L10N = True
USE_TZ = False

# Make this unique, and don't share it with anybody.
SECRET_KEY = '%-dz(1uiiygza@bq0w_!h$)hjykg^+@u!(nizs+a4xejmz))d9'
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

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

ROOT_URLCONF = 'bridge.urls'
WSGI_APPLICATION = 'bridge.wsgi.application'

TEST_RUNNER = ('django.test.runner.DiscoverRunner')

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'bridge',
'block',
'temporal',
'log',
'association',
'client',
'client_wizard',
'employee',
'employee_wizard',
'receivables',
'payables',
'reports',
'import_tool',
'user_accounts',
'carrier',
'commission',
# celery - async tasks.
'django_celery_results',
# ,'test_runner'
'client_portal',
#bootstrap forms for client portal
'edi',
'widget_tweaks', 
'payroll_extract',
)

RQ_QUEUES = {
'default': {
'HOST': 'localhost',
'PORT': 6379,
'DB': 0,
'DEFAULT_TIMEOUT': 360,
},
}

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}

# custom project settings follow...
LOGIN_URL = '/login'
LOGIN_REDIRECT_URL = '/'
AUTH_PROFILE_MODULE = "user_accounts.UserProfile"

COUNTRY_LOCALE = ''

SYSTEM_SALES_TAX = 'BC' #This is the province that the TPA client is based in. This is the fall back tax if nothing is set at the client level.
USE_ASSOCIATION_BANK_ACCOUNTS = False

ADMIN_FEE_ON_ZERO_PREMIUMS = False # overwrite by setting it to True in settings_production_BenefitAdminCompanyName.py if the Admin Fee is charged even if the current premium is zero.

# DEPRECIATED
INVOICE_ORDER = ('LIFE', 'AD', 'WI', 'LTD', 'DEPL', 'EHC', 'DENT', 'EAP', 'MSP', 'OPTLF', 'OSPLIF', 'OPTADD', 'OSPADD', 'VADD', 'CI',)
# END DEPRECIATED

# celery settings
CELERY_RESULT_BACKEND = 'django-db'
CELERY_IMPORTS = ("receivables.async_tasks",'edi.edi', 'payroll_extract.views')

INTERNAL_IPS = ('127.0.0.1')

'''
# RUN_TYPE is a binary flag - it can be any combination of RUN_*
# for ex. to set RUN_DEV and RUN_TEST at the same time use:

RUN_TYPE = RUN_DEV | RUN_TEST

# to check use:

if RUN_TYPE & RUN_DEV == RUN_DEV:
#...
# or
if RUN_TYPE & RUN_DEV:
#...

'''
RUN_DEV = 1
RUN_TEST = 2
RUN_PROD = 4
RUN_TYPE = RUN_PROD


USE_CACHE = True # enable/disable request level caching by @cache annotation
TRACK_CALLS = False # enable/disable function call count by @cache and @track annotations
TEST_CREATE_NEW_DUMP = True
TEST_RESTORE_DB = True
TEST_DB_TMPFS = False
TEST_LOG_FILE=''
TEST_USER = 'auto_test'
TEST_PSWD = 'pass'
LOG_SQL = False
USE_DEBUG_TOOLBAR = False

LEDGER_SWITCH_DATE = 

Collaborators wanted

2020-04-21 Thread John McClain
Hello all,

I have developed an eCommerce marketplace and am looking for collaborators
to help with further iteration work as I would like to concentrate
primarily on promoting the launch and refining the marketing of the beta
release

I have an immediate need to refactor some of the existing models to include
more advanced functionality beyond the MVP models that exist at the moment.

The project is full-stack hosted on Heroku with a private git repo.

Current items in the pipeline needing immediate attention include...

Item 1:
Improve stripe payment by integrating intentions that allow users to
purchase items in USD instead of the default Euro.  Right now a user in GB
sees $1 Product but should because the product name has $1 in it. It is
imperative that the product name incorporates the $1 so the solution isn't
as simple as removing the $1 from the product name. The issue is, when a
user goes through the checkout they are billed €1 instead of $1.

Item 2: Improves on item 1 above... After solving the initial default
currency I need the Stripe payment process improved to allow the user to
select the currency they wish to trade in on the site. The issue is not
simple though because the product names on the site include a currency
denomination but are not dynamic. For example $1 Product and $5 Product.
The current model needs to be improved so that the currency value within
the product name is dynamically placed in the view so that the user
sees the product name in the currency they defined during the registration
process. This means that I need the registration, e-commerce, checkout and
cart models modified to provide this particular solution.

Item 3: I am looking to improve the checkout process so that the user can
define a beneficiary related to the product the user is purchasing. The
site is a fundraising portal and I wish to improve the process so that
items bought can be gifted to others via email or text alerts. This means
at checkout the user can define who they wish to gift the item to by
providing the email address or cell number of the person they wish to gift
the item to. That seems simple enough but the follow on process complicates
the iteration. To defeat attempts to defraud the system I require the user
to authenticate the gift via email or text message. This means I need a
message sent to the user who has gifted the item. In the message is an auth
token used to validate the request. Once the system recognizes the token
has been initiated it will send a message to the intended recipient of the
gift. This could be simplified by asking the user to forward the email they
receive to their guest which would likely improve the number of read
messages as it is anticipated that a high number of unsolicited messages
coming from our system would not be read by the recipient. This can be
discussed between us to determine a final solution.

Item 4: I am looking for a designer to create the sales pages for the site.
The current app is an MVP with little emphasis on design at all. I have a
vision for what the page layout should look like and a list of reference
sites. I am really looking for someone with UX experience and a good feel
for design to take the lead in designing the project.

As this is a start-up compensation cannot be offered. If you are looking
for an opportunity to intern with a project for the experience with the
hopes of converting your efforts into a long term fulltime paid gig then
this may be an opportunity that interests you. I do have a very experienced
python django master at my disposal who will oversee all of your efforts
and can be used to help you familiarize yourself with the project as it
currently exists as well as help you debug your solutions as you go.

Strong command of the English language is preferred.

Please respond here with your interest




-- 
John McClain

Cell: 085-1977-823
Skype: jmcclain0129
Email: jmcclain0...@gmail.com

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


Re: Problem in polls app(ques text will not display)

2020-04-21 Thread LGBS fine soul coders
Try to send your source code

On Tue, 21 Apr 2020, 23:28 Antje Kazimiers,  wrote:

> It sounds like your database is empty. Did you check if there are any
> Question records in your admin view? Under
>
> 127.0.0.1:8000/admin
>
> You should see an entry for Questions and you can create question
> records there.
>
> Here they describe, how to create those records using the django
> management shell:
>
>
> https://docs.djangoproject.com/en/3.0/intro/tutorial02/#playing-with-the-api
>
> I think if you have records in your database, the index view should list
> them.
>
> Antje
>
> On 4/21/20 7:50 PM, Balkrishana Gaur wrote:
> > Dear sir i am new to django. And following each and every step to create
> my first app. Almost done. But at the time of polls question no text will
> display while i use to run 127.0.0.1/8000/polls
> > What can i do
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d6459c76-f83f-b902-19aa-7e4bcdcbacfb%40gmail.com
> .
>

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


Re: Problem in polls app(ques text will not display)

2020-04-21 Thread Antje Kazimiers
It sounds like your database is empty. Did you check if there are any
Question records in your admin view? Under

127.0.0.1:8000/admin

You should see an entry for Questions and you can create question
records there.

Here they describe, how to create those records using the django
management shell:

https://docs.djangoproject.com/en/3.0/intro/tutorial02/#playing-with-the-api

I think if you have records in your database, the index view should list
them.

Antje

On 4/21/20 7:50 PM, Balkrishana Gaur wrote:
> Dear sir i am new to django. And following each and every step to create my 
> first app. Almost done. But at the time of polls question no text will 
> display while i use to run 127.0.0.1/8000/polls
> What can i do
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d6459c76-f83f-b902-19aa-7e4bcdcbacfb%40gmail.com.


Re: CSRF token still needed today?

2020-04-21 Thread David Merrick
Hi if you have an url with stuff?Stuff=Stuff the URL can be changed.
See the link below.
https://portswigger.net/web-security/csrf

On Wed, Apr 22, 2020 at 6:16 AM guettli 
wrote:

> Hi David, could you please explain how cross site forgery requests can
> happen
> with the current default for cookies (SameSite=Lax)?
>
> Am Montag, 20. April 2020 14:43:10 UTC+2 schrieb David Merrick:
>>
>> if you want cross site forgery requests get rid off it
>>
>> On Mon, Apr 20, 2020 at 10:45 PM Andréas Kühne 
>> wrote:
>>
>>> Why is it a problem to have? You add one specific command on all forms -
>>> or you disable it in the view
>>>
>>> What do you want to accomplish by removing it?
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>>
>>> Den sön 19 apr. 2020 kl 22:12 skrev guettli <
>>> guettl...@thomas-guettler.de>:
>>>
 iI look at this page: https://docs.djangoproject.com/en/3.0/ref/csrf/
 ... and then I look at this page:
 https://scotthelme.co.uk/csrf-is-dead/

 Is a CSRF token still needed today?

 All my users use a modern browser.

 It would be very nice if I could get rid of the CSRF token.

 Is there a safe way to avoid CSRF tokens in  my Django project?

 Regards,
   Thomas

 --
 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...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/487c7392-e874-4a1e-a1ff-488ab933ae42%40googlegroups.com
 
 .

>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAK4qSCeO0bkxsGYFc7t-V7%2BZnr965gYAG0oALB0ELtoJjojedg%40mail.gmail.com
>>> 
>>> .
>>>
>>
>>
>> --
>> Dave Merrick
>>
>> TutorInvercargill
>>
>> http://tutorinvercargill.co.nz
>>
>> Daves Web Designs
>>
>> Website http://www.daveswebdesigns.co.nz
>>
>> Email merri...@gmail.com
>>
>> Ph   03 216 2053
>>
>> Cell 027 3089 169
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c33f7b81-2e74-480c-b1fe-acd5f28468ac%40googlegroups.com
> 
> .
>


-- 
Dave Merrick

TutorInvercargill

http://tutorinvercargill.co.nz

Daves Web Designs

Website http://www.daveswebdesigns.co.nz

Email merrick...@gmail.com

Ph   03 216 2053

Cell 027 3089 169

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


Re: CSRF token still needed today?

2020-04-21 Thread Kenny Loveall
The original blog post you posted seems to answer this question. Further it
states "It's going to be a long time until we can consider removing
traditional anti-CSRF mechanisms but adding SameSite on top of those gives
us an incredibly robust defence." Like most things in security, I think
this is an "in addition to" instead of "in place of." At least until all
browsers support it (and that can be guaranteed by some mechanism).

For me personally the cost of keeping/adding them in is really low since
Django handles the recordkeeping and validation. However, if you have a
specific use case where a) you can guarantee everyone is using a
compatible browser and b) CSRF tokens are difficult to implement for some
reason, I think it's relatively reasonable to drop requiring them. This is
also assuming that your site doesn't do anything that makes it a high value
target for attackers (such as financial transactions, etc.). If any of
these are not true, I would personally leave the protections in place.


On Tue, Apr 21, 2020 at 1:19 PM guettli 
wrote:

>
>
> Am Sonntag, 19. April 2020 23:11:59 UTC+2 schrieb Alex Heyden:
>>
>> Django supports samesite on session cookies now, and it's on (set to lax)
>> by default. Whether or not that completely covers your surface risk to CSRF
>> attacks is a somewhat different question.
>>
>>
> AFAIK they can not happen. But I am not an expert in this area.
> Does somebody know if CSRF attacks can happen with SameSite=Lax cookies?
>
>>
>>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/84e032ab-f78b-41f8-879f-38e623269910%40googlegroups.com
> 
> .
>

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


Problem in polls app(ques text will not display)

2020-04-21 Thread Balkrishana Gaur
Dear sir i am new to django. And following each and every step to create my 
first app. Almost done. But at the time of polls question no text will display 
while i use to run 127.0.0.1/8000/polls
What can i do

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1013f35a-4f2f-4dab-955e-908086c21d14%40googlegroups.com.


Re: CSRF token still needed today?

2020-04-21 Thread guettli


Am Sonntag, 19. April 2020 23:11:59 UTC+2 schrieb Alex Heyden:
>
> Django supports samesite on session cookies now, and it's on (set to lax) 
> by default. Whether or not that completely covers your surface risk to CSRF 
> attacks is a somewhat different question.
>
>
AFAIK they can not happen. But I am not an expert in this area.
Does somebody know if CSRF attacks can happen with SameSite=Lax cookies?

>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/84e032ab-f78b-41f8-879f-38e623269910%40googlegroups.com.


Re: CSRF token still needed today?

2020-04-21 Thread guettli
Hi Andreas. I try to avoid doing things which are not needed. Some call
doing things which are not needed "useless", some even call it "stupid", 
but that's rude.

Am Montag, 20. April 2020 12:46:14 UTC+2 schrieb Andréas Kühne:
>
> Why is it a problem to have? You add one specific command on all forms - 
> or you disable it in the view 
>
> What do you want to accomplish by removing it?
>
> Regards,
>
> Andréas
>
>
> Den sön 19 apr. 2020 kl 22:12 skrev guettli  >:
>
>> iI look at this page: https://docs.djangoproject.com/en/3.0/ref/csrf/
>> ... and then I look at this page: https://scotthelme.co.uk/csrf-is-dead/
>>
>> Is a CSRF token still needed today?
>>
>> All my users use a modern browser.
>>
>> It would be very nice if I could get rid of the CSRF token.
>>
>> Is there a safe way to avoid CSRF tokens in  my Django project?
>>
>> Regards,
>>   Thomas
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/487c7392-e874-4a1e-a1ff-488ab933ae42%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6e53f168-9b32-4c73-85ab-13362d03e0e4%40googlegroups.com.


Re: CSRF token still needed today?

2020-04-21 Thread guettli
Hi David, could you please explain how cross site forgery requests can 
happen
with the current default for cookies (SameSite=Lax)? 

Am Montag, 20. April 2020 14:43:10 UTC+2 schrieb David Merrick:
>
> if you want cross site forgery requests get rid off it
>
> On Mon, Apr 20, 2020 at 10:45 PM Andréas Kühne  > wrote:
>
>> Why is it a problem to have? You add one specific command on all forms - 
>> or you disable it in the view 
>>
>> What do you want to accomplish by removing it?
>>
>> Regards,
>>
>> Andréas
>>
>>
>> Den sön 19 apr. 2020 kl 22:12 skrev guettli > >:
>>
>>> iI look at this page: https://docs.djangoproject.com/en/3.0/ref/csrf/
>>> ... and then I look at this page: https://scotthelme.co.uk/csrf-is-dead/
>>>
>>> Is a CSRF token still needed today?
>>>
>>> All my users use a modern browser.
>>>
>>> It would be very nice if I could get rid of the CSRF token.
>>>
>>> Is there a safe way to avoid CSRF tokens in  my Django project?
>>>
>>> Regards,
>>>   Thomas
>>>
>>> -- 
>>> 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...@googlegroups.com .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/487c7392-e874-4a1e-a1ff-488ab933ae42%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAK4qSCeO0bkxsGYFc7t-V7%2BZnr965gYAG0oALB0ELtoJjojedg%40mail.gmail.com
>>  
>> 
>> .
>>
>
>
> -- 
> Dave Merrick
>
> TutorInvercargill
>
> http://tutorinvercargill.co.nz
>
> Daves Web Designs
>
> Website http://www.daveswebdesigns.co.nz
>
> Email merri...@gmail.com 
>
> Ph   03 216 2053
>
> Cell 027 3089 169
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c33f7b81-2e74-480c-b1fe-acd5f28468ac%40googlegroups.com.


Re: Channels/Daphne offloading SSL Certs to AWS ELB fails to establish socket

2020-04-21 Thread Andrew C.
I’m about to create a PR (or not, not sure) with an AWS ALB setup for
cookiecutter django. The gist of it really is that there’s an article my
msaizar that has a good nginx configuration setup. Remove traefik and add
nginx. Your target group in AWS should have all machines registered on port
80 and you should be good to go. There’s a little more to what I’ve said,
but that’s the gist of it.

On Tue, Apr 21, 2020 at 12:25 PM Shaheed Haque 
wrote:

> On Tue, 21 Apr 2020 at 00:30, Tim Nelson  wrote:
>
>> Well if you want the clients IP logged or need to do something with it on
>> the request:
>>
>>set_real_ip_from 0.0.0.0/0;
>>real_ip_header X-Forwarded-For;
>>real_ip_recursive on;
>>
>
> Thanks for the tip. I'll have to look into those in due course.
>
> Shaheed
>
>
>>
>> On Mon, Apr 20, 2020 at 5:55 PM Shaheed Haque 
>> wrote:
>>
>>>
>>>
>>> On Mon, 20 Apr 2020 at 21:54, Filbert  wrote:
>>>
 *Answering my own question.AWS classic ELBs never worked properly
 with websockets. Need to convert them to ALBs.*

>>>
>>> Thanks for closing the loop; this is quite likely to be in my future.
>>> Did you need any nginx config changes?
>>>
>>> Shaheed
>>>
>>> On Tuesday, April 14, 2020 at 5:37:54 PM UTC-4, Filbert wrote:
>
> Using AWS ELB, I was able to serve HTTP (via uwsgi) and websockets
> through Nginx with Nginx handling the SSL certs.
>
> Once I tried to offloading SSL certs to the ELB so I could capture
> X-Forwarded-For, websockets fail to route/upgrade to Daphne and I get "Not
> Found: /ws/" in uwsgi's logs.
>
> Here is the relevant (working) piece of Nginx .conf file using TCP/443
> pass thru from the ELB:
>
> location /ws {
> proxy_pass http://unix:/opt/toogo/run/r117.0.4.3720.ws;
>  #Obviously daphne is listening here
> proxy_set_header Upgrade $http_upgrade;
> proxy_set_header Connection "upgrade";
> proxy_http_version 1.1;
> proxy_set_header X-Forwarded-For
> $proxy_add_x_forwarded_for;
> proxy_set_header Host $host;
> }
>
> What change is required if I offload the SSL certs to the ELB and
> introduce X-Forwarded-for?
>
 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/305b31ae-ff69-425a-a173-645c55ba07a1%40googlegroups.com
 
 .

>>>
>>> --
>>> 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/iNoIPxDgv90/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAHAc2jf1KNYe-p2JM-XLD2q8HpC_29oNrJ24KkyjVFRj%2BpPo%2BQ%40mail.gmail.com
>>> 
>>> .
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAK09zoq2pD6MsMfXA6y_rj4CUvcxgrT-w11xYCSvaUjdm8TD_Q%40mail.gmail.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHAc2jcGo1YFJhJNf%2Bt1BfhD60dG%3DwUaamU5M9Wg_ksAm4HWaQ%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Re: Channels/Daphne offloading SSL Certs to AWS ELB fails to establish socket

2020-04-21 Thread Shaheed Haque
On Tue, 21 Apr 2020 at 00:30, Tim Nelson  wrote:

> Well if you want the clients IP logged or need to do something with it on
> the request:
>
>set_real_ip_from 0.0.0.0/0;
>real_ip_header X-Forwarded-For;
>real_ip_recursive on;
>

Thanks for the tip. I'll have to look into those in due course.

Shaheed


>
> On Mon, Apr 20, 2020 at 5:55 PM Shaheed Haque 
> wrote:
>
>>
>>
>> On Mon, 20 Apr 2020 at 21:54, Filbert  wrote:
>>
>>> *Answering my own question.AWS classic ELBs never worked properly
>>> with websockets. Need to convert them to ALBs.*
>>>
>>
>> Thanks for closing the loop; this is quite likely to be in my future. Did
>> you need any nginx config changes?
>>
>> Shaheed
>>
>> On Tuesday, April 14, 2020 at 5:37:54 PM UTC-4, Filbert wrote:

 Using AWS ELB, I was able to serve HTTP (via uwsgi) and websockets
 through Nginx with Nginx handling the SSL certs.

 Once I tried to offloading SSL certs to the ELB so I could capture
 X-Forwarded-For, websockets fail to route/upgrade to Daphne and I get "Not
 Found: /ws/" in uwsgi's logs.

 Here is the relevant (working) piece of Nginx .conf file using TCP/443
 pass thru from the ELB:

 location /ws {
 proxy_pass http://unix:/opt/toogo/run/r117.0.4.3720.ws;
  #Obviously daphne is listening here
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection "upgrade";
 proxy_http_version 1.1;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header Host $host;
 }

 What change is required if I offload the SSL certs to the ELB and
 introduce X-Forwarded-for?

>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/305b31ae-ff69-425a-a173-645c55ba07a1%40googlegroups.com
>>> 
>>> .
>>>
>>
>> --
>> 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/iNoIPxDgv90/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAHAc2jf1KNYe-p2JM-XLD2q8HpC_29oNrJ24KkyjVFRj%2BpPo%2BQ%40mail.gmail.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAK09zoq2pD6MsMfXA6y_rj4CUvcxgrT-w11xYCSvaUjdm8TD_Q%40mail.gmail.com
> 
> .
>

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


RE: Problema con instalar django 3.0.5

2020-04-21 Thread german salcedo aragon
Gracias Sr. Daniel.

Enviado desde Correo para 
Windows 10


De: django-users@googlegroups.com  en nombre de 
Ing.Daniel Bojorge 
Enviado: Monday, April 20, 2020 12:35:17 PM
Para: django-users@googlegroups.com 
Asunto: Re: Problema con instalar django 3.0.5

Te sugiero crear un entorno virtual.

Ejecuta pip freeze para ver si no tienes problemas con la instalación de python.


Dios L@s Bendiga

Saludos,




[http://d3mod6n032mdiz.cloudfront.net/thumb2/d/a/n/daniel.bojorge/daniel.bojorge-105x70.jpg]

daniel.bojorge
about.me/daniel.bojorge


[snake]Curso Desarrollo Web con Python usando Django 2.2 Para Principiantes con 
Descuento 95%   [snake]
WebService RestFul API con Python usando Django 
RestFrameWork
Fácil Replicación de Cualquier Base de Datos y/o Sistema 
Operativo
Programación en Capas (Web y Escritorio)
Mi Blog
Nicaragua

"Si ustedes permanecen unidos a mí, y si permanecen fieles a mis enseñanzas, 
pidan lo que quieran y se les dará.
(Juan 15:7 DHH)
Bendito el varón que se fía en el SEÑOR, y cuya confianza es el SEÑOR.
(Jeremías 17:7 RV2000)




El lun., 20 abr. 2020 a las 6:42, german salcedo aragon 
(mailto:salcedo_ger...@hotmail.com>>) escribió:
Buenos días , no puedo instalar django 3.0.5 me sale este error, por favor 
ayuda. Gracias
C:\WINDOWS\system32>pip install django==3.0.5
Fatal error in launcher: Unable to create process using 
'"c:\python38\python.exe"  "C:\Python38\Scripts\pip.exe" install 
django==3.0.5': El sistema no puede encontrar el archivo especificado.


--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/14ae6cf0-f5b6-4f0c-80c2-6f1fefd3b151%40googlegroups.com.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/BN8PR04MB63858481BB3A9E34A59147B2F1D50%40BN8PR04MB6385.namprd04.prod.outlook.com.


Initialize a formset with manytomany relationship

2020-04-21 Thread rahul sharma
I have two models connected by manytomany relationship and I am trying to 
use `formset` to create a dynamic form. I am able to save the form but the 
problem arise when I am trying to edit the saved instance, I don't know how 
to properly pass the instance to the formset such that it shows the 
instance data in form for editing

Here are the details:

Models.py

class Player(models.Model):
pname = models.CharField(max_length=50)
hscore = models.IntegerField()
age = models.IntegerField()
def __str__(self):
   return self.pname

class Team(models.Model):
tname = models.CharField(max_length=100)
player= models.ManyToManyField(Player)
def __str__(self):
return self.tname

Forms.py

class PlayerForm(forms.ModelForm):

class Meta:
model = Player
fields = '__all__'

PlayerFormset= formset_factory(PlayerForm)

class TeamForm(forms.ModelForm):

   player= PlayerFormset()
   class Meta:
   model = Team
   fields = '__all__'
   exclude = ["player"]

Views.py


def team(request):

   if request.POST:
form = TeamForm(request.POST)
form.player_instances = PlayerFormset(request.POST)
if form.is_valid():
team= Team()
team.tname= form.cleaned_data['tname']
team.save()

if form.player_instances.cleaned_data is not None:
for item in form.player_instances.cleaned_data:
player = Player()
player.pname= item['pname']
player.hscore= item['hscore']
player.age= item['age']
player.save()
team.player.add(player)
team.save()

   else:
form = TeamForm()
return render(request, 'packsapp/employee/new.html', 
{'form':form})


def updateTeam(request,pk):

team = Team.objects.get(id=pk)
form = TeamForm(instance=team)

// something here to initialize the formset ??

if request.method == "POST":
form = TeamForm(request.POST, instance=team)
if form.is_valid():
form.save()

context = {'form': form}
return render(request, 'packsapp/employee/new.html', context)

Html




gffdfdf

https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css;>
https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js";>

https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js";>







{% csrf_token %}
 Team
{% for field in form %}
{{ field.errors }}
{{ field.label_tag }}  {{ field }}
{% endfor %}
{{ form.player.management_form }}

 Product Instance(s)



player name
highest score
age



{% for player in form.player %}



{{ player.pname }}
{{ player.hscore }}
{{ player.age }}





{% endfor %}

save





var i = 1;
$("#input_add").click(function () {
$("tbody tr:first").clone().find(".data_input").each(function 
() {
if ($(this).attr('class') == 'tr_clone_add btn data_input') 
{
$(this).attr({
'id': function (_, id) {
return "remove_button"
},
'name': function (_, name) {
return "name_remove" + i
},
'value': 'Remove'
}).on("click", function () {
var a = $(this).parent();
var b = a.parent();
i = i - 1
$('#id_form-TOTAL_FORMS').val(i);
b.remove();

$('.player-instances tr').each(function (index, 
value) {
$(this).find('.data_input').each(function () {
$(this).attr({
'id': function (_, id) {
console.log("id", id)
var idData = id;
var splitV = 
String(idData).split('-');
var fData = splitV[0];
var 

RelatedObjectDoesNotExist: User has no profile, Django error || unable to login after signup

2020-04-21 Thread Anonymous Patel
https://youtu.be/QDk3rI_H3ks

here is the video for the error from this awesome community of developers, 
@errormania
 they provide solution all programming errors. they reply in a day or come 
up with a solution to your errors.
they help as much as they can


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9654bf6b-361c-4a01-b9ec-213df444fde2%40googlegroups.com.


errormania a developers community

2020-04-21 Thread Anonymous Patel
https://www.youtube.com/channel/UCxxPBCkto7W8MX6TMctgLqw

join this open community of developers, they help us to solve programming 
errors you can directly ask them in their telegram channel they comeup with 
solution video in a day and reply urgently on telegram.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2f73581f-f4e5-4ad4-b927-7c5a81db6bc4%40googlegroups.com.


Expecting JSON object instead of JSON Array

2020-04-21 Thread Salah Abdul Gafoor
In my django application with database engine djongo, I'm trying to return 
a JSON response by retrieving from my database. But, I'm receiving JSON 
array instead of JSON object. Currently, there is only one record in my 
database. Please see the code below.

model.py

class bloodDonors(models.Model):
location=models.CharField(max_length=20)
name=models.CharField(max_length=20)
phone=models.IntegerField()
address=models.TextField()
bloodGroup=models.CharField(max_length=5)
type=models.CharField(max_length=20)
def __str__(self):
return self.name

views.py

class bloodDonersView(viewsets.ModelViewSet):
queryset = bloodDonors.objects.all()
serializer_class = bloodDonorsSerializer


JSON Reponse I got:

[
{
"id": 3,
"location": "Delhi",
"name": "Tony",
"phone": 888,
"address": "South street",
"bloodGroup": "B+",
"type": "blood-donation"
}

]


But, actually I needed the response as given below:

{
"id": 3,
"location": "Delhi",
"name": "Tony",
"phone": 888,
"address": "South street",
"bloodGroup": "B+",
"type": "blood-donation"
}


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/778b2423-78d5-4b61-b9b9-db7663188d1a%40googlegroups.com.


Expecting JSON object instead of JSON Array

2020-04-21 Thread Salah Abdul Gafoor
In my django application with database engine djongo, I'm trying to return 
a JSON response by retrieving from my database. But, I'm receiving JSON 
array instead of JSON object. Currently, there is only one record in my 
database. Please see the code below.

model.py

class bloodDonors(models.Model):
location=models.CharField(max_length=20)
name=models.CharField(max_length=20)
phone=models.IntegerField()
address=models.TextField()
bloodGroup=models.CharField(max_length=5)
type=models.CharField(max_length=20)
def __str__(self):
return self.name


views.py

class bloodDonersView(viewsets.ModelViewSet):
queryset = bloodDonors.objects.all()
serializer_class = bloodDonorsSerializer


JSON Reponse:

[
{
"id": 3,
"location": "Delhi",
"name": "Tony",
"phone": 888,
"address": "South street",
"bloodGroup": "B+",
"type": "blood-donation"
}
]

But, actually I needed the response as given below:

{
"id": 3,
"location": "Delhi",
"name": "Tony",
"phone": 888,
"address": "South street",
"bloodGroup": "B+",
"type": "blood-donation"
}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5656271c-fe21-4933-ad3f-9dc7505a56c1%40googlegroups.com.


Re: Reg: Django signal not working

2020-04-21 Thread sahil khan
Hello i am from google group plz see this video chennel and solve
your problem
https://youtu.be/QDk3rI_H3ks like comment and subscribe and share so that
another people get help this channel

On Mon, 20 Apr 2020, 4:28 pm Aditya Singh, 
wrote:

> What's the original issue please, seems like you picked things up with
> someone till this email.
> Regards,
> Aditya
>
> On Mon, Apr 20, 2020, 3:11 PM 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
>> -+c Hello Jorge,
>>
>> After doing some research, I realized that the signal which is saving the
>> user profile should have
>>
>> "instance.signup.save()" , as the name of the custom model is signup.
>> This time I still got the error .However,  I could create the new user and
>> login to the website. However, when I look into the admin panel, I still
>> could't see the "contact" field getting saved after the user is registered
>> successfully.
>>
>> Therefore the main purpose of creating the custom User model still
>> failing.
>>
>> Below are the code snippet, and screenshot from my admin panel.
>>
>> Models.py
>> -
>>
>> from django.db import models
>> from django.contrib.auth.models import User
>> from django.db.models.signals import post_save
>> from django.dispatch import receiver
>>
>>
>> class SignUp(models.Model):
>> user = models.OneToOneField(User, on_delete=models.CASCADE)
>> Contact = models.CharField(max_length=500, blank=True)
>>
>> @receiver(post_save, sender=User)
>> def create_user_profile(sender, instance, created, **kwargs):
>> if created:
>> SignUp.objects.create(user=instance)
>>
>> @receiver(post_save, sender=User)
>> def save_user_profile(sender, instance, **kwargs):
>> save2 = instance.signup.save()
>> print(save2)
>>
>>
>> To debug the issue, I used the print statement to see the output of
>> "instance.signup.save()". So, after submitting the form, I checked the
>> "runserver" console. The output was "None". So, something doesn't seems to
>> be right.
>>
>> forms.py
>> --
>>
>> from django.contrib.auth.forms import UserCreationForm
>> from django.contrib.auth.models import User
>> from django import forms
>> from .models import SignUp
>>
>>
>> class SignUpForm(UserCreationForm):
>> email = forms.EmailField()
>> first_name = forms.CharField(max_length=100)
>> last_name = forms.CharField(max_length=100)
>>
>> class Meta:
>> model = User
>> fields = ('username', 'first_name', 'last_name', 'email', 
>> 'password1', 'password2')
>>
>>
>> class CustomSignUpPage(forms.ModelForm):
>> Contact = forms.CharField(max_length=10)
>>
>> class Meta:
>> model = SignUp
>> fields = ('Contact', )
>>
>>
>> views.py
>> -
>>
>> def register_user(request):
>> if request.method == "POST":
>> form = SignUpForm(request.POST)
>> cus_form = CustomSignUpPage(request.POST)
>> if form.is_valid() and cus_form.is_valid():
>> save1 = form.save()
>> save1.refresh_from_db()
>> cus_form = CustomSignUpPage(request.POST, 
>> instance=request.save1.signup.contact)
>> cus_form.full_clean()
>> cus_form.save()
>> username = form.cleaned_data['username']
>> password = form.cleaned_data['password1']
>> user = authenticate(request, username=username, 
>> password=password)
>> login(request, user)
>> messages.success(request, f'Registration successful')
>> return redirect('home')
>> else:
>> messages.error(request, f'Please correct the error below.')
>> else:
>> form = SignUpForm()
>> cus_form = CustomSignUpPage()
>>
>> return render(request, 'authenticate\\register.html', context={'form': 
>> form, 'cus_form': cus_form})
>>
>> Screenshot from the admin panel:
>>
>> [image: Inline image]
>> Please suggest. If you are comfortable we can go on a web meeting where I
>> can share my screen and we can work on it.
>>
>> Regards,
>> Amitesh
>>
>> Sent from Yahoo Mail on Android
>> 
>>
>> On Sun, 19 Apr 2020 at 19:42, Jorge Gimeno
>>  wrote:
>> Amitesh,
>>
>> Where is User.profile defined?
>>
>> -Jorge
>>
>> On 4/18/20, Saurabh Ranjan Singh  wrote:
>> > I am having the same issue. Please fix it.
>> >
>> > On Friday, 17 April 2020 22:47:40 UTC+5:30, Amitesh Sahay wrote:
>> >>
>> >> Hi,
>> >>
>> >> I am creating a Django signup form through "User" model and
>> >> "UserCreationForm" and customized the User model to accommodate single
>> >> user
>> >> defined field "contact".
>> >>
>> >> However, the signal that I have written seems not to be working.
>> >> Whenever, I am filling the form, I am getting below error:
>> >>
>> >> AttributeError at /auth/register/
>> >> 

Re: stack

2020-04-21 Thread Anonymous Patel
https://www.youtube.com/channel/UCxxPBCkto7W8MX6TMctgLqw

watch this channel if you get some error errormania is open developers 
community you can join them and ask your doubts while development.
and even upload your own video. if you face error and solve it than help 
others to solve solve it

On Monday, 20 April 2020 21:44:00 UTC+5:30, tejasri mamidi wrote:
>
> Hiii everyone ,,iam new to django ,can anyone suggest path to grow django 
> skis, 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/506b07ce-ffce-464f-be60-c01fee274635%40googlegroups.com.


Notifications in DRF

2020-04-21 Thread shreehari Vaasistha L
if anyone has implemented FCM in django rest framework 
using https://github.com/xtrinch/fcm-django or anyother packages, please 
share it with me. 
need to send notifications to devices.
Thanks in Advance !

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/08cda12c-51d4-4dc2-8448-9f18dd6b3c9b%40googlegroups.com.


RE: Re: stack

2020-04-21 Thread Tejasri Mamidi
Sure,thank Sent from Mail for Windows 10 From: Rok KlancarSent: 20 April 2020 21:57To: Django usersSubject: Re: stack Do the official Django tutorial-- You received this message because you are subscribed to the Google Groups "Django users" group.To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d024215b-ac1e-4323-b6de-07e26152e6bd%40googlegroups.com. 

	

		Virus-free. www.avg.com
		
	
 



-- 
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5e9ed0a5.1c69fb81.db0ca.5dac%40mx.google.com.


Re: Reg: Django signal not working

2020-04-21 Thread Anonymous Patel
https://youtu.be/QDk3rI_H3ks
Checkout this video from errormania
They explained about signal.
If that doesn't help leave comment there they provide you with a video in a
day

Raj Patel

On Tue, 21 Apr, 2020, 9:34 am 'Amitesh Sahay' via Django users, <
django-users@googlegroups.com> wrote:

> Hello Aditya,
>
> I am using Django's "User" and "UserCreationForm" to create registration
> and login page and it's backend logic. So far so good. I could add the
> default fields to my registration page and it's working as per required.
>
> However, I want to add a custom field "contact" as it does not come
> in-built. But no matter what I am not able to do it.
>
> I have already shared the code in my previous email. Please go through it
> and let me know if you can help me somehow.
>
> Thank you
>
> Amitesh
>
> Sent from Yahoo Mail on Android
> 
>
> On Mon, 20 Apr 2020 at 16:28, Aditya Singh
>  wrote:
> What's the original issue please, seems like you picked things up with
> someone till this email.
> Regards,
> Aditya
>
> On Mon, Apr 20, 2020, 3:11 PM 'Amitesh Sahay' via Django users <
> django-users@googlegroups.com> wrote:
>
> -+c Hello Jorge,
>
> After doing some research, I realized that the signal which is saving the
> user profile should have
>
> "instance.signup.save()" , as the name of the custom model is signup. This
> time I still got the error .However,  I could create the new user and login
> to the website. However, when I look into the admin panel, I still could't
> see the "contact" field getting saved after the user is registered
> successfully.
>
> Therefore the main purpose of creating the custom User model still
> failing.
>
> Below are the code snippet, and screenshot from my admin panel.
>
> Models.py
> -
>
> from django.db import models
> from django.contrib.auth.models import User
> from django.db.models.signals import post_save
> from django.dispatch import receiver
>
>
> class SignUp(models.Model):
> user = models.OneToOneField(User, on_delete=models.CASCADE)
> Contact = models.CharField(max_length=500, blank=True)
>
> @receiver(post_save, sender=User)
> def create_user_profile(sender, instance, created, **kwargs):
> if created:
> SignUp.objects.create(user=instance)
>
> @receiver(post_save, sender=User)
> def save_user_profile(sender, instance, **kwargs):
> save2 = instance.signup.save()
> print(save2)
>
>
> To debug the issue, I used the print statement to see the output of
> "instance.signup.save()". So, after submitting the form, I checked the
> "runserver" console. The output was "None". So, something doesn't seems to
> be right.
>
> forms.py
> --
>
> from django.contrib.auth.forms import UserCreationForm
> from django.contrib.auth.models import User
> from django import forms
> from .models import SignUp
>
>
> class SignUpForm(UserCreationForm):
> email = forms.EmailField()
> first_name = forms.CharField(max_length=100)
> last_name = forms.CharField(max_length=100)
>
> class Meta:
> model = User
> fields = ('username', 'first_name', 'last_name', 'email', 
> 'password1', 'password2')
>
>
> class CustomSignUpPage(forms.ModelForm):
> Contact = forms.CharField(max_length=10)
>
> class Meta:
> model = SignUp
> fields = ('Contact', )
>
>
> views.py
> -
>
> def register_user(request):
> if request.method == "POST":
> form = SignUpForm(request.POST)
> cus_form = CustomSignUpPage(request.POST)
> if form.is_valid() and cus_form.is_valid():
> save1 = form.save()
> save1.refresh_from_db()
> cus_form = CustomSignUpPage(request.POST, 
> instance=request.save1.signup.contact)
> cus_form.full_clean()
> cus_form.save()
> username = form.cleaned_data['username']
> password = form.cleaned_data['password1']
> user = authenticate(request, username=username, password=password)
> login(request, user)
> messages.success(request, f'Registration successful')
> return redirect('home')
> else:
> messages.error(request, f'Please correct the error below.')
> else:
> form = SignUpForm()
> cus_form = CustomSignUpPage()
>
> return render(request, 'authenticate\\register.html', context={'form': 
> form, 'cus_form': cus_form})
>
> Screenshot from the admin panel:
>
> [image: Inline image]
> Please suggest. If you are comfortable we can go on a web meeting where I
> can share my screen and we can work on it.
>
> Regards,
> Amitesh
>
> Sent from Yahoo Mail on Android
> 

Watch "RelatedObjectDoesNotExist: User has no profile, Django error || unable to login after signup" on YouTube

2020-04-21 Thread Anonymous Patel
https://youtu.be/QDk3rI_H3ks

Raj Patel

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


DRF instance page sends GET instead of DELETE with both Firefox and Chromium

2020-04-21 Thread Olivier
Hello,

I'm discovering DRF.
When I type http://foo/api/friends/3/ in my browser, I'm seeing content 
describing Friend 2 or Friend 3 instance.

When I type curl -X DELETE http://foo/api/friends/2/ a DELETE request is 
sent to my Django app and everything works OK as Friend 2 is removed from 
database.

When looking at Friend 3 instance, I can see a DELETE and a Delete buttons.
When I click over DELETE then Delete buttons, a GET request is sent over to 
my Django instance.
I would expect a DELETE request to be sent.

I tried this with both Firefox 68 ESR and Chromium 57 and with both a GET 
request is sent instead of a DELETE one.
I also tried with PATCH button: a GET request is also sent.

Looking at this HTTP request capture, I do not see any evidence reflecting 
a DELETE or PATCH intent.
Looking at page HTML source code, I can see that buttons are mapped to GET 
request with an intriguing "data-method" set to DELETE or PATCH.


1. Is it possible to have these browsers sending expected DELETE or PATCH 
requests ?
Is it something that can be configured by Django ? Within browsers 
themselves ?

2. Is it possible to have these browsers still sending GET request but have 
my Django app mapping these requests to the DELETE/PATCH/whatever
methods these requests are supposed to be mapped to ?


Best regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8e6de397-eb9a-4d91-9117-c4d21279ed04%40googlegroups.com.