Wednesday, October 2, 2019

Re: cannot import path in urls

In urls.py
Write 
from django.urls import path

On Thu, 3 Oct, 2019, 10:02 AM MEGA NATHAN, <cloudnathan1997@gmail.com> wrote:
Hi.


i'm meganathan beginer for django ....

urls cannot import for path . how to reslove ....

--
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/a0c82af4-da14-49e4-a0af-eff26f47afbd%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/CAPjsHcEv9-av30MrCetr0FxAHHEpjHM_0jiava_PP6XdKQWLwg%40mail.gmail.com.

Re: Django 2.2.6 fails to serve some static files in Windows 10

You need to edit external css link:

Solution:
href="{% static 'css/styles.css' %}"








Regards:
Desh Deepak
+917011101001





On Wed, 2 Oct 2019, 21:37 red sky, <Alfredobaut@gmail.com> wrote:
My system: Windows 10 1903. Python 3.7.4, 64 bit.

My directory structure:
%USERPROFILE%/Desktop/myproject/manage.py
%USERPROFILE%/Desktop/myproject/some_app (...)
%USERPROFILE%/Desktop/myproject/myproject/db.sqlite3
%USERPROFILE%/Desktop/myproject/myproject/urls.py
%USERPROFILE%/Desktop/myproject/myproject/static (...)
%USERPROFILE%/Desktop/myproject/myproject/static/css (...)
%USERPROFILE%/Desktop/myproject/myproject/media (...)
%USERPROFILE%/Desktop/myproject/myproject/some_apps (...)
%USERPROFILE%/Desktop/myproject/myproject/settings/
%USERPROFILE%/Desktop/myproject/myproject/settings/__init__.py
%USERPROFILE%/Desktop/myproject/myproject/settings/settings_base.py
%USERPROFILE%/Desktop/myproject/myproject/settings/settings_devel.py
%USERPROFILE%/Desktop/myproject/myproject/settings/settings_production.py


My urls.py (last part):
if ENVIRONMENT=="development":
import debug_toolbar
urlpatterns += [path('__debug__/',include (debug_toolbar.urls))]
urlpatterns += static(MEDIA_URL,document_root=MEDIA_ROOT)
urlpatterns += static(STATIC_URL,document_root=STATIC_ROOT)
urlpatterns += router.urls

My settings:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR , 'static')
MEDIA_ROOT = BASE_DIR + '/media/'
(...)
MEDIA_URL='/media/'

I also tried with and without the following setting in several variants:
STATIFCILES_DIRS = ["","//",STATIC_ROOT,"%userprofile%\\Desktop\\myproject\\myproject\\"]

The template: The error happens both with  href="/static/css/styles.css" and {% load static %} (...) href="{% static css/styles.css}" . I think the template is not the problem here.

The error:"GET /static/css/styles.css HTTP/1.1" 404 1767

The error takes place also with static requests (http://127.0.0.1:8000/static/css/styles.css)

Strange behaviour: 
If I change the setting static_url to STATIC_URL = "static/" the css file is served. However, debug_toolbar ceases to serve her own static files and doesn't work anymore ("GET /myproject/static/debug_toolbar/img/ajax-loader.gif HTTP/1.1" 404 14554)

I have tried many things, to no avail.

Thank you.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/aa231cc0-c3bf-4d3d-8bf0-6578d1952eff%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/CAJ0m4xgGtsdnSmGVvniNf__obX3XBqD2p6YPHhYhy3WH8T3z8Q%40mail.gmail.com.

ListView from 2 model

hi everyone,
I got a problem in listing two models from a listview that is,  a list of one model and another model together (eg Books and Authors)

--
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/915dbb5a-78bc-4d06-9a96-b0a43fa84be7%40googlegroups.com.

Can Django support chunked file uploads without a Content-Length header?

I'm working on a Django API which receives audio files and some extra POST data and then processes the file. This was initially in Flask, but Django suits the overall project better so we're migrating. However we've run into a snag.

Currently the audio file is sent via node.js, with the node-fetch library. The important thing about this library is that it does not set a Content-Length header and instead chunks the file, giving us a "Transfer-Encoding: chunked" header.

It seems to me that Django cannot handle this and simply reads the wsgi.input as blank.

To be specific about how this happens Django creates a LimitedStream using the wsgi.input stream and a content-length defaulting to 0 here.

On trying to then read the stream we hit this block due to the limit (the content-length) being 0, which in turn causes this block to be executed rendering the input stream effectively blank.

The effect of the above is to stop Django being able to read chunked files. This occurs both with the development server and with gunicorn.

I did find a seemingly related bug here but it seems specific to GET requests and is applied in middleware - which occurs after we've already set the nulling limit on the LimitedStream.

So I'm left wondering if this is intentional, or should it be considered a bug? If it is intentional, is there a workaround for this? For instance in werkzeug which uses a wsgi.input_terminated flag to tell whether it should just use the raw wsgi.input stream or use its own version of a LimitedStream.

--
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/fb74257e-5f06-4d42-a266-2e694d831187%40googlegroups.com.

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

Hi,

Can some one please share where to place a chrome driver [.exe] file in a django project which launches a webpage to perform click operations using selenium.

Please share any document or videos for the same,

Regards,
N.Dilip kumar.

On Wed, Oct 2, 2019 at 3:15 PM Dilipkumar Noone <n.dilipk@gmail.com> wrote:
Dear Deep L Sukhwani,

The below statement clarifies my doubt.
----------------------------------------------------------------------------------------------------------------------------------------------------
Here, your Django app is running on a different process and you are triggering selenium job separately.
----------------------------------------------------------------------------------------------------------------------------------------------------

Thanks & Regards.
N.Dilip Kumar.

On Wed, Oct 2, 2019 at 10:23 AM Deep Sukhwani <deepsukhwani@gmail.com> wrote:
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.

--
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/CAGDt2kBuq7%2BZK_3C9%3D2CMcgSykXfsnUUv%2BSxhSpEUSyPtnM8eQ%40mail.gmail.com.

Bug? django fails to serve static files in Windows 10

my system: Windows 10 1903, Python 3.7.4, 64 bit

My directory structure

%USERPROFILE%/Desktop/myproject/manage.py
%USERPROFILE%/Desktop/myproject/some_app/(...)
%USERPROFILE%/Desktop/myproject/myproject/sqlite3.db
%USERPROFILE%/Desktop/myproject/myproject/static (...)
%USERPROFILE%/Desktop/myproject/myproject/media (...)
%USERPROFILE%/Desktop/myproject/myproject/settings (with files __init__.py, settings_base.py, settings_devel.py, settings_production.py)
%USERPROFILE%/Desktop/myproject/myproject/static (...)
%USERPROFILE%/Desktop/myproject/myproject/static/css/styles.css
%USERPROFILE%/Desktop/myproject/myproject/more_apps/(...)

My urls.py (relevant parts)

from .settings import ENVIRONMENT, MEDIA_URL, MEDIA_ROOT, STATIC_URL, STATIC_ROOT
(...)
if ENVIRONMENT=="development":
import debug_toolbar
urlpatterns += [path('__debug__/',include (debug_toolbar.urls))]
urlpatterns += static(MEDIA_URL,document_root=MEDIA_ROOT)
urlpatterns += static(STATIC_URL,document_root=STATIC_ROOT)
urlpatterns += router.urls


My settings_base.py (relevant part)

INSTALLED_APPS = [...
'django.contrib.staticfiles',
...]

MEDIA_ROOT = BASE_DIR + '/media/'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR , 'static')
STATIFCILES_DIRS = ["","//",STATIC_ROOT,"C://Users//alfre//Desktop//memes//memes//"]
MEDIA_URL='/media/'

My settings_base.py (relevant part)

MEDIA_ROOT = BASE_DIR + '/media/'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR , 'static')
#STATIFCILES_DIRS = ["","//",STATIC_ROOT,"C://Users//alfre//Desktop//memes//memes//"]
MEDIA_URL='/media/'

(The error happens with several variants of the STATICFILES_DIRS, even with that line disabled or with several combinations)

The template shows the adress right, so I guess that is not the problem. Furthermore, the issue also happens when I request the file manually (http://127.0.0.1:8000/static/css/styles.css).

The error is "GET /static/css/styles.css HTTP/1.1" 404 1767
 
Strangely enough, I have not had any error with MEDIA images (served by sorl_thumbnails).

Strange behaviour:

If I replace STATIC_URL = '/static/' with 'static/' my static files are SOMETIMES served (but only when requested from root) (it seems I have to start the server, request the page, change form /static/ to static/ and then request it again to have the css served!), but django toolbar static files are not (they give back a 404 error , but they complain about the path GET /myproject/static/debug_toolbar/styles.css HTTP/1.1" 404 1767

As you can expect, this issue is relevant for development, given the importance of stylesheets.

Finally, if I insert print(STATIC_ROOT) in my settings files, I get the correct directory displayed on the console. But the files are still not delivered.

Thank you.

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

Django 2.2.6 fails to serve some static files in Windows 10

My system: Windows 10 1903. Python 3.7.4, 64 bit.

My directory structure:
%USERPROFILE%/Desktop/myproject/manage.py
%USERPROFILE%/Desktop/myproject/some_app (...)
%USERPROFILE%/Desktop/myproject/myproject/db.sqlite3
%USERPROFILE%/Desktop/myproject/myproject/urls.py
%USERPROFILE%/Desktop/myproject/myproject/static (...)
%USERPROFILE%/Desktop/myproject/myproject/static/css (...)
%USERPROFILE%/Desktop/myproject/myproject/media (...)
%USERPROFILE%/Desktop/myproject/myproject/some_apps (...)
%USERPROFILE%/Desktop/myproject/myproject/settings/
%USERPROFILE%/Desktop/myproject/myproject/settings/__init__.py
%USERPROFILE%/Desktop/myproject/myproject/settings/settings_base.py
%USERPROFILE%/Desktop/myproject/myproject/settings/settings_devel.py
%USERPROFILE%/Desktop/myproject/myproject/settings/settings_production.py


My urls.py (last part):
if ENVIRONMENT=="development":
import debug_toolbar
urlpatterns += [path('__debug__/',include (debug_toolbar.urls))]
urlpatterns += static(MEDIA_URL,document_root=MEDIA_ROOT)
urlpatterns += static(STATIC_URL,document_root=STATIC_ROOT)
urlpatterns += router.urls

My settings:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR , 'static')
MEDIA_ROOT = BASE_DIR + '/media/'
(...)
MEDIA_URL='/media/'

I also tried with and without the following setting in several variants:
STATIFCILES_DIRS = ["","//",STATIC_ROOT,"%userprofile%\\Desktop\\myproject\\myproject\\"]

The template: The error happens both with  href="/static/css/styles.css" and {% load static %} (...) href="{% static css/styles.css}" . I think the template is not the problem here.

The error:"GET /static/css/styles.css HTTP/1.1" 404 1767

The error takes place also with static requests (http://127.0.0.1:8000/static/css/styles.css)

Strange behaviour: 
If I change the setting static_url to STATIC_URL = "static/" the css file is served. However, debug_toolbar ceases to serve her own static files and doesn't work anymore ("GET /myproject/static/debug_toolbar/img/ajax-loader.gif HTTP/1.1" 404 14554)

I have tried many things, to no avail.

Thank you.

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