Wednesday, October 2, 2019

Re: Entire Application in Django shuts down with single error

Hi,

You shouldn't use runserver in production - that's not what it's for. So first read how to deploy django in production. When in production, you don't deploy code that doesn't work - so that means that you won't get this issue.

You shouldn't work on live working websites - that's not how you do it professionally. You should work locally on your machine and then update the production server WHEN everything works. Allowing someone to work live on a production server is a major issue. Like you said, you will probably crash the server when doing that. 

Django development is very friendly - as long as you work in the correct way:

1. Work on a development machine - update the changes and run your tests to make sure that everything works as expected.
2. Create a package for the website somehow (git archive, create a docker image or something like that).
2a. Test your code on a staging server.
3. Update your production server with the working code.
4. Restart the application server on the production server.

If you follow that mindset it won't be a problem when working  - and this is basically the way you should be working REGARDLESS of what framework you are using. Otherwise you will get changes done in several places - you won't know what is the latest code and so on.

The list above is a minimal list - you could of course expand on that as well.


Regards,

Andréas


Den tis 1 okt. 2019 kl 13:13 skrev Amit Sharma <lettertoamit@gmail.com>:
I am new to Python and django , I worked on C# and php as developer earlier. My problem here is Entire Application in Django shuts down with single error.

for example i start my website with "python3 manage.py runserver 0.0.0.0:8000" example:-- i have two pages home and register
1) if i make error in register page code(register.py) , It shuts down home page too. Is there a way to prevent that as in php and C# in both one page do not effect other.
2) how to work in django with team one errors full team hangs.

3) How to work with live working websites things may become too risky.

4) can we make django development as friendly as C#, PHP  ......... and other programming language

also i am not able to find article related to this. kindly 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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7d81706a-2f84-4f55-a25c-1bae726a8879%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCdqTaedug%2BdjQ%2BLYb7oiKWA9%2BCbuu2QggFdm8CwuU6JCg%40mail.gmail.com.

Re: AttributeError

You have a typo in your details view:

question=Question.object.get(

Should be:

question=Question.objects.get(

Cheers,
Daniel

Am 02.10.2019 um 06:38 schrieb Jorge Gimeno <jlgimeno71@gmail.com>:




On Tue, Oct 1, 2019 at 9:24 PM yasar arafath Kajamydeen <yasarnow@gmail.com> wrote:
Hi ,

While try to execute  it showing AttributeError, Can some one help me on this.


My views.py



from django.shortcuts import render
from django.http import Http404
from django.http import HttpResponse
from .models import Question


def index(request):
latest_question_list=Question.objects.order_by('pub_date')[:3]
context={'latest_question_list':latest_question_list}
return render(request,'polls/index.html',context)

def detail(request, question_id):
try:
question=Question.object.get(pk=question_id)
except Question.DoesNotExist:
raise Http404("Question does not exist")
return render(request, 'polls/detail.html', {'question':question})


def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResponse(response%question_id)


def vote(request, question_id):
return HttpResponse("You're voting on question %s."%question_id)






My detail.html


  {{question}}








My polls/urls.py



from django.urls import path

from . import views

urlpatterns = [
# ex: /polls/
path('', views.index, name='index'),
# ex: /polls/5/
path('<int:question_id>/', views.detail, name='detail'),
# ex: /polls/5/results/
path('<int:question_id>/results/', views.results, name='results'),
# ex: /polls/5/vote/
path('<int:question_id>/vote/', views.vote, name='vote'),

]

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9918df61-41fd-40bd-8ca3-79ee3be12ec3%40googlegroups.com.

Can you please post the traceback?  Copy and paste, please. Without that we won't know where the exception is raised.

-Jorge

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANfN%3DK_EVDfucXrk490XeumWyf2_u0QOfitfbQ0jFQOJyKkAjg%40mail.gmail.com.

Tuesday, October 1, 2019

Re: Request to provide the details of how to integrate django app with selenium chrome web driver

Still not clear on what is the automation task. From your original questions:

1.Under one tab ,provide a button name "ApplyGSP"
2.click on "ApplyGSP" button should open a form ,which required below input from the user.

   a)model_no b)model_name c)os_version d)requested_time e)user f)from_sas_url g) to_sas_url etc.

3.once the user submitted the FORM with all the fields from step2, your app should open a browser with the user specified URL from f)from_sas_url field in step2.
4.Perform few click operations using selenium webdriver.
   5.copy the list of records from f) to g)

These indicate that you want to perform a particular task using selenium.

What is the other task you are trying to run simultaneously for which you want to run the selenium job using celery.delay()?

My full understanding is: 
  • You will develop a Django application that meets the above requirements
  • That Django application will certainly be in running state (only then you will be able to perform visual automation on it)
  • You will then run a selenium job on the above running Django application.
  • Here, your Django app is running on a different process and you are triggering selenium job separately.
  • If on the other hand, the only reason you want to run a Django app is to do the selenium task and then shutdown the Django app altogether, you can put the whole thing in a single bash script which essentially:
    • Starts your Django application using gunicorn or direct call to runserver or whichever way you want it to run
    • Checks that the Django application is up and running
    • Triggers the Selenium flow
    • If selenium flow returns exit 0 - gets out and shuts down the Django application
Is the above correct expectation correct?

--
Regards
Deep L Sukhwani


On Tue, 1 Oct 2019 at 23:08, Dilipkumar Noone <n.dilipk@gmail.com> wrote:
Hi,

If i use selenium webdriver regular way in my django app, will it not cause time consuming to perform the automation task on chrome webdriver ?
So to save the time , can i launch browser and perform automation task using celery delay() method.

Regards,
N.Dilip Kumar.

On Tuesday, October 1, 2019 at 4:13:51 AM UTC+5:30, Deep Sukhwani wrote:
What exactly do you want to use celery for?

Using selenium webdriver the regular way should suffice here.
Regarding copying from one field and pasting into another, you might be able to work with .get_text() method in selenium to read text from one field, store it in a variable and then .send_keys() to write that text into another field.

Note: This is a good question for selenium community and you should consider posting it there or on Stack overflow with selenium webdriver tag

On Mon, Sep 30, 2019, 21:29 Dilipkumar Noone <n.d...@gmail.com> wrote:


On Monday, September 30, 2019 at 9:22:16 PM UTC+5:30, Dilipkumar Noone wrote:
I am new to Django.

I  have a requirement to develop a django application with the requirement as stated below:

1.Under one tab ,provide a button name "ApplyGSP"
2.click on "ApplyGSP" button should open a form ,which required below input from the user.

   a)model_no b)model_name c)os_version d)requested_time e)user f)from_sas_url g) to_sas_url etc.

3.once the user submitted the FORM with all the fields from step2, your app should open a browser with the user specified URL from f)from_sas_url field in step2.
4.Perform few click operations using selenium webdriver.
   5.copy the list of records from f) to g)

Please provide your suggestion how to perform this task in a better way.

can i use celery application and launch the browser and perform the click operations using selenium webdriver ?
Is there any better way please suggest me.

Regards,
N.Dilip Kumar.   


 

--
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/87eaa9b9-eccb-4f7c-87b3-3a6a2d6ee8b7%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3292dd2d-b5b7-4b65-8d67-8b3276e4f94f%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEMqiPezLR9s%3DXVpUk-D-Bu7_O57_bR5mB7NmgY7Trw-iCwq9g%40mail.gmail.com.

Re: AttributeError



On Tue, Oct 1, 2019 at 9:24 PM yasar arafath Kajamydeen <yasarnow@gmail.com> wrote:
Hi ,

While try to execute  it showing AttributeError, Can some one help me on this.


My views.py



from django.shortcuts import render
from django.http import Http404
from django.http import HttpResponse
from .models import Question


def index(request):
latest_question_list=Question.objects.order_by('pub_date')[:3]
context={'latest_question_list':latest_question_list}
return render(request,'polls/index.html',context)

def detail(request, question_id):
try:
question=Question.object.get(pk=question_id)
except Question.DoesNotExist:
raise Http404("Question does not exist")
return render(request, 'polls/detail.html', {'question':question})


def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResponse(response%question_id)


def vote(request, question_id):
return HttpResponse("You're voting on question %s."%question_id)






My detail.html


  {{question}}








My polls/urls.py



from django.urls import path

from . import views

urlpatterns = [
# ex: /polls/
path('', views.index, name='index'),
# ex: /polls/5/
path('<int:question_id>/', views.detail, name='detail'),
# ex: /polls/5/results/
path('<int:question_id>/results/', views.results, name='results'),
# ex: /polls/5/vote/
path('<int:question_id>/vote/', views.vote, name='vote'),

]

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9918df61-41fd-40bd-8ca3-79ee3be12ec3%40googlegroups.com.

Can you please post the traceback?  Copy and paste, please. Without that we won't know where the exception is raised.

-Jorge

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANfN%3DK_EVDfucXrk490XeumWyf2_u0QOfitfbQ0jFQOJyKkAjg%40mail.gmail.com.

AttributeError

Hi ,

While try to execute  it showing AttributeError, Can some one help me on this.


My views.py



from django.shortcuts import render
from django.http import Http404
from django.http import HttpResponse
from .models import Question


def index(request):
latest_question_list=Question.objects.order_by('pub_date')[:3]
context={'latest_question_list':latest_question_list}
return render(request,'polls/index.html',context)

def detail(request, question_id):
try:
question=Question.object.get(pk=question_id)
except Question.DoesNotExist:
raise Http404("Question does not exist")
return render(request, 'polls/detail.html', {'question':question})


def results(request, question_id):
response = "You're looking at the results of question %s."
return HttpResponse(response%question_id)


def vote(request, question_id):
return HttpResponse("You're voting on question %s."%question_id)






My detail.html


  {{question}}








My polls/urls.py



from django.urls import path

from . import views

urlpatterns = [
# ex: /polls/
path('', views.index, name='index'),
# ex: /polls/5/
path('<int:question_id>/', views.detail, name='detail'),
# ex: /polls/5/results/
path('<int:question_id>/results/', views.results, name='results'),
# ex: /polls/5/vote/
path('<int:question_id>/vote/', views.vote, name='vote'),

]

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9918df61-41fd-40bd-8ca3-79ee3be12ec3%40googlegroups.com.

Re: Django FastCGI and static files

hi  Django project structure is clearly understandable but I want CURD Operations mini-project  by using Django project



On Tuesday, September 17, 2019 at 9:46:31 PM UTC+5:30, Martin Jaan Leesment wrote:
Hey

I'm new to serving Django website on a shared server as well as using fastcgi and .htaccess so this might be a basic question. Namely I'm having difficulties serving static content. I've tried playing with htaccess rules, but no luck yet. My project structure:

myproject/
├── myapp
│   ├── admin.py
│   ├── apps.py
│   ├── models.py
│   ├── static
│   │   └── myapp
│   │       ├── css
│   │       │   ├── bootstrap.min.css
│   │       │   ├── bootstrap.min.min_myproject.css
│   │       │   └── proj.css
│   │       ├── fonts
│   │       ├── images
│   │       │   ├── logo.png
│   │       └── scripts
│   │           ├── bootstrap.bundle.min.js
│   │           └── bootstrap.min.js
│   ├── templates
│   │   └── myapp
│   │       ├── base.html
│   │       ├── footer.html
│   │       ├── header.html
│   │       ├── index.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── manage.py
├── myproject
│   ├── __init__.py
│   ├── locale
│   ├── media
│   ├── settings
│   │   ├── base.py
│   │   ├── dev.py
│   │   ├── __init__.py
│   │   ├── prod.py
│   ├── static
│   ├── templates
│   │   └── base.html
│   ├── urls.py
│   └── wsgi.py
├── requirements
└── test.py

My htaccess

Options +ExecCGI
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteRule ^(/static.*)$ /static//$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ cgi-bin/mydjangapp.fcgi/$1 [QSA,L]


If anybody can help me figure out how to solve it, would really appreciate.

Thanks!

Best
MJ

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9892f659-d841-41d5-a65e-6216a6b9fae7%40googlegroups.com.

Widgets not working for dynamically added formset forms

I have a formset with fields with Select2 widgets and a calendar (date-picker) from django app.

And I use dynamic addition of formset forms.


When I render a template for the first time, all widgets work fine. But when I add new formset form, widgets of this new form don't work.


I think, this ('formset:add') is somehow related to my problem, but I can't figure how to use it.

I also found this: 

$('.django-select2').djangoSelect2();

With this line dropdowns start working, but they become empty.


For adding new form I use 'empty form' and this jQuery:

<script>
$('.buttons').on('click', '#add_form', function() {
var form_idx = $('#id_resolution_set-TOTAL_FORMS').val();
$('#form_set').append($('#empty_form').html().replace(/__prefix__/g, form_idx));
$('#id_resolution_set-TOTAL_FORMS').val(parseInt(form_idx) + 1);
});
</script>


Form in HTML:

{% if mat_id == None %}
<form id="MatterForm" action="{% url 'matter_create_url' %}" enctype="multipart/form-data" method="post">
{% else %}
<form id="MatterForm" action="{% url 'matter_edit_url' mat_id=mat_id %}" enctype="multipart/form-data" method="post">
{% endif %}

{% csrf_token %}
<div class="form-matter">
{% for field in form_matter %}
<div class="form-row">
{% if field.errors %}
<div>{{ field.errors }}</div>
{% endif %}
<label class="form-label">{{ field.label_tag }}</label>
<div class="form-input">{{ field }}</div>
</div>
{% endfor %}
</div>
<h3>RESOLUTIONS</h3>

<div id="form_set" name="form_set">
{{ formset_resolutions.management_form }}
{% for form in formset_resolutions %}
<div class="formset-form" name="formset-form">
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% for field in form.visible_fields %}
<div class="form-row">
{% if field.errors %}
<div>{{ field.errors }}</div>
{% endif %}
<label class="form-label">{{ field.label_tag }}</label>
<div class="form-input">{{ field }}</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
<div class="buttons">
<button class="btn" type="button" id="add_form">ADD</button>
<button class="btn" type="submit">SAVE</button>
</div>
<div id="empty_form" style="display:none">
<div class="formset-form">
{% for field in formset_resolutions.empty_form.visible_fields %}
<div class="form-row">
{% if field.errors %}
<div>{{ field.errors }}</div>
{% endif %}
<label class="form-label">{{ field.label_tag }}</label>
<div class="form-input">{{ field }}</div>
</div>
{% endfor %}
</div>
</div>
</form>


Other scripts:

<script type="text/javascript" src="/jsi18n/"></script>
<script type="text/javascript" src="/static/js/jquery.js"></script>
{{ form_matter.media.js }}

{{ form_matter.media.js }} are:
<script type="text/javascript" src="/static/admin/js/calendar.js"></script>
<script type="text/javascript" src="/admin/jsi18n/"></script>  <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js"></script>  <script type="text/javascript" src="/static/admin/js/admin/DateTimeShortcuts.js"></script>  <script type="text/javascript" src="/static/admin/js/core.js"></script>  <script type="text/javascript" src="/static/django_select2/django_select2.js"></script>

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/109371d8-73ba-4a84-94be-f66e3bd81c96%40googlegroups.com.