Generation of Session IDs in Django

2016-04-27 Thread Arun S

Hi,

Just trying to get a few answers on the Session IDs in Django.

> how does Django Generate Session IDs/Session Keys.
It seems that Django does the following for Session Keys:

def _get_new_session_key(self):
"Returns session key that isn't being used."
while True:
session_key = get_random_string(32, VALID_KEY_CHARS)
if not self.exists(session_key):
break
return session_key

Does this mean that only a RANDOM string is chosen from the set of Valid 
Key Chars ??
If the Above is not the case, then
Does Django Support any Cryptographic Algorithms for Genearting Session IDs?
in that case
Which Cryptographic Algorithm does Django Uses for Session IDs and how many 
Bits of Entropy is used.??

Any information on this would be very helpful.

Thanks
Arun

-- 
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/eba81953-c59f-4aba-b733-e320cc6fdef8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I'm new to programming, I don't know where consider as "document root of web server"

2016-04-27 Thread Lachlan Musicman
On 28 April 2016 at 14:41, Mie Rex  wrote:

> for your case, site1 and site2 are two isolate webserver, correct?
> Will all the files under both of these directories open to public once the
> server is up and running?
>

Oops - almost, but not quite. Site1 and Site2 are two different websites,
being served by the same webserver. A web server can serve as many sites as
you want, so long as you configure them all correctly.

"open to the public" is a tricky phrase. In a traditional site (I'm an old
man) that would have been the case - long list of .html files and they
would be "served". These days it's more common for the files to be mini
database-referencing programs (like .php files), or in the case of Django
to be a systemic framework that requires one more server (a 'gateway
interface', like Gunicorn, wsgi, fastcgi, etc - these normally execute the
.py files).

That is a very complex answer - I'm sorry, but web serving is fiddly :/

But the simple answer is yes - if you have configured the server correctly,
both directories will be "served".



> Is the article from the tutorial suggest to have .py files store in some
> other place to avoid it being see by visitors online?
> So the framework could just import scripts from designated place through
> PYTHONPATH even when the scripts are not placed within site1 or site2?
>


I can't speak to the exact reason why it is recommended that you avoid
putting them in the traditional document root. I would suggest that it's
almost certainly due to security reasons. I wont guess what they are,
because I can think of half a dozen off the top of my head that are
confusing and potentially wrong. But it's almost certainly for server
security, yes.



Thank you for such a quick response especially to my extremely novice
> question.
> I hope I would learn a lot from this community, thank you very much
>


No problems. I learnt a lot here too.

cheers
L.

-- 
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/CAGBeqiNc2eSDZ_AhKJ-Q0QT1fPwf%2BT%3DpD35n10x_4tXRGArKEQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Completed form for an authenticated user

2016-04-27 Thread Said Akhmedbayev
Yes Gergely, it is exactly what I want, simple form that saves a user's 
input into database. I have gone through tutorial on the django doc website 
and kind of know how forms work in general. I just cannot figure out how to 
hook together a user with his/her input data.

On Wednesday, April 27, 2016 at 11:49:22 PM UTC+6, Gergely Polonkai wrote:
>
> It is indeed unclear, what you want to do. How I understood it:
>
> show a bunch of fields to the user that they can fill with data
> then, they press the Save button, and the data gets into the database (or 
> whatever)
> then, you want to show the same fields, filled with the data that the user 
> just entered
>
> Is this it?
>
> Also, have you gone through the tutorial? If not, I strongly suggest to to 
> so. It will clear a lot of things both about Django and the web in general.
>
> Best,
> Gergely
>
>  
>
> Gergely Polonkai
> [image: https://]about.me/gergely.polonkai
>
> 
>
> 2016-04-27 19:13 GMT+02:00 Said Akhmedbayev  >:
>
>> Let's say, for example, I have a reusable form. An authenticated user 
>> fills out this form and saves it. How then, I can show to the user a page 
>> with the complete form?
>>
>> Sorry, for not being able to explain the question clearly, I am new to 
>> django and to the web development in general.
>>
>> -- 
>> 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/4165af84-44ec-4494-8613-8396cc6d2e0b%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/af272634-e148-4e82-ace5-839617f5502f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I'm new to programming, I don't know where consider as "document root of web server"

2016-04-27 Thread Mie Rex
for your case, site1 and site2 are two isolate webserver, correct?
Will all the files under both of these directories open to public once the 
server is up and running?
Is the article from the tutorial suggest to have .py files store in some 
other place to avoid it being see by visitors online?
So the framework could just import scripts from designated place through 
PYTHONPATH even when the scripts are not placed within site1 or site2?

Thank you for such a quick response especially to my extremely novice 
question.
I hope I would learn a lot from this community, thank you very much

Lachlan Musicman於 2016年4月27日星期三 UTC-7下午6時57分26秒寫道:
>
> Mie,
>
> Traditionally the document root to your webserver is (depending on your 
> system) /var/www.
>
> This will be defined in the webserver (apache2/httpd, nginx, etc) 
> configuration.
>
> I normally create a folder in my home dir called www and place my sites 
> within that
>
> /home/lachlan/www/site1
> /home/lachlan/www/site2
>
> At a later point, you will need to set up your webserver to read from that 
> directory.
>
>
>
> Cheers
> L.
>
> --
> The most dangerous phrase in the language is, "We've always done it this 
> way."
>
> - Grace Hopper
>
> On 28 April 2016 at 11:25, Mie Rex  
> wrote:
>
>> Hello everyone, I am new to Django and quite new to Python as well.
>>
>> I came across this advice while I'm going through the Django tutorial here
>> https://docs.djangoproject.com/en/1.9/intro/tutorial01/
>>
>> It mentioned "It’s not a good idea to put any of this Python code within 
>> your Web server’s document root..."
>> My very newbie question is:  what's document root of web server?
>> I have no knowledge in building a web site so please forgive my very 
>> shallow question.
>> Cheers
>>
>> -- 
>> 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/0d8833ce-1623-4811-836a-d82a1cc39ee9%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/9f33413c-5f4c-42c3-9d87-b4ac494f6508%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New to Django (stuck at the end of the tutorial)

2016-04-27 Thread Mie Rex

>
> I had a smiliar problem with another Django tutorial.
>

I was running Django with Anaconda environment and I took the advice from 
"Two Scoop Django" to have all projects stored in one directory and all the 
environment in another.  Therefore the project "mysite" was initialized and 
put in a folder, which was parallel to the environment folder.
I fixed all the problem by initializing the project inside the environment 
used for Django.

Took me 3 days to figure out what was the problem.
Hope you could figure out how to fix that soon.
Cheers

-- 
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/21ed70ea-9cf1-4b66-84e9-9d519d69b467%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I'm new to programming, I don't know where consider as "document root of web server"

2016-04-27 Thread Lachlan Musicman
Sorry, that was a "where is" not a "what is"

The document root of your webserver is the *default* location on the file
system that the webserver will look for content/websites/things to "serve".


cheers
L.

--
The most dangerous phrase in the language is, "We've always done it this
way."

- Grace Hopper

On 28 April 2016 at 11:56, Lachlan Musicman  wrote:

> Mie,
>
> Traditionally the document root to your webserver is (depending on your
> system) /var/www.
>
> This will be defined in the webserver (apache2/httpd, nginx, etc)
> configuration.
>
> I normally create a folder in my home dir called www and place my sites
> within that
>
> /home/lachlan/www/site1
> /home/lachlan/www/site2
>
> At a later point, you will need to set up your webserver to read from that
> directory.
>
>
>
> Cheers
> L.
>
> --
> The most dangerous phrase in the language is, "We've always done it this
> way."
>
> - Grace Hopper
>
> On 28 April 2016 at 11:25, Mie Rex  wrote:
>
>> Hello everyone, I am new to Django and quite new to Python as well.
>>
>> I came across this advice while I'm going through the Django tutorial here
>> https://docs.djangoproject.com/en/1.9/intro/tutorial01/
>>
>> It mentioned "It’s not a good idea to put any of this Python code within
>> your Web server’s document root..."
>> My very newbie question is:  what's document root of web server?
>> I have no knowledge in building a web site so please forgive my very
>> shallow question.
>> Cheers
>>
>> --
>> 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/0d8833ce-1623-4811-836a-d82a1cc39ee9%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/CAGBeqiOyiX9Uy8s%2BDOp8whFwYAQU2Q0z4E%2B_1aYFb-BZ7M1ZZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I'm new to programming, I don't know where consider as "document root of web server"

2016-04-27 Thread Lachlan Musicman
Mie,

Traditionally the document root to your webserver is (depending on your
system) /var/www.

This will be defined in the webserver (apache2/httpd, nginx, etc)
configuration.

I normally create a folder in my home dir called www and place my sites
within that

/home/lachlan/www/site1
/home/lachlan/www/site2

At a later point, you will need to set up your webserver to read from that
directory.



Cheers
L.

--
The most dangerous phrase in the language is, "We've always done it this
way."

- Grace Hopper

On 28 April 2016 at 11:25, Mie Rex  wrote:

> Hello everyone, I am new to Django and quite new to Python as well.
>
> I came across this advice while I'm going through the Django tutorial here
> https://docs.djangoproject.com/en/1.9/intro/tutorial01/
>
> It mentioned "It’s not a good idea to put any of this Python code within
> your Web server’s document root..."
> My very newbie question is:  what's document root of web server?
> I have no knowledge in building a web site so please forgive my very
> shallow question.
> Cheers
>
> --
> 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/0d8833ce-1623-4811-836a-d82a1cc39ee9%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/CAGBeqiMGmYZtif%2BakWm9OgnRV9jqGBsN1NXEBqAWMWHB4d%2BCfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Nagios plugins for Monitoring Django Apps

2016-04-27 Thread Gergely Polonkai
Hello,

I don’t know of any built-in metrics in Django that you can monitor. If you
write some for your apps, you could also write some monitoring scripts, too
(probably in the form of a management command).

Best,
Gergely



Gergely Polonkai
[image: https://]about.me/gergely.polonkai


2016-04-27 22:42 GMT+02:00 Keir W :

> Does anyone have any tips on monitoring the health & status of a django
> app, possibly with the use of a Nagios plugin?
>
> I am using check_log to grep out any errors from the apache error log file
> (when using mod_wsgi) but wondered if I was missing a trick and someone had
> something better to try.
>
> Ta.
>
> --
> 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/12b0d8a7-ceb6-4a9f-a17d-3f05ee9aa2aa%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/CACczBUJq8i6qJfA0zLLw-72RU%2BjPdDZm1RrmOGXXuiS%3Dzd_dYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Nagios plugins for Monitoring Django Apps

2016-04-27 Thread Keir W
Does anyone have any tips on monitoring the health & status of a django 
app, possibly with the use of a Nagios plugin?

I am using check_log to grep out any errors from the apache error log file 
(when using mod_wsgi) but wondered if I was missing a trick and someone had 
something better to try.

Ta.

-- 
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/12b0d8a7-ceb6-4a9f-a17d-3f05ee9aa2aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


CSRF verification failed. Request aborted.

2016-04-27 Thread Jagga Soorma
Hi Guys,

We have a few internal sites that seem to be creating a cookie with domain 
.xxx.com.  If I access one of these sites and then try to access my horizon 
interface (which creates a yyy.xxx.com domain cookie) I am no longer able 
to and get the following error message:

--
CSRF verification failed. Request aborted.
--

if I manually remove the .xxx.com domain cookie then it works fine.  Looks 
like horizon matches the .xxx.com (not fqdn) cookie instead of its own 
yyy.xxx.com.  Not sure how cookies work and was wondering if anyone on this 
list can help point me in the correct direction.  

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/b6303602-4ebf-42f5-b438-675ff65f9303%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: (Newbie) Stuck with annotate() docs

2016-04-27 Thread Tim Graham
Please give this a try: https://github.com/django/django/pull/6524

On Wednesday, April 27, 2016 at 10:45:03 AM UTC-4, Ankush Thakur wrote:
>
> I'm not sure how Book.objects.first().chapters is different 
> from Book.objects.first().chapters.count(), but the point is that 
> "chapters" is not defined in the models at the top of that page! The 
> snippet makes sense if I treat Book.chapters as another ManyToManyField 
> (like authors), but it's really weird to see that error in the docs. So, 
> does that mean I can report it? If yes, to who?
>
> On Wednesday, April 27, 2016 at 4:36:40 AM UTC+5:30, Tim Graham wrote:
>>
>> Looks like a typo. Does the rest of the example make sense and work if 
>> that line is changed to "Book.objects.first().chapters"?
>>
>> On Tuesday, April 26, 2016 at 12:50:31 PM UTC-4, Ankush Thakur wrote:
>>>
>>> Folks, I'm having exceptional trouble understanding annotate(), 
>>> aggregate(), and their various combinations. I'm currently stuck here: 
>>> https://docs.djangoproject.com/en/1.9/topics/db/aggregation/#combining-multiple-aggregations
>>>
>>> The example here uses Book.objects.first().chapters.count(), but there's 
>>> no chapters model or field at the start of the tutorial. It's frustrating, 
>>> to say the least. Even if I set up a separate application to test this 
>>> myself, what do I make of "chapters"? Is it another model with many-to-many 
>>> relation with Book? When I ran an example with the following models:
>>>
>>> class Author(models.Model):
>>> name = models.CharField(max_length=100)
>>> age = models.IntegerField()
>>>
>>> class Book(models.Model):
>>> name = models.CharField(max_length=300)
>>> chapters = models.IntegerField()
>>> authors = models.ManyToManyField(Author)
>>>
>>> I got: 
>>>
>>> >>> Book.objects.first().chapters.count()
>>> Traceback (most recent call last):
>>>   File "", line 1, in 
>>> AttributeError: 'int' object has no attribute 'count'
>>> >>> 
>>>
>>> So basically, I feel like I'm screwed. Please help.
>>>
>>

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


Re: admin popup + button help

2016-04-27 Thread Giuseppe
I managed to get this working, sort of. I learned that I need to include 
jquery.init.js to my parent form. otherwise It wont open in a new window. 
Now the only issue I am encountering is after I submit my child form, the 
window goes white, but does not close. I think the code that gets called 
when I submit the form is this 
return HttpResponse('opener.dismissAddRelatedObjectPopup(window, "%s", 
"%s");' % \
(escape(newObject._get_pk_val()), escape(newObject)))
I cant figure out if its being called at all or if its being called on the 
child or if its being called on the parent and thats why its not closing. 
"window" is being staticaly typed so its not in the view code other than 
that one spot. 

Here is the Django code for the dismiss function (this was pulled directly 
from  
https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
function dismissAddRelatedObjectPopup(win, newId, newRepr) {
   var name = windowname_to_id(win.name);
   var elem = document.getElementById(name);
   if (elem) {
   var elemName = elem.nodeName.toUpperCase();
   if (elemName === 'SELECT') {
   elem.options[elem.options.length] = new Option(newRepr, newId
, true, true);
   } else if (elemName === 'INPUT') {
   if (elem.className.indexOf('vManyToManyRawIdAdminField') !== 
-1 && elem.value) {
   elem.value += ',' + newId;
   } else {
   elem.value = newId;
   }
   }
   // Trigger a change event to update related links if required.
   $(elem).trigger('change');
   } else {
   var toId = name + "_to";
   var o = new Option(newRepr, newId);
   SelectBox.add_to_cache(toId, o);
   SelectBox.redisplay(toId);
   }
   win.close();
   }

I can see that after I submit my new object gets selected in the dropdown 
inside the parent form, but the popup window from the child form does not 
close. Any ideas how to get the child form to close, the dismiss function 
should be doing that correct?


On Wednesday, April 20, 2016 at 5:06:22 PM UTC-4, Giuseppe wrote:
>
> I am trying to get a pop up that will let me create a new object to 
> associate to a many to many relationship on a form/model. In the same way 
> that it works in django-admin.
>
> I have been followed the instructions from here 
> , and its 
> not working for me. 
>
> whenever I click the plus button it opens the related object creating form 
> in the same tab instead of a new pop up. When I try to submit the new 
> object I get a cert error and I included the cert tag in the template.
>
> Let me know what code you want to see and I can post it. Also if you know 
> of a different resource, or library or way of doing this that would be 
> amazing.
>
> By the way I think the link provided was for django 1.1 and im using 
> django 1.9.1
>

-- 
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/dbba1952-d5b3-4fc1-a68f-cc48fc4a508c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Completed form for an authenticated user

2016-04-27 Thread Gergely Polonkai
It is indeed unclear, what you want to do. How I understood it:

show a bunch of fields to the user that they can fill with data
then, they press the Save button, and the data gets into the database (or
whatever)
then, you want to show the same fields, filled with the data that the user
just entered

Is this it?

Also, have you gone through the tutorial? If not, I strongly suggest to to
so. It will clear a lot of things both about Django and the web in general.

Best,
Gergely



Gergely Polonkai
[image: https://]about.me/gergely.polonkai


2016-04-27 19:13 GMT+02:00 Said Akhmedbayev :

> Let's say, for example, I have a reusable form. An authenticated user
> fills out this form and saves it. How then, I can show to the user a page
> with the complete form?
>
> Sorry, for not being able to explain the question clearly, I am new to
> django and to the web development in general.
>
> --
> 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/4165af84-44ec-4494-8613-8396cc6d2e0b%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/CACczBUL_JRtrkzPq7Mjb_NQn9QpSnYFAYB907MbM1a2C_qiePw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Fwd: Built In Template Tag Request

2016-04-27 Thread Paul Kenjora
Hello,

  I sometimes have to pass more complex content into an include or another
tag as a variable.  The {% with %} tag and filters aren't enough to for
example render an HTML button and pass it into another include.

  I'd like to request a {% with_html variable %} tag in the built in tag
set.  Like the one below

@register.tag
> def with_html(parser, token):
>   nodelist = parser.parse(('endwith_html',))
>   parser.delete_first_token()
>   return WithHTML(nodelist, token.contents.split()[1])
>
> class WithHTML(template.Node):
>   def __init__(self, nodelist, variable):
> self.nodelist = nodelist
> self.variable = variable
>   def render(self, context):
> context[self.variable] = self.nodelist.render(context)
> return ''


A use case would be for example...

{% with_html extra %}
>   {% if row.0.ingredient_set.count %}{{ row.0.ingredient_set.count }}
> Ingredients{% endif %}
>   {% if row.0.step_set.count %}{{ row.0.step_set.count }} Steps{%
> endif %}
> {% endwith_html %}
> {% with item_title=row.0.title item_description=row.0.description
> item_image=row.0.image item_extra=extra item_link=row.0.link
> item_button=newsletter.recipe_button %}
>   {% include "newsletter/email_full.html" %}
> {% endwith %}


This type of tag would help keep the code more DRY in my opinion since the
rendering logic for the complex content doesn't need extra files and I can
now make includes more generic.  It would be a great compliment to the
already existing with tag.

-- 
- Paul Kenjora
- 602-214-7285

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


Completed form for an authenticated user

2016-04-27 Thread Said Akhmedbayev
Let's say, for example, I have a reusable form. An authenticated user fills 
out this form and saves it. How then, I can show to the user a page with 
the complete form?

Sorry, for not being able to explain the question clearly, I am new to 
django and to the web development in general.

-- 
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/4165af84-44ec-4494-8613-8396cc6d2e0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Test runner wants to run models package?!

2016-04-27 Thread Torsten Bronger
Hallöchen!

Tim Graham writes:

> Could you try Python 3.4.x?

The problem does not exist with Python 3.4.3.  (Ubuntu 14.04)

> I ran into some issues with Django's own test suite [0] due to
> some import changes in Python 3.5 [1].

If I look at Python 3.5's release notes, the following is
suspicious:

Found packages are now checked for load_tests regardless of
whether their path matches pattern, because it is impossible for
a package name to match the default pattern.

I understand this this way: The pattern still works for .py files
but not for packages (__init__.py files).  And since my models'
__init__.py says

from .physical_processes import *

and the app is not yet set up, this breaks.


Question is: Is is bad style to have a models *package* which
collects alls models in its __init__.py, or has Django to be adapted
to Python's new behaviour?

Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de

-- 
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/87potbc87j.fsf%40physik.rwth-aachen.de.
For more options, visit https://groups.google.com/d/optout.


Re: Using django login functionality in a non django app

2016-04-27 Thread Avraham Serour
You can just use the session id, call it a token instead of cookie and be
happy

On Wed, Apr 27, 2016, 6:53 PM Gergely Polonkai  wrote:

> I would create a separate view for this, like /falcon_login/, which could
> give you a plain text result. But that’s totally up to you.
>
>
>
> Gergely Polonkai
> [image: https://]about.me/gergely.polonkai
>
> 
>
> 2016-04-27 16:57 GMT+02:00 Larry Martell :
>
>> Well, not really. I have managed to invoke my django login screen from
>> my Qt app, but after I log in, of course my django app comes up.
>>
>> What I would like is to pass in some parameter to the login screen
>> (which is easy), and then have my django app detect that and after
>> successfully or unsuccessfully logging in, return a token or error
>> code to the Qt app and not bring up the django app. But I'm not sure
>> how to do that.
>>
>> On Tue, Apr 26, 2016 at 9:27 AM, Gergely Polonkai 
>> wrote:
>> >
>> > That means you have to be able to do it via the API. The other solution
>> is to pop up a web view for these tasks. However, we are moving out from
>> Django field here, as this is getting more and more a falcon/UX-related
>> question.
>> >
>> >
>> > Gergely Polonkai
>> > about.me/gergely.polonkai
>> >
>> > 2016-04-26 14:19 GMT+02:00 Larry Martell :
>> >>
>> >> I need to support create user, change password, delete user and forgot
>> password.
>> >>
>> >> On Tue, Apr 26, 2016 at 7:32 AM, Gergely Polonkai 
>> wrote:
>> >> >
>> >> >
>> >> > That’s not a big issue if you really communicate with Django via a
>> web-based API. If the user can’t log in, you can simply redirect them to a
>> web page. I don’t see the need for user admin functions, though.
>> >> >
>> >> >
>> >> > Gergely Polonkai
>> >> > about.me/gergely.polonkai
>> >> >
>> >> > 2016-04-26 13:10 GMT+02:00 Larry Martell :
>> >> >>
>> >> >> Well, the issue with simply implementing auth, is that we'd need to
>> >> >> not only implement login, which is easy, but also forgot password,
>> and
>> >> >> all the user admin functions. Since we have that already with
>> django I
>> >> >> want to leverage that and not reinvent the wheel.
>> >> >>
>> >> >> On Tue, Apr 26, 2016 at 2:29 AM, Gergely Polonkai <
>> gerg...@polonkai.eu> wrote:
>> >> >> > Now I somewhat understand what falcon is, I suggest that you
>> simply
>> >> >> > implement auth on you web app (it seems to me there is none or
>> little right
>> >> >> > now. Of course, you don't have to protect all iour views, or you
>> may want to
>> >> >> > display a different dataset, but that's another topic.
>> >> >> >
>> >> >> > When that is done, you have to do two things in your Qt app.
>> First, make
>> >> >> > sure that when the server says that you are not authorized, pop
>> up a login
>> >> >> > window. After a successful login, store the user's credentials
>> for later
>> >> >> > use. What type of authentication to use and what to store is up
>> to your
>> >> >> > decision: HTTP Basic (store user/password), HTTP session (store
>> the session
>> >> >> > cookie) or token (store the token) based auths are the most
>> common examples.
>> >> >> >
>> >> >> > Best,
>> >> >> > Gergely
>> >> >> >
>> >> >> > On Apr 26, 2016 00:09, "Larry Martell" 
>> wrote:
>> >> >> >>
>> >> >> >> The Qt app talks to the server with web requests routed to
>> python code
>> >> >> >> by falcon. It currently has no authentication/authorization of
>> any
>> >> >> >> kind. It's not a web app, you can't just navigate to any page,
>> you can
>> >> >> >> only get to parts of the app the code lets you get to.
>> >> >> >>
>> >> >> >> The way I envision it (if possible) is that I would have a
>> decorator
>> >> >> >> just like @login_required, and if that is called and the user is
>> not
>> >> >> >> logged in, it would invoke the django login page - just like it
>> works
>> >> >> >> in django. I think I can do most of this, the part I am unclear
>> on is
>> >> >> >> how I get control from the django login page back to the Qt app.
>> >> >> >>
>> >> >> >> On Mon, Apr 25, 2016 at 5:26 PM, Gergely Polonkai <
>> gerg...@polonkai.eu>
>> >> >> >> wrote:
>> >> >> >> > Hello,
>> >> >> >> >
>> >> >> >> > this all depends on how this Qt app communicates with the
>> other end
>> >> >> >> > (server
>> >> >> >> > side). Does it offer *any* kind of
>> authentication/authorization? If so,
>> >> >> >> > look
>> >> >> >> > for ways to integrate it with Django. If not, you are screwed
>> anyway
>> >> >> >> > (from
>> >> >> >> > security point of view), because even if your app pops up a
>> login
>> >> >> >> > screen,
>> >> >> >> > there can (and will) be ways to get around it.
>> >> >> >> >
>> >> >> >> > Best,
>> >> >> >> > Gergely
>> >> >> >> >
>> >> >> >> > On Apr 25, 2016 22:37, 

Re: Using django login functionality in a non django app

2016-04-27 Thread Gergely Polonkai
I would create a separate view for this, like /falcon_login/, which could
give you a plain text result. But that’s totally up to you.



Gergely Polonkai
[image: https://]about.me/gergely.polonkai


2016-04-27 16:57 GMT+02:00 Larry Martell :

> Well, not really. I have managed to invoke my django login screen from
> my Qt app, but after I log in, of course my django app comes up.
>
> What I would like is to pass in some parameter to the login screen
> (which is easy), and then have my django app detect that and after
> successfully or unsuccessfully logging in, return a token or error
> code to the Qt app and not bring up the django app. But I'm not sure
> how to do that.
>
> On Tue, Apr 26, 2016 at 9:27 AM, Gergely Polonkai 
> wrote:
> >
> > That means you have to be able to do it via the API. The other solution
> is to pop up a web view for these tasks. However, we are moving out from
> Django field here, as this is getting more and more a falcon/UX-related
> question.
> >
> >
> > Gergely Polonkai
> > about.me/gergely.polonkai
> >
> > 2016-04-26 14:19 GMT+02:00 Larry Martell :
> >>
> >> I need to support create user, change password, delete user and forgot
> password.
> >>
> >> On Tue, Apr 26, 2016 at 7:32 AM, Gergely Polonkai 
> wrote:
> >> >
> >> >
> >> > That’s not a big issue if you really communicate with Django via a
> web-based API. If the user can’t log in, you can simply redirect them to a
> web page. I don’t see the need for user admin functions, though.
> >> >
> >> >
> >> > Gergely Polonkai
> >> > about.me/gergely.polonkai
> >> >
> >> > 2016-04-26 13:10 GMT+02:00 Larry Martell :
> >> >>
> >> >> Well, the issue with simply implementing auth, is that we'd need to
> >> >> not only implement login, which is easy, but also forgot password,
> and
> >> >> all the user admin functions. Since we have that already with django
> I
> >> >> want to leverage that and not reinvent the wheel.
> >> >>
> >> >> On Tue, Apr 26, 2016 at 2:29 AM, Gergely Polonkai <
> gerg...@polonkai.eu> wrote:
> >> >> > Now I somewhat understand what falcon is, I suggest that you simply
> >> >> > implement auth on you web app (it seems to me there is none or
> little right
> >> >> > now. Of course, you don't have to protect all iour views, or you
> may want to
> >> >> > display a different dataset, but that's another topic.
> >> >> >
> >> >> > When that is done, you have to do two things in your Qt app.
> First, make
> >> >> > sure that when the server says that you are not authorized, pop up
> a login
> >> >> > window. After a successful login, store the user's credentials for
> later
> >> >> > use. What type of authentication to use and what to store is up to
> your
> >> >> > decision: HTTP Basic (store user/password), HTTP session (store
> the session
> >> >> > cookie) or token (store the token) based auths are the most common
> examples.
> >> >> >
> >> >> > Best,
> >> >> > Gergely
> >> >> >
> >> >> > On Apr 26, 2016 00:09, "Larry Martell" 
> wrote:
> >> >> >>
> >> >> >> The Qt app talks to the server with web requests routed to python
> code
> >> >> >> by falcon. It currently has no authentication/authorization of any
> >> >> >> kind. It's not a web app, you can't just navigate to any page,
> you can
> >> >> >> only get to parts of the app the code lets you get to.
> >> >> >>
> >> >> >> The way I envision it (if possible) is that I would have a
> decorator
> >> >> >> just like @login_required, and if that is called and the user is
> not
> >> >> >> logged in, it would invoke the django login page - just like it
> works
> >> >> >> in django. I think I can do most of this, the part I am unclear
> on is
> >> >> >> how I get control from the django login page back to the Qt app.
> >> >> >>
> >> >> >> On Mon, Apr 25, 2016 at 5:26 PM, Gergely Polonkai <
> gerg...@polonkai.eu>
> >> >> >> wrote:
> >> >> >> > Hello,
> >> >> >> >
> >> >> >> > this all depends on how this Qt app communicates with the other
> end
> >> >> >> > (server
> >> >> >> > side). Does it offer *any* kind of
> authentication/authorization? If so,
> >> >> >> > look
> >> >> >> > for ways to integrate it with Django. If not, you are screwed
> anyway
> >> >> >> > (from
> >> >> >> > security point of view), because even if your app pops up a
> login
> >> >> >> > screen,
> >> >> >> > there can (and will) be ways to get around it.
> >> >> >> >
> >> >> >> > Best,
> >> >> >> > Gergely
> >> >> >> >
> >> >> >> > On Apr 25, 2016 22:37, "Larry Martell" 
> wrote:
> >> >> >> >>
> >> >> >> >> We have an existing django app with login, change password,
> and forgot
> >> >> >> >> password functionality.
> >> >> >> >>
> >> >> >> >> Then we have this other app built with the falcon framework.
> The
> >> >> >> >> 

Re: Using django login functionality in a non django app

2016-04-27 Thread Larry Martell
Well, not really. I have managed to invoke my django login screen from
my Qt app, but after I log in, of course my django app comes up.

What I would like is to pass in some parameter to the login screen
(which is easy), and then have my django app detect that and after
successfully or unsuccessfully logging in, return a token or error
code to the Qt app and not bring up the django app. But I'm not sure
how to do that.

On Tue, Apr 26, 2016 at 9:27 AM, Gergely Polonkai  wrote:
>
> That means you have to be able to do it via the API. The other solution is to 
> pop up a web view for these tasks. However, we are moving out from Django 
> field here, as this is getting more and more a falcon/UX-related question.
>
>
> Gergely Polonkai
> about.me/gergely.polonkai
>
> 2016-04-26 14:19 GMT+02:00 Larry Martell :
>>
>> I need to support create user, change password, delete user and forgot 
>> password.
>>
>> On Tue, Apr 26, 2016 at 7:32 AM, Gergely Polonkai  
>> wrote:
>> >
>> >
>> > That’s not a big issue if you really communicate with Django via a 
>> > web-based API. If the user can’t log in, you can simply redirect them to a 
>> > web page. I don’t see the need for user admin functions, though.
>> >
>> >
>> > Gergely Polonkai
>> > about.me/gergely.polonkai
>> >
>> > 2016-04-26 13:10 GMT+02:00 Larry Martell :
>> >>
>> >> Well, the issue with simply implementing auth, is that we'd need to
>> >> not only implement login, which is easy, but also forgot password, and
>> >> all the user admin functions. Since we have that already with django I
>> >> want to leverage that and not reinvent the wheel.
>> >>
>> >> On Tue, Apr 26, 2016 at 2:29 AM, Gergely Polonkai  
>> >> wrote:
>> >> > Now I somewhat understand what falcon is, I suggest that you simply
>> >> > implement auth on you web app (it seems to me there is none or little 
>> >> > right
>> >> > now. Of course, you don't have to protect all iour views, or you may 
>> >> > want to
>> >> > display a different dataset, but that's another topic.
>> >> >
>> >> > When that is done, you have to do two things in your Qt app. First, make
>> >> > sure that when the server says that you are not authorized, pop up a 
>> >> > login
>> >> > window. After a successful login, store the user's credentials for later
>> >> > use. What type of authentication to use and what to store is up to your
>> >> > decision: HTTP Basic (store user/password), HTTP session (store the 
>> >> > session
>> >> > cookie) or token (store the token) based auths are the most common 
>> >> > examples.
>> >> >
>> >> > Best,
>> >> > Gergely
>> >> >
>> >> > On Apr 26, 2016 00:09, "Larry Martell"  wrote:
>> >> >>
>> >> >> The Qt app talks to the server with web requests routed to python code
>> >> >> by falcon. It currently has no authentication/authorization of any
>> >> >> kind. It's not a web app, you can't just navigate to any page, you can
>> >> >> only get to parts of the app the code lets you get to.
>> >> >>
>> >> >> The way I envision it (if possible) is that I would have a decorator
>> >> >> just like @login_required, and if that is called and the user is not
>> >> >> logged in, it would invoke the django login page - just like it works
>> >> >> in django. I think I can do most of this, the part I am unclear on is
>> >> >> how I get control from the django login page back to the Qt app.
>> >> >>
>> >> >> On Mon, Apr 25, 2016 at 5:26 PM, Gergely Polonkai 
>> >> >> wrote:
>> >> >> > Hello,
>> >> >> >
>> >> >> > this all depends on how this Qt app communicates with the other end
>> >> >> > (server
>> >> >> > side). Does it offer *any* kind of authentication/authorization? If 
>> >> >> > so,
>> >> >> > look
>> >> >> > for ways to integrate it with Django. If not, you are screwed anyway
>> >> >> > (from
>> >> >> > security point of view), because even if your app pops up a login
>> >> >> > screen,
>> >> >> > there can (and will) be ways to get around it.
>> >> >> >
>> >> >> > Best,
>> >> >> > Gergely
>> >> >> >
>> >> >> > On Apr 25, 2016 22:37, "Larry Martell"  
>> >> >> > wrote:
>> >> >> >>
>> >> >> >> We have an existing django app with login, change password, and 
>> >> >> >> forgot
>> >> >> >> password functionality.
>> >> >> >>
>> >> >> >> Then we have this other app built with the falcon framework. The
>> >> >> >> client side of that is C++/Qt. That app has no login functionality -
>> >> >> >> you bring it up and you're in. We would like to somehow use the 
>> >> >> >> login
>> >> >> >> functionality of the django app in the falcon app. Is that even
>> >> >> >> possible? I was thinking that in the Qt app I could bring up the
>> >> >> >> django login page by invoking the URL for that app. But once they 
>> >> >> >> log
>> >> >> >> in, how could I get control back to the Qt app and not have it 
>> >> >> >> proceed
>> 

Re: run Parent __init__

2016-04-27 Thread Григор Колев
I create menu in class A 
I create html tables with column and row

In class B i must change only get method.

сряда, 27 април 2016 г., 17:22:59 UTC+3, Vijay Khemlani написа:
>
> Class B shouldn't extend View, A already does
>
> It doesn't make a lot of sense to call the constructor again (__init__) 
> from another method (get)
>
> On Wed, Apr 27, 2016 at 11:18 AM, Григор Колев  > wrote:
>
>> Where is the problem in this code.
>>
>> class A (View):
>>
>> def __init__(self):
>> self.data = ['1', '2']
>> 
>> def get(self, request):
>> pass
>>
>> class B (View, A):
>> 
>> def get(self, request):
>> A.__init__(self)
>>
>>
>> -- 
>> 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/5e7761c3-3543-43f0-8630-26548937622a%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/623d2d77-27ac-460b-af3d-e1d4930894cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: (Newbie) Stuck with annotate() docs

2016-04-27 Thread Ankush Thakur
I'm not sure how Book.objects.first().chapters is different 
from Book.objects.first().chapters.count(), but the point is that 
"chapters" is not defined in the models at the top of that page! The 
snippet makes sense if I treat Book.chapters as another ManyToManyField 
(like authors), but it's really weird to see that error in the docs. So, 
does that mean I can report it? If yes, to who?

On Wednesday, April 27, 2016 at 4:36:40 AM UTC+5:30, Tim Graham wrote:
>
> Looks like a typo. Does the rest of the example make sense and work if 
> that line is changed to "Book.objects.first().chapters"?
>
> On Tuesday, April 26, 2016 at 12:50:31 PM UTC-4, Ankush Thakur wrote:
>>
>> Folks, I'm having exceptional trouble understanding annotate(), 
>> aggregate(), and their various combinations. I'm currently stuck here: 
>> https://docs.djangoproject.com/en/1.9/topics/db/aggregation/#combining-multiple-aggregations
>>
>> The example here uses Book.objects.first().chapters.count(), but there's 
>> no chapters model or field at the start of the tutorial. It's frustrating, 
>> to say the least. Even if I set up a separate application to test this 
>> myself, what do I make of "chapters"? Is it another model with many-to-many 
>> relation with Book? When I ran an example with the following models:
>>
>> class Author(models.Model):
>> name = models.CharField(max_length=100)
>> age = models.IntegerField()
>>
>> class Book(models.Model):
>> name = models.CharField(max_length=300)
>> chapters = models.IntegerField()
>> authors = models.ManyToManyField(Author)
>>
>> I got: 
>>
>> >>> Book.objects.first().chapters.count()
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> AttributeError: 'int' object has no attribute 'count'
>> >>> 
>>
>> So basically, I feel like I'm screwed. Please help.
>>
>

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


Re: run Parent __init__

2016-04-27 Thread Vijay Khemlani
Class B shouldn't extend View, A already does

It doesn't make a lot of sense to call the constructor again (__init__)
from another method (get)

On Wed, Apr 27, 2016 at 11:18 AM, Григор Колев 
wrote:

> Where is the problem in this code.
>
> class A (View):
>
> def __init__(self):
> self.data = ['1', '2']
>
> def get(self, request):
> pass
>
> class B (View, A):
>
> def get(self, request):
> A.__init__(self)
>
>
> --
> 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/5e7761c3-3543-43f0-8630-26548937622a%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/CALn3ei3aYJa7c%3DhFCEGAE0a0jVDnU7gBniWC0yKHtp5s6F8oRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


run Parent __init__

2016-04-27 Thread Григор Колев
Where is the problem in this code.

class A (View):

def __init__(self):
self.data = ['1', '2']

def get(self, request):
pass

class B (View, A):

def get(self, request):
A.__init__(self)


-- 
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/5e7761c3-3543-43f0-8630-26548937622a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Accept the json request.

2016-04-27 Thread 1175190234
I was wondering if there is any method to the handle the *json* request in 
an easy and simple way.
For examle ( in flask ):
names = request.json['names'] 
But in django, I will use: 
import json
text = request.read()
names =json.loads(text)['names']
Is there any way better?

-- 
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/80c04b70-68a8-4faf-884e-7f8631b046e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


regarding Session ID and cookie validation

2016-04-27 Thread Samarjeet Singh
Hi All,

Your input is very much valuable ,kindly help me out regarding this. 

I need to have a CSDL compliance for following for a project using django 
framwork :-
But my main concern here is how does django framework validates the session 
id and cookie and is
it defalut in all the frameworks.I have seen the API (like signed and 
unsugned) also but how to ensure that my framework is doing
these checks:-
1. When cookies are used to carry authentication tokens or session IDs 
within a web application, and multiple such cookies are present, the django 
verify all such cookies before granting access to the user session. 
2. All conflicting cookies are treated as invalid by django.

3. If validation of any such cookie fails, the cookie treated as if it 
didn't exist, and the event is added to the audit log or not by django.

4. In django after validation of all such cookies, permission are evaluated 
based on the cookies for which validation succeeded.

5. Cleartext Storage of Sensitive Information in a Cookie:info may be 
stored in plane of coded form and how much difficult it is to decode. 
6. Information Exposure Through Persistent Cookies:How many old or unused 
cookie are stored and persist in the system 
7. Reliance on Cookies without Validation and Integrity Checking:- Is it 
doing the signing and unsigningalways for the integrity check and is this 
only been done by the default django frame work.

8. Sensitive Cookie in HTTPS Session Without 'Secure' Attribute : if it is 
OFF or ON and in which circumstaces this should be ON.

9. Session IDs are fully validated before they may be used:how is session 
Id validated in django and the API used for it and how can i check in my 
framework.
 

regards 
samarjeet singh

-- 
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/1ad806f5-73d8-4389-866d-de3e884f4415%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Regarding django session handling:- cookie and session ID

2016-04-27 Thread Samarjeet Singh
While doing CSDL compliance i need to know that does django framework give 
following feature and if it does which are the API for the same.


1. When cookies are used to carry authentication tokens or session IDs 
within a web application, and multiple such cookies are present, does 
django verify all such cookies before granting access to the user session. 

2. in django does All conflicting cookies are treated as invalid. 

3. If validation of any such cookie fails, is it treated as if it didn't 
exist, and does this thing gets logged  and get added to the audit log. 

4. After validation of all such cookies, does django gives permissions 
evaluated based on the   cookies for which validation succeeded. 

5. Cleartext Storage of Sensitive Information in a Cookie:- does it stores 
the data in cookie in plain form or in other form can that form be easily 
decoded.  

6. Information Exposure Through Persistent Cookies -does it keeps the 
cookie in the db always or the unused or old cookie are deleted. 

7. Reliance on Cookies without Validation and Integrity Checking:-redundent 
(does it rely on cookie without the validation check) 

8. Sensitive Cookie in HTTPS Session Without 'Secure' Attribute- the cookie 
which are send in https session with secure attribute not set do they go in 
plain format.  

9. Session Id is fully validated before they may be used:-validation of 
session id is done in case of djanago  

10. When using session ID to keep authentication state and track user 
progress within a web application, the django application treat the session 
ID as untrusted data, and sanitize and validate it before use. 

-- 
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/7f09d3cd-d6e2-4f87-8b41-c9fe19257755%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New to Django (stuck at the end of the tutorial)

2016-04-27 Thread Nikhil Beniwal
You can define it like :-

url(r'^$', 'apps_name.views.home', name='home'),


On Wednesday, April 27, 2016 at 6:28:38 AM UTC+5:30, Cronos Cto wrote:
>
> Could you give me an example or so Vijay Khemali?
>

-- 
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/a96c20ac-cb8f-4b0e-ab47-2431ae981970%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with defining Models for ManyToMany and OneToMany relationships...

2016-04-27 Thread Mike Dewhirst

On 26/04/2016 9:41 PM, Bruce Whealton wrote:

Mike,
         So, I tried your idea for reorganizing the models, and
just removed Organization and instead setup
ContactOrOrganization as a class. Â
It seemed to work ok, in terms of migrating fine. Â However, the
database now lacks a ContactsOrOrganizationÂ
table. Â
Oops, my mistake, it does have a table now for that model. Â I wonder if
I need a ForeignKey field in the ContactsOrOrganization table?


Bruce

I thought I'd better try it myself and this models.py in an app called 
"contact" works for me. I'm using Python 3.4 and Django 1.8.12 on 
Windows 8.1 with Postgres 9.3 on localhost.


Because I kept doing typos I changed that ridiculously long name to 
Entity. Also, mindful of your requirement to have different types of 
entities namely people and organisations, I did a a Role model to carry 
that information. In fact I could have done a choices= attribute on 
Entity but I might use this myself and I would prefer the 1:n approach 
because an entity could be more than just one sort of entity.


Anyway, once the initial migration for the following models.py is run 
and the tables exist it is easy to flesh out any of the models with more 
fields and/or other related tables and rely on migrate to roll out the 
changes.


from django.db import models

class Role(models.Model):

name = models.CharField(max_length=32)

class Meta:
verbose_name = 'Entity type'
verbose_name_plural = 'Entity types'

def __str__(self):
return "{0}".format(self.name)


class Entity(models.Model):

connections = models.ManyToManyField("self",
blank=True,
symmetrical=False,
through="Entity_Connections")

role = models.ForeignKey("role")

name = models.CharField(max_length=128)

comment = models.TextField(null=True, blank=True)

class Meta:
verbose_name = 'Entity'
verbose_name_plural = 'Entities'

def __str__(self):
return "{0} {{1})".format(self.name, self.role)

class Entity_Connections(models.Model):

from_entity = models.ForeignKey("entity",
related_name="from_entity")

to_entity = models.ForeignKey("entity", blank=True,
related_name="to_entity")

class Meta:
verbose_name = 'Connection'
verbose_name_plural = 'Connnections'


Good luck

Mike



Bruce


Anyway, I will try to remove the ManyToMany statement from the
Connections Model. Â
I would then have one Contact or Organization maps to many Connection
types. Â

On Sunday, April 24, 2016 at 1:13:16 AM UTC-4, Mike Dewhirst wrote:


I think you should rethink your Contact and Organization classes and
see
if you can eliminate one or the other. A single table for both would
simplify the problem because the Connection class can implement as many
connections as you like.

For example ...

class ContactOrOrganization(etc):
     various detail fields ...

class Connection(etc):
     organization = ForeignKey("ContactOrOrganization",
         related_name="organization")
     contact = ForeignKey("ContactOrOrganization",
         related_name="contact")

Just because I used related_name that way means nothing. You can
connect
contacts together or organizations together. Also, you can add other
fields to Connection with which to describe the relationship.

Mike

> I wanted to use the Organization as a foreign key on the Contact
model.
> Â I could have more than one contact from
> an Organization. Â The Connection model is inspired by the Google
Plus
> idea of "Circles" - e.g. friends,
> family, following, etc. Â  So, this would be a many-to-many
relationship. Â
>
> My problems are (1) I cannot create connections without specifying a
> contact. Â
> (2) If I was adding a contact using the admin interface, how do I
allow
> no value for that foreign field
> or allow for some kind of ajax type of text completion? Â If a
person is
> family or friend, I may not need
> to list an Organization for them.
> (3) I would like to support multiple connection types - e.g.
following,
> employer, etc.
>
> So, here is my apps models.py file:
> Â 
>
> from django.db import models
>
>

--
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