Re: Using the URLconf defined in polls.urls, Django tried these URL patterns, in this order

2018-10-22 Thread Manjunath
Your project urls are set to address starting with admin & polls.

You can browse *localhost:8000/polls/*

On Monday, October 22, 2018 at 11:06:22 PM UTC+5:30, Bugs Bunny wrote:
>
> Regards for the answers this is my input
>
> On Sun, Oct 21, 2018 at 8:15 AM Motaz Hejaze  > wrote:
>
>> first , no spaces are allowed in URLS
>> as  Manjunath said
>> replace path(' ', views.index, name='index') with path('', views.index, 
>> name='index') in your polls/urls.py and check the result.
>>
>> second , run the server 
>> python manage.py runserver 
>>
>> third check the url
>> go to http://127.0.0.1:8000/polls
>>
>> On Sun, Oct 21, 2018 at 1:56 PM Manjunath > > wrote:
>>
>>> I think you have a space in your url path.
>>>
>>> replace path(' ', views.index, name='index') with path('', views.index, 
>>> name='index') in your polls/urls.py and check the result.
>>>
>>> On Friday, October 19, 2018 at 4:59:10 PM UTC+5:30, Bugs Bunny wrote:

 Greetings django team, I'm a newbie with this framework but I have 
 experience with python, I did the first tutorial and it throws me a 404 
 error, I saw that in the previous versions we used a r'formated 'string 
 and 
 indicated the beginning ^ and the end $ but in version 2.1 is no 
 longer used, check and I do not know where the error comes from, I will 
 leave some captures, the IRC room is down I hope answers from this 
 wonderful community

 tuto/urls.py
  from django.contrib import admin
  from django.urls import include, path

  urlpatterns = [
  path('polls/', include('polls.urls')),
  path('admin/', admin.site.urls),
  ]





 polls/urls.py
 from django.urls import path
 from . import views

 urlpatterns = [
  path(' ', views.index, name='index'),
  ]

 polls/views.py
 from django.shortcuts import render
 from django.http import HttpResponse as HR
 # Create your views here.

 def index(request):
return HR("hola estas en el index de polls")
  

 mi internet its very laggy

>>> -- 
>>> 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/8b8d005c-e2c1-4399-9bd8-9deb1cdea9f8%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...@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/CAHV4E-cjH_Zc645Hj13201Z8Fme%2BBevfqA5oie5Gnz9ZN%3DGt%3DA%40mail.gmail.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/a0e99f7d-50af-41a8-a3c2-c648641aee14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django auto-deletes field related to MySQL Transactions

2018-10-22 Thread RyanW
I have a Django site I'm developing, which I've connected to a MySQL db.  I 
haven't deployed into production yet, as I'm still working on a couple of 
things, however I leave the server running in development for initial data 
entry. 

I've noticed that some of the records already inputted gets deleted, 
seemingly randomly. I enabled logging on MySQL and found logs like the 
following:

6798 Connect
rya...@cobb.eyes.uab.edu on downswebdb2
6798 Query
SET NAMES utf8
6798 Query
set autocommit=0
6798 Query
set autocommit=1
6798 Query
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
6798 Query
SELECT `Epe_epe`.`id`, `Epe_epe`.`epe_type`, `Epe_epe`.`epe_type2_id`, 
`Epe_epe`.`epe_date`, `Epe_epe`.`epe_ani`, `Epe_epe`.`epe_ani2_id`, 
`Epe_epe`.`epe_apn`, `Epe_epe`.`epe_apn2_id`, `Epe_epe`.`epe_weight`, 
`Epe_epe`.`epe_drug_type1`, `Epe_epe`.`epe_drug1`, `Epe_epe`.`epe_dose1`, 
`Epe_epe`.`epe_amount1`, `Epe_epe`.`epe_route1`, `Epe_epe`.`epe_time1`, 
`Epe_epe`.`epe_drug_type2`, `Epe_epe`.`epe_drug2`, `Epe_epe`.`epe_dose2`, 
`Epe_epe`.`epe_amount2`, `Epe_epe`.`epe_route2`, `Epe_epe`.`epe_time2`, 
`Epe_epe`.`epe_drug_type3`, `Epe_epe`.`epe_drug3`, `Epe_epe`.`epe_dose3`, 
`Epe_epe`.`epe_amount3`, `Epe_epe`.`epe_route3`, `Epe_epe`.`epe_time3`, 
`Epe_epe`.`epe_drug_type4`, `Epe_epe`.`epe_drug4`, `Epe_epe`.`epe_dose4`, 
`Epe_epe`.`epe_amount4`, `Epe_epe`.`epe_route4`, `Epe_epe`.`epe_time4`, 
`Epe_epe`.`epe_drug_type5`, `Epe_epe`.`epe_drug5`, `Epe_epe`.`epe_dose5`, 
`Epe_epe`.`epe_amount5`, `Epe_epe`.`epe_route5`, `Epe_epe`.`epe_time5`, 
`Epe_epe`.`epe_drug_type6`, `Epe_epe`.`epe_drug6`, `Epe_epe`.`epe_dose6`, 
`Epe_epe`.`epe_amount6`, `Epe_epe`.`epe_route6`, `Epe_epe`.`epe_time6`, 
`Epe_epe`.`epe_iso_start`, `Epe_epe`.`epe_iso_end`, `Epe_epe`.`epe_o2_end`, 
`Epe_epe`.`epe_start1`, `Epe_epe`.`epe_start2`, `Epe_epe`.`epe_start3`, 
`Epe_epe`.`epe_start4`, `Epe_epe`.`epe_start5`, `Epe_epe`.`epe_start6`, 
`Epe_epe`.`epe_start7`, `Epe_epe`.`epe_start8`, `Epe_epe`.`epe_hr1`, 
`Epe_epe`.`epe_hr2`, `Epe_epe`.`epe_hr3`, `Epe_epe`.`epe_hr4`, `Epe_epe`.
`epe_hr5`, `Epe_epe`.`epe_hr6`, `Epe_epe`.`epe_hr7`, `Epe_epe`.`epe_hr8`, 
`Epe_epe`.`epe_spo2_1`, `Epe_epe`.`epe_spo2_2`, `Epe_epe`.`epe_spo2_3`, 
`Epe_epe`.`epe_spo2_4`, `Epe_epe`.`epe_spo2_5`, `Epe_epe`.`epe_spo2_6`, 
`Epe_epe`.`epe_spo2_7`, `Epe_epe`.`epe_spo2_8`, `Epe_epe`.`epe_temp1`, 
`Epe_epe`.`epe_temp2`, `Epe_epe`.`epe_temp3`, `Epe_epe`.`epe_temp4`, 
`Epe_epe`.`epe_temp5`, `Epe_epe`.`epe_temp6`, `Epe_epe`.`epe_temp7`, 
`Epe_epe`.`epe_temp8`, `Epe_epe`.`epe_etco2_1`, `Epe_epe`.`epe_etco2_2`, 
`Epe_epe`.`epe_etco2_3`, `Epe_epe`.`epe_etco2_4`, `Epe_epe`.`epe_etco2_5`, 
`Epe_epe`.`epe_etco2_6`, `Epe_epe`.`epe_etco2_7`, `Epe_epe`.`epe_etco2_8`, 
`Epe_epe`.`epe_rr1`, `Epe_epe`.`epe_rr2`, `Epe_epe`.`epe_rr3`, `Epe_epe`.
`epe_rr4`, `Epe_epe`.`epe_rr5`, `Epe_epe`.`epe_rr6`, `Epe_epe`.`epe_rr7`, 
`Epe_epe`.`epe_rr8`, `Epe_epe`.`epe_comment` FROM `Epe_epe` WHERE `Epe_epe`.
`id` = 1508
6798 Query
set autocommit=0
6798 Query
DELETE FROM `Epe_epe` WHERE `Epe_epe`.`id` IN (1508)
6798 Query
commit
6798 Query
set autocommit=1
6798 Quit
Where Epe_epe is from a model called Epe in my Django app. 

As far as I know, no user is performing delete commands on these records, 
so can I assume Django is performing these deletes in the background?  What 
would a trigger possibly be for these deletes?

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+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/91c6af18-cdf0-45f4-9f1c-e865c7128334%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Doc on deploying production website using django

2018-10-22 Thread ah
Hi,
Is there a detailed comprehensive documentation on how to deploy a 
production website using django with different options like Gunicorn or 
uWSGI with servers like nginx or apache and dB postgres. 
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/ab4465ae-2bda-4996-a9fc-6f7e620c408d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Meeting scheduling package

2018-10-22 Thread Am Stat
Hi there,

I'd like to to create a meeting scheduling web app so users can send a 
private meeting invitation to other users, recipients can either accept or 
reject a meeting invite. Originator can edit or cancel the meeting after it 
was accepted, etc., some basic functions. 

I don't want to reinvent the wheel, any recommendations on django libraries 
or packages I can use?

Thanks very much in advance!
Leon

-- 
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/1900fa32-0b1c-4720-9170-d9141413df4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trigger actions independently of url request

2018-10-22 Thread Charley Paulus
Hi Andrew,

Thank you for your answer.

To better clarify my need, here is one use case:
1) I would like my server (where Django is) to ping a remote address (let's 
say google.com) every 10 minutes, and put the result (communication ok or 
not) in a Django-generated database.
2) Then I will have a Django view that displays some statistics based on 
this database records. No worries for this point. My question is strictly 
on point 1.

So what I need is my server itself to run code on a regular basis.
Can I simply start a thread in manage.py, like here: 
https://eldarion.com/blog/2013/02/14/entry-point-hook-django-projects/ ?

It seems that Celery and AWS Lambda are external tools that can remotely 
call my Django API.

I hope the example helps.

Thanks again.

Best regards,
Charley


On Monday, October 22, 2018 at 1:10:52 PM UTC-4, Andrew Pinkham wrote:
>
> On Oct 22, 2018, at 12:08, Charley Paulus  > wrote: 
> > After reading the Django tutorial, my understanding (I hope I’m wrong) 
> is that the only way to trigger a function of a Django app is when someone 
> on the client side request the url related to that function. 
>
> That is correct. A view function/object is only called when a site visitor 
> is routed to that callable by the URL configuration. 
>
> > But what if I want the server to run a function indenpendently of a url 
> call, for example: 
> > - every 10 minutes 
> > - when a pre-defined combination of variables become true 
>
> I'm not clear on your second condition, but you are probably interested in 
> Celery for the first. 
>
> http://www.celeryproject.org/ 
> 
>  
>
> Alternatively, some clouds provide the ability to run code on a regular 
> basis. If your Django code is not closely coupled with cron job, you could 
> use AWS Lambda. 
>
> https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html 
>
> If it is tightly coupled and Celery is too powerful for your needs, you 
> could use an AWS Lambda (or Azure Function, etc) to send a request to your 
> Django API on a regular basis. 
>
> Andrew 
> https://jambonsw.com 
> https://django-unleashed.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/73e3ded5-45be-4185-95e5-968ef803c75b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django dynamic form class creation at runtime

2018-10-22 Thread RONAK JAIN
You can create Model and configure admin then you will get your way.

-- 
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/CA%2BAqMUcyg0VP44xEh%2Bwh4%2BExWDgojTP%2B-k%3Dx7-DAHyUUiP_XQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: Creating seperate unique ids within the same table

2018-10-22 Thread Matthew Pava
Very fascinating.
There is a remark from Eric Sheridan, though, that discusses this:
"I think that anytime database primary keys are exposed, an access control rule 
is required. There is no way to practically DOR all database primary keys in a 
real enterprise or post-enterprise system."
The articles very much suggest that it is the developer's responsibility to 
implement access control rules on objects.  In Django and my projects, that's 
done through the authentication system, sessions, and requiring login 
credentials.  As such, I'm not worried about exposing PKs in URLs.

Saying that, if Django really wants to discourage PKs in URLs, it needs to 
remove the  kwarg to be used in URLs, and as you mentioned, the tutorials 
need to be updated.

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Andrew Pinkham
Sent: Monday, October 22, 2018 11:51 AM
To: django-users@googlegroups.com
Subject: Re: Creating seperate unique ids within the same table

On Oct 22, 2018, at 12:29, Matthew Pava  wrote:
> I am curious why you think it is anti-practice to expose primary keys for 
> user-visible purposes.
> My URLs all have the PK to the object in them, and any advanced user would be 
> able to “reverse engineer” a URL if they guess the PK of an object—and that’s 
> okay.

https://www.owasp.org/index.php/Top_10_2013-A4-Insecure_Direct_Object_References
https://www.owasp.org/index.php/Insecure_Direct_Object_Reference_Prevention_Cheat_Sheet

> Even Django tutorials suggest using the PK in the URL of an object.

That's an interesting point, and I might argue is a shortcoming in the tutorial.

PRs welcome!

-- 
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/79D86944-B1A3-479B-8959-9477144EBA6F%40andrewsforge.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/d299562d6c474b5f83da9af7e219a357%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: test error

2018-10-22 Thread Andréas Kühne
Hi Joel,

The fact that you are using Django 2.2 has nothing to do with if f strings
are supported. f-strings are a part of the python language. You need to
have at least version 3.6 installed to be able to use f-strings. Check your
python version by writing : python --version in a command shell. If it's
less than 3.6 f strings don't work.

Also regarding how you are writing your tests, you don't need to use an
f-string there at all - you can just test:
self.assertEqual(post.author, 'testuser1')

and so on.

Regards,

Andréas


Den mån 22 okt. 2018 kl 17:17 skrev Joel Mathew :

> Why did you say that? I'm using django 2.2 and f strings are indeed
> supported.
>
> Sincerely yours,
>
> Joel G Mathew
>
>
> On Sun, 21 Oct 2018 at 18:05, Motaz Hejaze  wrote:
> >
> > f'{}' is not supported
> >
> > On Sun, Oct 21, 2018 at 2:29 PM Joel  wrote:
> >>
> >> What is your version of python? f strings were introduced in 3.6
> >>
> >> On Sun, 21 Oct, 2018, 9:54 AM Tim Vogt (Tim Vogt), 
> wrote:
> >>>
> >>> I try to make a test with has an error
> >>> any suggestions?
> >>> tim
> >>>
> >>>
> >>> expected_author = f'{post.author}
> >>> ^
> >>> SyntaxError: EOL while scanning string literal
> >>>
> >>>
> >>> --
> >>> Ran 1 test in 0.000s
> >>>
> >>> FAILED (errors=1)
> >>> Destroying test database for alias 'default'...
> >>> MacBook-Pro-15-Officerebel:blogapi timvogt$
> >>>
> >>>
> >>> from django.test import TestCase
> >>> from django.contrib.auth.models import User
> >>>
> >>> from .models import Post
> >>>
> >>> class BlogTests(TestCase):
> >>>
> >>> @classmethod
> >>> def setUpTestData(cls):
> >>> #Create a user
> >>> testuser1 = User.objects.create_user(
> >>> username='testuser1', password='abc123')
> >>> testuser1.save()
> >>>
> >>> # Create a blog post
> >>> test_post = Post.objects.create(
> >>> author=testuser1, title='Blog title', body='Body content...')
> >>> test_post.save()
> >>>
> >>> def test_blog_content(self):
> >>> post = Post.objects.get(id=1)
> >>> expected_author = f'{post.author}'
> >>> expected_title = f'{post.title}'
> >>> expected_body = f'{post.body}'
> >>> self.assertEquals(expected_author, 'testuser1')
> >>> self.assertEquals(expected_title,'Blog title')
> >>> self.assertEquals(expected_body, 'Body content ...')
> >>>
> >>> --
> >>> 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/FCBEF0A0-EDB1-4842-BB4E-42249F3F48EB%40gmail.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/CAA%3Diw_8VU9J9QGUz_LNGjBRCQSGo0rpJ1FTtY5H00U_Di_7oiw%40mail.gmail.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/CAHV4E-d4qHggazeGzrZJWdf1_Z766SoiJhqXDwizP5Vuox0nVQ%40mail.gmail.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/CAA%3Diw_98qeuc4MM4_HdUHJzjfJXGxpZGMmeauOMQXaaon-KSkA%40mail.gmail.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 

Re: Cannot deploy Django project on Heroku from a Ubuntu 18.04 laptop

2018-10-22 Thread Andréas Kühne
The problem you are having has nothing to do with the python version. What
heroku is saying is that you should change to python 3.6.6 which you do by
adding a file to the project - see
https://devcenter.heroku.com/articles/deploying-python.

The problem you are getting (and that hinders you from installing your
application) is that you are using a python 2.7 compatible plugin (Cheetah)
- that doesn't have any python 3 code. The error is that the code is not
python 3 compatible. (the syntax error you are getting at the end shows
this) - to install a Cheetah that you can use, install cheetah3.

Regards,

Andréas


Den mån 22 okt. 2018 kl 14:21 skrev Mo-rema07 :

> Hello people,
>
> Can I please get help? I am a noob using a Lenovo V110 running Ubuntu
> 18.04. I am getting an  error that I am using python 3.6.5 instead of
> 3.6.6. However when I check the python version using "python3 --version" I
> find that my version is 3.6.6. Can someone please help I have been
> struggling with this issue for about 2 weeks and I cannot find the solution
> online.
>
> 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+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/7dc30e45-81f9-4ce0-8635-814651c3e340%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/CAK4qSCdMWSGUD%2BrT%2BBvLT0FkYvvJFBCFqpPdiEw8CdKmUpkPcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating seperate unique ids within the same table

2018-10-22 Thread bill . torcaso . oxfam
Joel said this was a requirement:

One of the important criteria I had was that these IDs should be easily 
memorable. Unfortunately UUIDs are not memorable, being too long to 
remember.
 

A primary key that appears in a URL is just an implementation detail - the 
implementation could change, and still display the equivalent behavior to a 
user.

But when I person has to remember a value, that value is no longer an 
implementation detail.  Again, just my opinion; but that crosses the line.  

-- 
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/b7510c26-ecac-4a68-b7c4-05d5d0e89ad2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trigger actions independently of url request

2018-10-22 Thread Andrew Pinkham
On Oct 22, 2018, at 12:08, Charley Paulus  wrote:
> After reading the Django tutorial, my understanding (I hope I’m wrong) is 
> that the only way to trigger a function of a Django app is when someone on 
> the client side request the url related to that function.

That is correct. A view function/object is only called when a site visitor is 
routed to that callable by the URL configuration.

> But what if I want the server to run a function indenpendently of a url call, 
> for example:
> - every 10 minutes
> - when a pre-defined combination of variables become true

I'm not clear on your second condition, but you are probably interested in 
Celery for the first.

http://www.celeryproject.org/

Alternatively, some clouds provide the ability to run code on a regular basis. 
If your Django code is not closely coupled with cron job, you could use AWS 
Lambda.

https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html

If it is tightly coupled and Celery is too powerful for your needs, you could 
use an AWS Lambda (or Azure Function, etc) to send a request to your Django API 
on a regular basis.

Andrew
https://jambonsw.com
https://django-unleashed.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/7DECDBA7-AF86-468C-A275-CC593CE10F0B%40andrewsforge.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help with CDN on Django App using heroku

2018-10-22 Thread Andrew Pinkham
On Oct 22, 2018, at 11:53, Akash Purandare  wrote:
> However the issue is not with Whitenoise. Whitenoise can be used to serve 
> static files, yes. But how do I use it to serve media assets in the project?

Sorry, missed the media part.

Michal is right, you will need to install and configure django-storages for S3. 

https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html

Related:
https://docs.djangoproject.com/en/2.1/ref/settings/#media-root
https://docs.djangoproject.com/en/2.1/ref/settings/#media-url

This tutorial may be useful (Updated in 2017):

https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/

Andrew
https://jambonsw.com
https://django-unleashed.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/16D1C20E-91C9-4E16-B4E3-F410F815FA3D%40andrewsforge.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating seperate unique ids within the same table

2018-10-22 Thread Andrew Pinkham
On Oct 22, 2018, at 12:29, Matthew Pava  wrote:
> I am curious why you think it is anti-practice to expose primary keys for 
> user-visible purposes.
> My URLs all have the PK to the object in them, and any advanced user would be 
> able to “reverse engineer” a URL if they guess the PK of an object—and that’s 
> okay.

https://www.owasp.org/index.php/Top_10_2013-A4-Insecure_Direct_Object_References
https://www.owasp.org/index.php/Insecure_Direct_Object_Reference_Prevention_Cheat_Sheet

> Even Django tutorials suggest using the PK in the URL of an object.

That's an interesting point, and I might argue is a shortcoming in the tutorial.

PRs welcome!

-- 
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/79D86944-B1A3-479B-8959-9477144EBA6F%40andrewsforge.com.
For more options, visit https://groups.google.com/d/optout.


RE: Creating seperate unique ids within the same table

2018-10-22 Thread Matthew Pava
I am curious why you think it is anti-practice to expose primary keys for 
user-visible purposes.
My URLs all have the PK to the object in them, and any advanced user would be 
able to “reverse engineer” a URL if they guess the PK of an object—and that’s 
okay.
Even Django tutorials suggest using the PK in the URL of an object.
I’m just curious.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of bill.torcaso.ox...@gmail.com
Sent: Monday, October 22, 2018 10:20 AM
To: Django users
Subject: Re: Creating seperate unique ids within the same table


Joel,

I completely agree that UUIDs are not memorable.

I still think you would be well-served to make a UUID the basis for uniquely 
defining a person.  If you want to further add a short name, you could make an 
object class that has a UUID and, say, an 8-digit number.  If you assert that 
the two are unique together, you will get a database-level guarantee of 
uniqueness at creation-time.

This is just an opinion, but I think it an anti-practice to expose a primary 
key for any user-visible purpose.

If you don't like UUID's for your purpose, you might consider the random number 
generator in PyCrypto.

On Monday, October 22, 2018 at 10:20:02 AM UTC-4, Joel wrote:
Thank you Bill. I had a look at UUIDs. One of the important criteria I
had was that these IDs should be easily memorable. Unfortunately UUIDs
are not memorable, being too long to remember. :(

Sincerely yours,

Joel G Mathew


On Mon, 22 Oct 2018 at 19:40, > wrote:
>
> Hello all,
>
> The previous discussion shows a method that will work.  but I think it has 
> disadvantages, and I want to suggest  another approach.
>
> The disadvantage of using a primary key from a table, any table, is that you 
> are committing to that table and that primary key for all eternity.   this 
> has consequences for migration to another system , for merging in data from 
> an external system, among others.
>
> Joel, if I understand your situation, you have a "thing", an individual human 
> being, and you need a permanent, unique identifier for that "thing".  The 
> identifier should not be an implementation detail of your current code, but 
> should be robust, sharable, and resilient in the face of evolving software.
>
> I faced a similar situation with digital assets that are photos and videos.  
> We share photos and videos across several related sites, but we don't want to 
> duplicate the asset for each site.
>
> My solution is to generate a UUID, a Universally Unique IDentifier,  when 
> creating the "thing" - see python 3 at 
> https://docs.python.org/3/library/uuid.html. or python 2 at 
> https://docs.python.org/2/library/uuid.html.
>
> A Universally Unique IDentifier is guaranteed not to collide with any other 
> UUID, and so independent systems can generate one at any time - no need to 
> coordinate with a central database or across separate servers.
>
> A UUID is robust in the face of name changes - such as a maiden name becoming 
> a married name.
>
> I would recommend a UUID over exposing a primary key, hands down, all the 
> time, no exceptions.
>
> --  Bill
>
> --
> 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/8bcbd562-5bb8-49f3-b1ad-1b73ff62d840%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/eb95ee38-160e-4acb-b966-9b7f3ddd6c75%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 

Re: Where to start - New to Django and Python

2018-10-22 Thread manu . pascual . luna
I don't know if it's the best book but I'm enjoying 
http://www.obeythetestinggoat.com. I like 
the 
 

 TDD approach for learning a new technology. Also you can read it for free 
online.


El lunes, 22 de octubre de 2018, 14:02:01 (UTC+2), Lokendar Singh escribió:
>
> Hi Community,
>
> I'm new to django and python, however I've experience in development. 
>
> Can someone suggest me the best book/content/tutor to enhance my skills as 
> a lead developer? 
> Currently I'm going through django documentation.
>
>
> Thanks in advance!
> Lokendar 
>

-- 
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/d3b9f7cb-8379-413b-b626-0eb06f12b2c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Trigger actions independently of url request

2018-10-22 Thread Charley Paulus
Hi,

After reading the Django tutorial, my understanding (I hope I’m wrong) is that 
the only way to trigger a function of a Django app is when someone on the 
client side request the url related to that function.

But what if I want the server to run a function indenpendently of a url call, 
for example:
- every 10 minutes
- when a pre-defined combination of variables become true

Where should such code live?

Thank you.
Best regards,
Charley

-- 
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/7897fc02-62de-49d4-bfc2-9fc874c34fdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Dynamic from class creation at runtime

2018-10-22 Thread Daniel Gola
Hi There,

do you have any experience with dynamic form class (inherited from 
django.forms.Form) creation at runtime? How to achieve it?

I will be grateful for your advice.

Regards
Daniel 

-- 
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/5d2e18d2-59e2-470e-87f6-cb7608ae9dfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django dynamic form class creation at runtime

2018-10-22 Thread Daniel Gola
Hi There,

do you have any experience with dynamic form class creation at runtime? How 
to achieve it?

I will be grateful for your advice.

Regards
Daniel 

-- 
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/eb438d64-ea9b-4d2d-b1b6-a2839a87d67a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot deploy Django project on Heroku from a Ubuntu 18.04 laptop

2018-10-22 Thread TimT Vogt
https://devcenter.heroku.com/articles/deploying-python

Verstuurd vanaf mijn iPhone

> Op 22 okt. 2018 om 17:52 heeft Gear Crew  het 
> volgende geschreven:
> 
> without deploy run this page and show the same error 
> 
>> On Monday, 22 October 2018 14:22:05 UTC+2, Mo-rema07 wrote:
>> Hello people,
>> 
>> Can I please get help? I am a noob using a Lenovo V110 running Ubuntu 18.04. 
>> I am getting an  error that I am using python 3.6.5 instead of 3.6.6. 
>> However when I check the python version using "python3 --version" I find 
>> that my version is 3.6.6. Can someone please help I have been struggling 
>> with this issue for about 2 weeks and I cannot find the solution online.
>> 
>> 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+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/a6ff5328-1596-486e-b50f-dee68e0e87e3%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/B6A8FFBC-EC0A-4A67-AD9D-CA8385FD9EF2%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help with CDN on Django App using heroku

2018-10-22 Thread Akash Purandare
Thank you for the fast reply.

However the issue is not with Whitenoise. Whitenoise can be used to serve 
static files, yes. But how do I use it to serve media assets in the project?

On Monday, October 22, 2018 at 9:11:02 PM UTC+5:30, Andrew Pinkham wrote:
>
> https://devcenter.heroku.com/articles/django-assets 
> 
>  
> http://whitenoise.evans.io/en/stable/django.html 
>
>

-- 
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/64d5e24a-7115-409e-b328-c45a0875f5b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot deploy Django project on Heroku from a Ubuntu 18.04 laptop

2018-10-22 Thread Gear Crew
without deploy run this page and show the same error 

On Monday, 22 October 2018 14:22:05 UTC+2, Mo-rema07 wrote:
>
> Hello people,
>
> Can I please get help? I am a noob using a Lenovo V110 running Ubuntu 
> 18.04. I am getting an  error that I am using python 3.6.5 instead of 
> 3.6.6. However when I check the python version using "python3 --version" I 
> find that my version is 3.6.6. Can someone please help I have been 
> struggling with this issue for about 2 weeks and I cannot find the solution 
> online.
>
> 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+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/a6ff5328-1596-486e-b50f-dee68e0e87e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help with CDN on Django App using heroku

2018-10-22 Thread Michal Petrucha
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On Mon, Oct 22, 2018 at 08:38:25AM -0700, Akash Purandare wrote:
> I am trying to serve both static and media files on Heroku by using an S3 
> bucket, but I do not know how to properly configure the settings.py for the 
> same.
> Does anyone know how to do it? If you do, please direct me to the correct 
> set of information.

Django itself does not ship with built-in support for S3, you'll have
to use a third-party package for that. django-storages appears to be a
popular one, I suggest that you start here:
https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html

Good luck,

Michal
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQIcBAEBCgAGBQJbze/JAAoJEHA7T/IPM/klbT8QAOLnyQUXGiJWWyXk0p1bEDMN
cECp9OkfvZsugvSkubXJF1RppLS9dv4CaPoC2dplC/HjPJeE/4hTtdvZHzHfE/8Y
aFI6ga/grMNvoNFl2F1Khxcau75ZwrJhzWwCQGQDfTnbz4hzjJ9er9asv4IO30X7
+WCGJAg2yLi+GxVEuDM4zC8+7SUzPlVVEL3DsbL6M0UzbcYbWWlZ7laQne3H+BM1
6hQ7nr/u9eYUB3wFVYGbcbtXW1yzSUo/KrW/Xu2Ns3oyhubboDDVr/IsRsRuMwLm
FFkthwS9A2ej37rR1BpQl0ayEOPpsnxNCf3eSytRwfpvxGZkE67kg6qJJdwWaTX+
cteyG8q31LJ2HCpUuFaEUc4YA8D35mGt/4sWfYxXJwDBQ+s4StbhjK3Y/aRYwjdk
oM+ewO/dxm1OQzHWU/a0qcvS8GXAiwIB8AbrsxYwYKPsPqPgx5KDojshuxEH5+X7
kZ7nQZGj7mYRtGkEGjpH/9gaQP6yiVrmORixb6l0vcWLyemmgrC5uIMSfceMpwTH
bUcjyXUfsrOD23ugrv+OKOAYzmce+fHujmEuLe/gy7w4jxWLax+qknf/2MZIcnFV
AXLmRt/hkElTAKnxj8Af+vLtJR20wcrE1rrtt8V4EvxUjKf5yMZgmd7NKw9Bp8Sz
GWuOPu4mWyx1+1sVxzXS
=xJut
-END PGP SIGNATURE-

-- 
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/20181022154202.GP18928%40konk.org.
For more options, visit https://groups.google.com/d/optout.


Re: Need help with CDN on Django App using heroku

2018-10-22 Thread Andrew Pinkham
https://devcenter.heroku.com/articles/django-assets
http://whitenoise.evans.io/en/stable/django.html

-- 
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/5027F5EE-03B2-4124-94CB-F88D4E42000E%40andrewsforge.com.
For more options, visit https://groups.google.com/d/optout.


Need help with CDN on Django App using heroku

2018-10-22 Thread Akash Purandare
I am trying to serve both static and media files on Heroku by using an S3 
bucket, but I do not know how to properly configure the settings.py for the 
same.
Does anyone know how to do it? If you do, please direct me to the correct 
set of information.

-- 
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/c3db0ad0-9342-4ca1-ba6d-2c1895b6790a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot deploy Django project on Heroku from a Ubuntu 18.04 laptop

2018-10-22 Thread Akash Purandare
You can use Pipenv to specify the version of python to Heroku. Personally, 
I have used upto Python 3.7 to deploy my Django projects, seems to work 
best with Pipenv

On Monday, October 22, 2018 at 5:52:05 PM UTC+5:30, Mo-rema07 wrote:
>
> Hello people,
>
> Can I please get help? I am a noob using a Lenovo V110 running Ubuntu 
> 18.04. I am getting an  error that I am using python 3.6.5 instead of 
> 3.6.6. However when I check the python version using "python3 --version" I 
> find that my version is 3.6.6. Can someone please help I have been 
> struggling with this issue for about 2 weeks and I cannot find the solution 
> online.
>
> 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+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/ef1f17c4-82e8-4862-b7f9-4bddb0250f51%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating seperate unique ids within the same table

2018-10-22 Thread bill . torcaso . oxfam

Joel,

I completely agree that UUIDs are not memorable.

I still think you would be well-served to make a UUID the basis for 
uniquely defining a person.  If you want to further add a short name, you 
could make an object class that has a UUID and, say, an 8-digit number.  If 
you assert that the two are unique together, you will get a database-level 
guarantee of uniqueness at creation-time.

This is just an opinion, but I think it an anti-practice to expose a 
primary key for any user-visible purpose.

If you don't like UUID's for your purpose, you might consider the random 
number generator in PyCrypto.

On Monday, October 22, 2018 at 10:20:02 AM UTC-4, Joel wrote:
>
> Thank you Bill. I had a look at UUIDs. One of the important criteria I 
> had was that these IDs should be easily memorable. Unfortunately UUIDs 
> are not memorable, being too long to remember. :( 
>
> Sincerely yours, 
>
> Joel G Mathew 
>
>
> On Mon, 22 Oct 2018 at 19:40, > 
> wrote: 
> > 
> > Hello all, 
> > 
> > The previous discussion shows a method that will work.  but I think it 
> has disadvantages, and I want to suggest  another approach. 
> > 
> > The disadvantage of using a primary key from a table, any table, is that 
> you are committing to that table and that primary key for all eternity.   
> this has consequences for migration to another system , for merging in data 
> from an external system, among others. 
> > 
> > Joel, if I understand your situation, you have a "thing", an individual 
> human being, and you need a permanent, unique identifier for that "thing". 
>  The identifier should not be an implementation detail of your current 
> code, but should be robust, sharable, and resilient in the face of evolving 
> software. 
> > 
> > I faced a similar situation with digital assets that are photos and 
> videos.  We share photos and videos across several related sites, but we 
> don't want to duplicate the asset for each site. 
> > 
> > My solution is to generate a UUID, a Universally Unique IDentifier, 
>  when creating the "thing" - see python 3 at 
> https://docs.python.org/3/library/uuid.html. or python 2 at 
> https://docs.python.org/2/library/uuid.html. 
> > 
> > A Universally Unique IDentifier is guaranteed not to collide with any 
> other UUID, and so independent systems can generate one at any time - no 
> need to coordinate with a central database or across separate servers. 
> > 
> > A UUID is robust in the face of name changes - such as a maiden name 
> becoming a married name. 
> > 
> > I would recommend a UUID over exposing a primary key, hands down, all 
> the time, no exceptions. 
> > 
> > --  Bill 
> > 
> > -- 
> > 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/8bcbd562-5bb8-49f3-b1ad-1b73ff62d840%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/eb95ee38-160e-4acb-b966-9b7f3ddd6c75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: test error

2018-10-22 Thread Joel Mathew
Why did you say that? I'm using django 2.2 and f strings are indeed supported.

Sincerely yours,

Joel G Mathew


On Sun, 21 Oct 2018 at 18:05, Motaz Hejaze  wrote:
>
> f'{}' is not supported
>
> On Sun, Oct 21, 2018 at 2:29 PM Joel  wrote:
>>
>> What is your version of python? f strings were introduced in 3.6
>>
>> On Sun, 21 Oct, 2018, 9:54 AM Tim Vogt (Tim Vogt),  
>> wrote:
>>>
>>> I try to make a test with has an error
>>> any suggestions?
>>> tim
>>>
>>>
>>> expected_author = f'{post.author}
>>> ^
>>> SyntaxError: EOL while scanning string literal
>>>
>>>
>>> --
>>> Ran 1 test in 0.000s
>>>
>>> FAILED (errors=1)
>>> Destroying test database for alias 'default'...
>>> MacBook-Pro-15-Officerebel:blogapi timvogt$
>>>
>>>
>>> from django.test import TestCase
>>> from django.contrib.auth.models import User
>>>
>>> from .models import Post
>>>
>>> class BlogTests(TestCase):
>>>
>>> @classmethod
>>> def setUpTestData(cls):
>>> #Create a user
>>> testuser1 = User.objects.create_user(
>>> username='testuser1', password='abc123')
>>> testuser1.save()
>>>
>>> # Create a blog post
>>> test_post = Post.objects.create(
>>> author=testuser1, title='Blog title', body='Body content...')
>>> test_post.save()
>>>
>>> def test_blog_content(self):
>>> post = Post.objects.get(id=1)
>>> expected_author = f'{post.author}'
>>> expected_title = f'{post.title}'
>>> expected_body = f'{post.body}'
>>> self.assertEquals(expected_author, 'testuser1')
>>> self.assertEquals(expected_title,'Blog title')
>>> self.assertEquals(expected_body, 'Body content ...')
>>>
>>> --
>>> 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/FCBEF0A0-EDB1-4842-BB4E-42249F3F48EB%40gmail.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/CAA%3Diw_8VU9J9QGUz_LNGjBRCQSGo0rpJ1FTtY5H00U_Di_7oiw%40mail.gmail.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/CAHV4E-d4qHggazeGzrZJWdf1_Z766SoiJhqXDwizP5Vuox0nVQ%40mail.gmail.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/CAA%3Diw_98qeuc4MM4_HdUHJzjfJXGxpZGMmeauOMQXaaon-KSkA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating seperate unique ids within the same table

2018-10-22 Thread Joel Mathew
Thank you Bill. I had a look at UUIDs. One of the important criteria I
had was that these IDs should be easily memorable. Unfortunately UUIDs
are not memorable, being too long to remember. :(

Sincerely yours,

Joel G Mathew


On Mon, 22 Oct 2018 at 19:40,  wrote:
>
> Hello all,
>
> The previous discussion shows a method that will work.  but I think it has 
> disadvantages, and I want to suggest  another approach.
>
> The disadvantage of using a primary key from a table, any table, is that you 
> are committing to that table and that primary key for all eternity.   this 
> has consequences for migration to another system , for merging in data from 
> an external system, among others.
>
> Joel, if I understand your situation, you have a "thing", an individual human 
> being, and you need a permanent, unique identifier for that "thing".  The 
> identifier should not be an implementation detail of your current code, but 
> should be robust, sharable, and resilient in the face of evolving software.
>
> I faced a similar situation with digital assets that are photos and videos.  
> We share photos and videos across several related sites, but we don't want to 
> duplicate the asset for each site.
>
> My solution is to generate a UUID, a Universally Unique IDentifier,  when 
> creating the "thing" - see python 3 at 
> https://docs.python.org/3/library/uuid.html. or python 2 at 
> https://docs.python.org/2/library/uuid.html.
>
> A Universally Unique IDentifier is guaranteed not to collide with any other 
> UUID, and so independent systems can generate one at any time - no need to 
> coordinate with a central database or across separate servers.
>
> A UUID is robust in the face of name changes - such as a maiden name becoming 
> a married name.
>
> I would recommend a UUID over exposing a primary key, hands down, all the 
> time, no exceptions.
>
> --  Bill
>
> --
> 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/8bcbd562-5bb8-49f3-b1ad-1b73ff62d840%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/CAA%3Diw__xSFHEcSUCDR-rzzkig3ZHZWKoCEO_z%2Bo%2BEOV_b4QByA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating seperate unique ids within the same table

2018-10-22 Thread bill . torcaso . oxfam
Hello all,

The previous discussion shows a method that will work.  but I think it has 
disadvantages, and I want to suggest  another approach.

The disadvantage of using a primary key from a table, any table, is that 
you are committing to that table and that primary key for all eternity.  
 this has consequences for migration to another system , for merging in 
data from an external system, among others.

Joel, if I understand your situation, you have a "thing", an individual 
human being, and you need a permanent, unique identifier for that "thing".  
The identifier should not be an implementation detail of your current code, 
but should be robust, sharable, and resilient in the face of evolving 
software.

I faced a similar situation with digital assets that are photos and 
videos.  We share photos and videos across several related sites, but we 
don't want to duplicate the asset for each site.

My solution is to generate a UUID, a Universally Unique IDentifier,  when 
creating the "thing" - see python 3 
at https://docs.python.org/3/library/uuid.html. or python 2 
at https://docs.python.org/2/library/uuid.html.

A Universally Unique IDentifier is guaranteed not to collide with any other 
UUID, and so independent systems can generate one at any time - no need to 
coordinate with a central database or across separate servers.

A UUID is robust in the face of name changes - such as a maiden name 
becoming a married name.

I would recommend a UUID over exposing a primary key, hands down, all the 
time, no exceptions.

--  Bill

-- 
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/8bcbd562-5bb8-49f3-b1ad-1b73ff62d840%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: How can I implement built in signals, for my app?

2018-10-22 Thread Matthew Pava
You may want to look at this middleware package that will automatically audit 
user logins.
https://github.com/muccg/django-useraudit

Also, in using AppConfigs, avoid using default_app_config as stated here:
https://docs.djangoproject.com/en/2.1/ref/applications/#configuring-applications
"New applications should avoid default_app_config. Instead they should require 
the dotted path to the appropriate AppConfig subclass to be configured 
explicitly in INSTALLED_APPS."

Your settings file should have something like this:
INSTALLED_APPS = [,'appointments.apps.AppointmentsConfig', ...]


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel Mathew
Sent: Sunday, October 21, 2018 11:51 AM
To: django-users@googlegroups.com
Subject: How can I implement built in signals, for my app?

How to implement built in signals, for my app?

I have a project myappointments, with two apps appointments and clinic in it.

Objective:
When a user logins, details should be entered in the database.

appointments/models.py:

class Event(models.Model):
id=models.AutoField(primary_key=True, unique=True)
type=models.CharField(max_length=60)
description = models.CharField(max_length=150)
time = models.DateTimeField(default=timezone.now)

appointments/__init__.py:

default_app_config = 'appointments.apps.AppointmentsConfig'

appointments/apps.py:

from django.apps import AppConfig
class AppointmentsConfig(AppConfig):
name = 'appointments'
def ready(self):
import appointments.signals  # noqa

appointments/signals.py:

from django.contrib.auth.signals import user_logged_in
from django.dispatch import receiver
def record_loggedin(sender, user, request, **kwargs):
  ev = Event(type="Login", description = 'User logged in:
{}'.format(request.user.id))
  ev.save()
  print("User has logged in. Saved event to DB.")
  user_logged_in.connect(record_loggedin)

What other modifications do I need to do this?

- Joel G Mathew

-- 
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/CAA%3Diw_8ViZgvx8ugBaC0_1uqaOUkCMLmS7adMCoQUmOZL9nJfQ%40mail.gmail.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/a8ab112a374941ebb2db41a1f03d9b2b%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: generate username and password

2018-10-22 Thread fatoubinetou196
Merxi Andrew!!!

Le lundi 22 octobre 2018 13:27:22 UTC, Andrew Pinkham a écrit :
>
> Au sujet d'utilisateurs avec email comme pseudonyme, j’ai créé (avec 
> Russell Keith-Magee) un projet qui a comme but de fournir des classes et 
> modèles qui aident a la création d'utilisateurs custom.
>
> https://django-improved-user.readthedocs.io/en/latest/quickstart.html
> https://github.com/jambonsw/django-improved-user/
>
> Si on parle de la façon d’enregistrer de nouveaux utilisateurs, le code 
> dans django-registration serait peut-être utile aussi.
>
> https://github.com/ubernostrum/django-registration
>
> A savoir: la classe BaseUserManager vient avec une 
> méthode make_random_password.
>
>
> https://docs.djangoproject.com/en/2.1/topics/auth/customizing/#django.contrib.auth.models.BaseUserManager
>
> Andrew
> https://jambonsw.com
> https://django-unleashed.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/ed26817b-07d8-4e5f-8e82-c1408bcb5876%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: generate username and password

2018-10-22 Thread Andrew Pinkham
Au sujet d'utilisateurs avec email comme pseudonyme, j’ai créé (avec Russell 
Keith-Magee) un projet qui a comme but de fournir des classes et modèles qui 
aident a la création d'utilisateurs custom.

https://django-improved-user.readthedocs.io/en/latest/quickstart.html
https://github.com/jambonsw/django-improved-user/

Si on parle de la façon d’enregistrer de nouveaux utilisateurs, le code dans 
django-registration serait peut-être utile aussi.

https://github.com/ubernostrum/django-registration

A savoir: la classe BaseUserManager vient avec une méthode make_random_password.

https://docs.djangoproject.com/en/2.1/topics/auth/customizing/#django.contrib.auth.models.BaseUserManager

Andrew
https://jambonsw.com 
https://django-unleashed.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/39D445EA-C85C-4AD0-B169-A0C58CB7CE02%40andrewsforge.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot deploy Django project on Heroku from a Ubuntu 18.04 laptop

2018-10-22 Thread TimT Vogt
Python 3.6.5 is not supported. You need to downgrade to supported python 
version or deploy to python anywhere

Verstuurd vanaf mijn iPhone

> Op 22 okt. 2018 om 14:20 heeft Mo-rema07  het 
> volgende geschreven:
> U
> Hello people,
> 
> Can I please get help? I am a noob using a Lenovo V110 running Ubuntu 18.04. 
> I am getting an  error that I am using python 3.6.5 instead of 3.6.6. However 
> when I check the python version using "python3 --version" I find that my 
> version is 3.6.6. Can someone please help I have been struggling with this 
> issue for about 2 weeks and I cannot find the solution online.
> 
> 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+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/7dc30e45-81f9-4ce0-8635-814651c3e340%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/8C5173C9-4B3F-4351-B8FD-E985B7106D57%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where to start - New to Django and Python

2018-10-22 Thread Joel
If you don't know python, spend time on basic language and structure before
starting django. The python documentation has a good tutorial. The courses
on udemy are good.
For learning django, the official django tutorial set is sufficient.

On Mon, 22 Oct, 2018, 5:31 PM Lokendar Singh,  wrote:

> Hi Community,
>
> I'm new to django and python, however I've experience in development.
>
> Can someone suggest me the best book/content/tutor to enhance my skills as
> a lead developer?
> Currently I'm going through django documentation.
>
>
> Thanks in advance!
> Lokendar
>
> --
> 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/0c69fb3c-1ddf-4781-b94c-d3c28faefb71%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/CAA%3Diw_-40gpfeikRpix22a0VUSYzzNk6pM5der%2BZVzqZztOCqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where to start - New to Django and Python

2018-10-22 Thread Mo-rema07
I have found The Django Book  to be a very good 
book to get a handle of Djangoa and it's philosophy.

On Monday, October 22, 2018 at 2:02:01 PM UTC+2, Lokendar Singh wrote:
>
> Hi Community,
>
> I'm new to django and python, however I've experience in development. 
>
> Can someone suggest me the best book/content/tutor to enhance my skills as 
> a lead developer? 
> Currently I'm going through django documentation.
>
>
> Thanks in advance!
> Lokendar 
>

-- 
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/3e0a9b82-84f4-4578-b09f-6e7e711c03d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Where to start - New to Django and Python

2018-10-22 Thread Lokendar Singh
Hi Community,

I'm new to django and python, however I've experience in development. 

Can someone suggest me the best book/content/tutor to enhance my skills as 
a lead developer? 
Currently I'm going through django documentation.


Thanks in advance!
Lokendar 

-- 
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/0c69fb3c-1ddf-4781-b94c-d3c28faefb71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: API Django

2018-10-22 Thread Phako Perez
Thanks Vinod for your quick response, I did, in addition I used -U
(capital) instead (-u), however I got error like

Method GET not allowed.

Method Not Allowed: /schedule/3/
[22/Oct/2018 06:13:50] "GET /schedule/3/ HTTP/1.1" 405 40

On Mon, Oct 22, 2018 at 1:02 AM 'Vinod Kumar' via Django users <
django-users@googlegroups.com> wrote:

> Remove Isauthenticated from rest_framework in settings.py
>
> On Mon, Oct 22, 2018, 11:22 AM Phako Perez <13.phak...@gmail.com> wrote:
>
>> Hi all,
>>
>> i'm really new on Django, trying to create an RESTful API, and getting
>> this error:
>>
>> curl -i -U Elly:Elly -H "Content-Type: application/json" -X GET
>> http://192.168.100.22:8000/schedule/3/
>>
>>
>> HTTP/1.1 403 Forbidden
>>
>> Date: Mon, 22 Oct 2018 05:44:40 GMT
>>
>> Server: WSGIServer/0.2 CPython/3.6.3
>>
>> Content-Type: application/json
>>
>> Vary: Accept, Cookie
>>
>> Allow: OPTIONS
>>
>> X-Frame-Options: SAMEORIGIN
>>
>> Content-Length: 58
>>
>>
>> {"detail":"Authentication credentials were not provided."}
>>
>> on my settings.py added below
>>
>> REST_FRAMEWORK = {
>> 'DEFAULT_AUTHENTICATION_CLASSES': (
>> 'rest_framework.authentication.BasicAuthentication',
>> 'rest_framework.authentication.SessionAuthentication',
>> 'rest_framework.permissions.IsAuthenticated'
>> ),
>> }
>>
>>
>> views.py
>>
>> from schedule.models import Schedule
>> from users.models import User
>> from rest_framework import exceptions
>> from rest_framework.views import APIView
>> from rest_framework.response import Response
>> from rest_framework.authentication import SessionAuthentication, 
>> BasicAuthentication
>> from rest_framework.permissions import IsAuthenticated
>>
>> from schedule.serializers import ScheduleSerializer
>>
>>
>> class ScheduleList(APIView):
>> authentication_classes = (SessionAuthentication, BasicAuthentication)
>> permission_classes = (IsAuthenticated,)
>>
>> def authenticate(self, request):
>> username = request.META.get('X_USERNAME')
>> if not username:
>> return None
>> try:
>> user = User.objects.get(username=username)
>> except:
>> raise exceptions.AuthenticationFailed('No such user')
>> return Response(user, None)
>>
>> queryset = 
>> Schedule.objects.all().filter(user=User.objects.all().filter(id=5)[0])
>> serializer_class = ScheduleSerializer
>>
>> def perform_create(self, serializer):
>> serializer.save(user=self.request.user)
>>
>>
>> class ScheduleDetail(APIView):
>> authentication_classes = (SessionAuthentication, BasicAuthentication)
>> permission_classes = (IsAuthenticated,)
>>
>> def authenticate(self, request):
>> username = request.META.get('X_USERNAME')
>> if not username:
>> return None
>> try:
>> user = User.objects.get(username=username)
>> except:
>> raise exceptions.AuthenticationFailed('No such user')
>> return Response(user, None)
>>
>> serializer_class = ScheduleSerializer
>>
>> def get_queryset(self):
>> return 
>> Schedule.objects.all().filter(user=User.objects.all().filter(id=5)[0])
>>
>>
>> thanks in advance
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To 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/CAF%3Duzp30Enf%2BE7mWHXG6t2ZAj5YKc11oQkg4HSQOPaHTOO0QsA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> 
>
> *This e-mail and all attachments are intended solely for use by the
> intended recipient and may contain confidential / proprietary information
> of KiwiTech, LLC, subject to important disclaimers and conditions including
> restrictions on the use, disclosure, transfer or export of such
> information.* *If you have received this message in error or are not the
> named recipient(s), please immediately notify the sender at the telephone
> number stated above or by reply e-mail and delete this e-mail from your
> computer*
>
> --
> 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 

Re: API Django

2018-10-22 Thread 'Vinod Kumar' via Django users
Remove Isauthenticated from rest_framework in settings.py

On Mon, Oct 22, 2018, 11:22 AM Phako Perez <13.phak...@gmail.com> wrote:

> Hi all,
>
> i'm really new on Django, trying to create an RESTful API, and getting
> this error:
>
> curl -i -U Elly:Elly -H "Content-Type: application/json" -X GET
> http://192.168.100.22:8000/schedule/3/
>
>
> HTTP/1.1 403 Forbidden
>
> Date: Mon, 22 Oct 2018 05:44:40 GMT
>
> Server: WSGIServer/0.2 CPython/3.6.3
>
> Content-Type: application/json
>
> Vary: Accept, Cookie
>
> Allow: OPTIONS
>
> X-Frame-Options: SAMEORIGIN
>
> Content-Length: 58
>
>
> {"detail":"Authentication credentials were not provided."}
>
> on my settings.py added below
>
> REST_FRAMEWORK = {
> 'DEFAULT_AUTHENTICATION_CLASSES': (
> 'rest_framework.authentication.BasicAuthentication',
> 'rest_framework.authentication.SessionAuthentication',
> 'rest_framework.permissions.IsAuthenticated'
> ),
> }
>
>
> views.py
>
> from schedule.models import Schedule
> from users.models import User
> from rest_framework import exceptions
> from rest_framework.views import APIView
> from rest_framework.response import Response
> from rest_framework.authentication import SessionAuthentication, 
> BasicAuthentication
> from rest_framework.permissions import IsAuthenticated
>
> from schedule.serializers import ScheduleSerializer
>
>
> class ScheduleList(APIView):
> authentication_classes = (SessionAuthentication, BasicAuthentication)
> permission_classes = (IsAuthenticated,)
>
> def authenticate(self, request):
> username = request.META.get('X_USERNAME')
> if not username:
> return None
> try:
> user = User.objects.get(username=username)
> except:
> raise exceptions.AuthenticationFailed('No such user')
> return Response(user, None)
>
> queryset = 
> Schedule.objects.all().filter(user=User.objects.all().filter(id=5)[0])
> serializer_class = ScheduleSerializer
>
> def perform_create(self, serializer):
> serializer.save(user=self.request.user)
>
>
> class ScheduleDetail(APIView):
> authentication_classes = (SessionAuthentication, BasicAuthentication)
> permission_classes = (IsAuthenticated,)
>
> def authenticate(self, request):
> username = request.META.get('X_USERNAME')
> if not username:
> return None
> try:
> user = User.objects.get(username=username)
> except:
> raise exceptions.AuthenticationFailed('No such user')
> return Response(user, None)
>
> serializer_class = ScheduleSerializer
>
> def get_queryset(self):
> return 
> Schedule.objects.all().filter(user=User.objects.all().filter(id=5)[0])
>
>
> thanks in advance
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/CAF%3Duzp30Enf%2BE7mWHXG6t2ZAj5YKc11oQkg4HSQOPaHTOO0QsA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 









This e-mail and all attachments are intended solely for use by
the intended 
recipient and may contain confidential / proprietary information
of 
KiwiTech, LLC, subject to important disclaimers and conditions including

restrictions on the use, disclosure, transfer or export of such 
information. If you have received this
message in error or are not the 
named recipient(s), please immediately notify
the sender at the telephone 
number stated above or by reply e-mail and delete
this e-mail from your 
computer





-- 
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/CAJOHC1wHOa0-2G%2B8RHrvWi4JzX0-UeX7w%3DAVJ%3DEb_4PHT4OiZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.