Re: Migrating into Django 1.9; question about autoescape

2018-03-11 Thread Peter of the Norse
This seems odd, because autoescaping has been on since almost the beginning.  
https://web.archive.org/web/20080826081214/http://docs.djangoproject.com:80/en/dev/topics/templates/#id2
  What actually changed with 1.9?

> On Feb 13, 2018, at 7:53 AM, Bill Torcaso  wrote:
> 
> 
> Hello all,
> 
> I have the task of migrating a very old website from Django 1.7 to either 
> Django 1.11 or 2.0, depending on the effort.
> 
> My plan is to go from 1.7 --> 1.8 --> 1.9 -->1.10 --> 1.11, adapting the 
> codebase as I go.  It's been easy enough until I arrive at 1.9, and the 
> change in template-rendering in which "autoescape" defaults to "on".
> 
> Now a lot of my payload is arriving at the browser with my HTML tags escaped. 
>  For example,
> 
>gets rendered asbutton
> 
> I have no argument with the autoescape-on default setting.  But I am unsure 
> how to proceed, and how large the effort will be.  As background, I am a 
> seasoned back-end programmer and a lightweight in HTML and template issues.
> 
> I see these alternatives.  Are there any others?
> 
> Get to the Template Engine object and set its autoescape attribute to "off".  
> This loses the protection that autoescape-on provides, restores the Django 
> 1.8 behavior, and let me proceed with the smallest amount of effort.
> 
> Is this the template engine I need?  "django.core.context_processors.request" 
>  And how do I get to the object?
> 
> Visit all of my HTML files and put "{% autoescape off %}" everywhere.
> 
> I put "{% autoescape off %}" in my base.html, and it partially solved the 
> problem.  But it did not get everything.
> 
> This is a medium amount of effort, and if I make a mistake the users will 
> have a bad experience.
> 
> Visit all of my code and all of my templates, carefully converting into the 
> world of autoescape-on.
> Thanks in advance,
> 
>   ---  Bill Torcaso

Peter of the Norse
rahmc...@radio1190.org



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


Re: Template.render(Context) in django 1.10+

2018-03-11 Thread Daniel Roseman
On Sunday, 11 March 2018 21:06:51 UTC, Craig de Stigter wrote:
>
> Hi folks
>
> I'm upgrading a large app from 1.8 to 1.11 and coming up against this as I 
> traverse through django 1.9:
>
> >>> from django.template import engines, Context
> ... t = engines['django'].from_string('')
> ... t.render(Context({}))
> ...
> /path/to/bin/django-admin.py:3: RemovedInDjango110Warning: render() must 
> be called with a dict, not a Context.
>
>
> This is a surprising warning to me, since the docs still document the use 
> of Template.render(Context) in 2.0: 
> https://docs.djangoproject.com/en/2.0/ref/templates/api/#rendering-a-context
>
> Would someone mind explaining this?
>
> Cheers
> Craig de Stigter
>
>
>
Not the same thing. `t` here is an instance 
of django.template.backends.django.Template, whose render method takes a 
dict. If you did:

  from django.templates import Template
  t = Template('')

then you would have an instance of django.template.base.Template, whose 
render method takes a context.

I have no idea why the distinction, though.
-- 
DR. 

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


Re: Using Python Packages in Django

2018-03-11 Thread djangorobert
Hi Jani thanks 
I was thinking something like this 

from rx import Observable, Observer


people = ['robert', 'anna', 'jake', 'harry', 'lacey']

class MyObserver(Observer):
 templates = 'peron/people.html'
 context = {}
def on_next(self, x):
print("Found: {}".format(x))

def on_error(self, e):
print("Sorry got an error for: {e}".format(e))

def on_completed(self):
print('All Done')

p = Observable.from_iterable(people)
subscribe = p.subscribe(MyObserver())
return render(request, templates, context)

On Sunday, March 11, 2018 at 3:02:18 PM UTC-5, Jani Tiainen wrote:
>
> Hi.
>
> Django is just Python so you can use any library as you see fit.
>
> You don't need to create any special models for that unless you want to 
> store something to database.
>
> If that package creteates output you want to show in template just calling 
> it from a view is sufficient.
>
> 11.3.2018 20.10 "djangorobert"  
> kirjoitti:
>
>> Have a question may be silly but want to know when using a library like 
>> the Python rx library package 
>> how would I use it in django?
>>
>> Would I have to create a model?
>> or could I use it in a View Thanks
>>
>>
>> I was thinking in a View but was unsure if i could with a Function view 
>> instead 
>>
>> Thanks 
>> IF you have had experience with it i would appreciate your INfo thanks.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/094bbd87-d1fd-4885-981d-8507f8cb3b2d%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Template.render(Context) in django 1.10+

2018-03-11 Thread Craig de Stigter
Hi folks

I'm upgrading a large app from 1.8 to 1.11 and coming up against this as I
traverse through django 1.9:

>>> from django.template import engines, Context
... t = engines['django'].from_string('')
... t.render(Context({}))
...
/path/to/bin/django-admin.py:3: RemovedInDjango110Warning: render() must be
called with a dict, not a Context.


This is a surprising warning to me, since the docs still document the use
of Template.render(Context) in 2.0:
https://docs.djangoproject.com/en/2.0/ref/templates/api/#rendering-a-context

Would someone mind explaining this?

Cheers
Craig de Stigter

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


Re: Using Python Packages in Django

2018-03-11 Thread Jani Tiainen
Hi.

Django is just Python so you can use any library as you see fit.

You don't need to create any special models for that unless you want to
store something to database.

If that package creteates output you want to show in template just calling
it from a view is sufficient.

11.3.2018 20.10 "djangorobert"  kirjoitti:

> Have a question may be silly but want to know when using a library like
> the Python rx library package
> how would I use it in django?
>
> Would I have to create a model?
> or could I use it in a View Thanks
>
>
> I was thinking in a View but was unsure if i could with a Function view
> instead
>
> Thanks
> IF you have had experience with it i would appreciate your INfo thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/094bbd87-d1fd-4885-981d-8507f8cb3b2d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Using Python Packages in Django

2018-03-11 Thread djangorobert
Have a question may be silly but want to know when using a library like the 
Python rx library package 
how would I use it in django?

Would I have to create a model?
or could I use it in a View Thanks


I was thinking in a View but was unsure if i could with a Function view 
instead 

Thanks 
IF you have had experience with it i would appreciate your INfo thanks.

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


Some Basic Basic Question DJango Interview questions

2018-03-11 Thread Sharad Jaiswal


Django is a free and open-source web framework written in Python and Based 
on the model-view-template architectural pattern. Django web framework is a 
set of components that help you to develop websites earlier and easier.
While building a website, you always need a similar set of components: a 
way to handle user authentication (signing up, signing in, signing out), a 
management panel for your website. 

Here are some Basic Question Django questions with  answers 


Regards
https://www.onlineinterviewquestions.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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ab531f76-26c8-4d41-9c67-c82d8c904fe6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using success_url with reverse() in class-based generic view

2018-03-11 Thread Mayur Karmakar
Try to import reverse_lazy form "django.core.urlresolvers" in your views.py 
and declare the DeleteView as:-

class MyDeleteView(DeleteView):
  model = models.YourModelName
  success_url = 
reverse_lazy('Your_app_name_for_urls.py':urlpattern_name_your_wanna_redirect_to)

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


Re: django URLconf current path didn't match

2018-03-11 Thread Jason
and you're getting this from the URL *localhost:8000/polls/ *?

On Saturday, March 10, 2018 at 8:31:34 AM UTC-5, Usman Gill wrote:
>
> Using the URLconf defined in mysite.urls, Django tried these URL patterns, 
> in this order:
>
> polls/ [name='index']
> admin/
>
> The current path, polls/, didn't match any of these.
>
>
> My code is... from (app)polls urls.py
>
>
> from django.urls import pathfrom . import views
>
>
> urlpatterns = [
> path('', views.index, name='index'),]
>
> from (project)mysite urls.py
>
> from django.urls import include, pathfrom django.contrib import admin
>
>
> urlpatterns = [
> path('polls/', include('polls.urls')),
> path('admin/', admin.site.urls),
> ]
>
> from views.py project file
>
> from django.shortcuts import renderfrom django.http import HttpResponse
> def index(request):
> return HttpResponse("Hello world, you are at the polls index.")
>
>

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