Django Developer with Prior Experience developing a dialer required

2024-04-03 Thread Abhishek J
Dear Developers,

I need to build an android and IOS phone dialer similar to Truecaller.

We are seeking experienced and dedicated candidates who are proficient in
Django and possess a keen interest in contributing to this impactful
initiative.

We look forward to the opportunity to collaborate with talented individuals
who are passionate about creating innovative solutions in the education
sector.

Thank you for considering this opportunity.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKkngwCYo%2By%2Bzq0ph%2B%3D4tPZ1%2BWM3uhTtAu63-jP0VNVQ6xkmHg%40mail.gmail.com.


Freelance Opportunity : Django Developer for building A Dialer

2024-04-02 Thread Abhishek J
Dear Developers,

I need to build an android and IOS phone dialer similar to Truecaller.

We are seeking experienced and dedicated candidates who are proficient in
Django and possess a keen interest in contributing to this impactful
initiative.

We look forward to the opportunity to collaborate with talented individuals
who are passionate about creating innovative solutions in the education
sector.

Thank you for considering this opportunity.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKkngwDHBygGho4gkHRhNkpVJf_d2UOkHQ%3DemN3BtcFSVRU8sA%40mail.gmail.com.


Accessing my local backend

2023-03-12 Thread Rafael J. Soteldo S.
Hi there:

I'm being able to access my local backend built with django/python from 
Postman and react, but if I try to access it from an application built for 
mobiles, I get a Network error. I try to access the backend from an android 
device

What should I set in django in order to being able to access my endpoints 
from a device other than the computer

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/769bc9b8-eacf-4e29-ac14-4a199304e4cen%40googlegroups.com.


Uptime all the time

2023-01-22 Thread j harvey
I am looking for ideas on how to keep my app running all the time, even 
when uploading data that will replace the current data. Some of these 
tables will have a million rows or more. Ideas?

Thanks in advance,

John

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8087a569-f379-4e0e-b3fa-92d281abad69n%40googlegroups.com.


Upgrading Django from 3.2.16 to 4.1.x

2023-01-16 Thread 'Ellinghaus, Lance J' via Django users
I will be upgrading from Django 3.2.16 to 4.1.x and wanted to know if anyone 
has any suggestions. I am using oracle as the backend.
The release notes do not go into much detail.
Do I just need to install the Django 4.1.x software and run the makemigrations 
to do the upgrade?

Thank you,
Lance Ellinghausen

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/63c62f61.050a0220.cc9c2.6fc3SMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: User authentication with simple-jwt drf

2022-08-31 Thread Mobina J
hii 

import pandas as pd
from django.contrib import messages
from django.core.mail import EmailMessage
from django.shortcuts import render
from django.template.loader import render_to_string
from app_1.form import NotificationForm


def email_generic_template(request):
form = NotificationForm(request.POST)
if form.is_valid():
csv_file = request.FILES['file']
data = pd.read_csv(csv_file)
subj = request.POST.get('subject')
msg = request.POST.get('message')
BCC = request.POST.get('bcc_email')
CC = request.POST.get('cc_email')
answer = request.POST.get('selected_option')
demo = list()
try:
for k, r in data.iterrows():
value = r.to_dict()
recipient = value["email_id"]
Subject = subj.format(**value)
Body_of_message = msg.format(**value)
bcc = BCC.format(**value)
cc = CC.format(**value)
FROM_EMAIL = "exam...@gmail.com"
html_template = render_to_string('mail_template.html', {'content': 
Body_of_message})
email1 = EmailMessage(
Subject,
html_template,
FROM_EMAIL,
[recipient],
bcc=[bcc],
cc=[cc]
)
email1.content_subtype = 'html'
sent = email1.send()
value['sent'] = sent
demo.append(value)
if sent == 1:
sent = 'success'
print(sent)
else:
sent = 'Fail'
print(sent)
if answer == 'sample_mail':
break
context = {
'form': form,
'value': demo,
}
return render(request, 'index.html', context)
except Exception as e:
messages.error(request, e)
context = {
'form': form,
'value': demo
}
return render(request, 'index.html', context)

else:
context = {'form': form}
return render(request, 'index.html', context)
  



this is my code...I want to show failed mail to the template...I am new to 
Django I did not know how to do it. anyone  help me
On Wednesday, August 24, 2022 at 7:24:23 PM UTC+5:30 dashlaksh...@gmail.com 
wrote:

> Hello everyone,
> I want to create a user authentication app using ReactJS and django. But 
> facing problems in authenticating with the jsonwebtokens in ReactJS. Can 
> anybody provide correct guide of implementing DjangoRestFramework 
> simple-jwt and ReactJS jet ?
>

-- 



_Disclaimer: _© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains 
PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the 
addressee(s). If you are not the intended recipient, please notify the 
sender by e-mail and delete the original message. Further, you are not to 
copy, disclose, or distribute this e-mail or its contents to any other 
person and any such actions are unlawful._
_
_
_
__

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/87302199-bf5f-4aae-bcaf-ab6ab2401c0fn%40googlegroups.com.


Project Organization.

2021-12-19 Thread J A
I have an idea for an application  where users submit json files that 
represent different data that needs to be parsed and put in a DB. I believe 
there may be many many different types of this input data over time so I 
had this idea that I would break down the different models by applications. 

This would allow me to keep different types of data separated and displayed 
differently. 

My question is this: 

Is this a good idea?
if I break things up into different applications can I also create a 
federated search across apps?

Thanks

J

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/564b224b-c8c6-44d0-8cd6-7390d03bb125n%40googlegroups.com.


RE: edit_view() missing 1 required positional argument: 'id'

2021-09-14 Thread Vikram J
Good Day,

I got this error how can I fixed it, plz help me out,

views.py

 def edit_view(request, id , *args, **kwargs):
d1 = data.objects.get(id=id)
if request.method == 'POST':
form = dataForm(request.POST, instance=d1)
if form.is_valid():
form.save()
return redirect('/homepage')
return render(request, 'edit.html', {'d1': d1 })

urls.py

  urlpatterns = [
path('admin/', admin.site.urls),
path('homepage/', views.select_view),
path('new/', views.create_view),
path('delete/', views.delete_view),
path('edit/', views.edit_view),

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f2121622-43cb-4b38-8470-1098792c2879n%40googlegroups.com.


Re: use of annotate in django query

2021-07-26 Thread V. J
Hello, I'm making a list of potential customers, in about two months, we
will have a business plan ready and we will issue a digital token (ICO)
based on our product in the company.  Would you be interested in learning
more ...?

Dne so 5. čvn 2021 19:09 uživatel Lalit Suthar 
napsal:

> just replied to your mail
>
> On Sat, 5 Jun 2021 at 11:48, Eugene TUYIZERE 
> wrote:
>
>> Dear Suthar,
>>
>> Can I have your private contact?
>>
>> regards,
>>
>> On Fri, 4 Jun 2021 at 06:25, Lalit Suthar 
>> wrote:
>>
>>> my pleasure :)
>>>
>>> On Thu, 3 Jun 2021 at 20:28, Eugene TUYIZERE 
>>> wrote:
>>>
 Dear Suthar,

 Thank you very much. It works well.


 On Thu, 3 Jun 2021 at 16:48, Lalit Suthar 
 wrote:

> not sure but maybe this can work inside views replace
> chart = {
>   'chart': {'type': 'column'},
>   'title': {'text': 'Previous statistics'},
>   'xAxis': {'replist': replist},
>   'series': [arriva_days]
> }
> with
> chart = {
>   'chart': {'type': 'column'},
>   'title': {'text': 'Previous statistics'},
>   'xAxis': {'categories': replist},
>   'series': [arriva_days]
> }
>
> On Thu, 3 Jun 2021 at 18:00, Eugene TUYIZERE 
> wrote:
>
>> This what I have in summarizedchart.html:
>>
>> {% extends "layouts/base.html" %}
>> {% load static %}
>> {% block title %} Repport {% endblock %}
>>
>> 
>> {% block stylesheets %}{% endblock stylesheets %}
>>
>> {% block content %}
>>
>> 
>> 
>> 
>> 
>> 
>> Report
>>
>> 
>>
>> 
>>
>> 
>> 
>> Highcharts.chart('container', {{ chart|safe }});
>> 
>> 
>> 
>> 
>> 
>> 
>> {% endblock content %}
>> {% block custom_js %}
>>
>> {% endblock custom_js %}
>>
>> On Thu, 3 Jun 2021 at 14:22, Lalit Suthar 
>> wrote:
>>
>>> so the view is not giving error right now but maybe we are passing
>>> the data in different format then the chart is expecting.
>>> What are you using for drawing the chart? can I see the code inside
>>> "summarizedchart.html"
>>>
>>> On Thu, 3 Jun 2021 at 17:43, Eugene TUYIZERE <
>>> eugenetuyiz...@gmail.com> wrote:
>>>
 Dear Suthar,

 You saved my day. Once more, the chart is displayed but the date is
 not displayed on Xaxis. This how it is:

 [image: image.png]

 Th codes are:
 def reqChart(request):
 current_date = date.today()
 days_before = date.today()-timedelta(days=30)
 datelist = Customer_Requests.objects.values("arrival_date").
 annotate(num_req=Count("request_name")).order_by('-arrival_date')[:
 20:-1]
 replist = list()
 sumdata = list()
 for listd in datelist:
 replist.append(listd['arrival_date'])
 sumdata.append(listd['num_req'])
 arriva_days = {
 'name': 'Datess',
 'data': sumdata,
 'color': 'green'
 }
 chart = {
 'chart': {'type': 'column'},
 'title': {'text': 'Previous statistics'},
 'xAxis': {'replist': replist},
 'series': [arriva_days]
 }
 dump = json.dumps(chart,cls=DjangoJSONEncoder)
 return render(request,'summarizedchart.html',{'chart': dump})


 On Thu, 3 Jun 2021 at 13:27, lalit suthar 
 wrote:

> Hi there!
> make these couple of changes
>
> 1) from django.core.serializers.json import DjangoJSONEncoder
> 2) dump3 = json.dumps(chart3, cls=DjangoJSONEncoder)
> On Thursday, 3 June 2021 at 16:18:15 UTC+5:30 eugenet...@gmail.com
> wrote:
>
>> Dear Suthar,
>>
>> Your idea works well , but I want now to display the result on
>> chart. Below is the code I am trying to use:
>> but Am getting the error message:
>>
>> Exception Value:
>>
>> Object of type date is not JSON serializable
>>
>>
>> def reqChart(request):
>> aa = Customer_Requests.objects.values("arrival_date").annotate(
>> num_req=Count("request_name")).order_by('-arrival_date')[:20:-1]
>> print(aa)
>> datesb = list()
>> sumdata = list()
>> for dd in aa:
>> datesb.append(dd['arrival_date'])
>> sumdata.append(dd['num_req'])
>> arriva_days = {
>> 'name': 'Datess',
>> 'data': sumdata,
>> 'color': 'green'
>> }
>> chart3 = {
>> 'chart': {'type': 'column'},
>> 'title': {'text': 'Previous statistics'},
>> 'xAxis': {'datesb': datesb},
>> 'series': [arriva_days]
>> }
>> dump3 = json.dumps(chart3)
>> return render(request,'summarizedchart.html',{'chart3': dump3})
>>

Re: CSS not linking with HTML

2021-07-26 Thread V. J
Hello, I'm making a list of potential customers, in about two months, we
will have a business plan ready and we will issue a digital token (ICO)
based on our product in the company.  Would you be interested in learning
more ...?

Dne čt 3. čvn 2021 10:06 uživatel sukhy gill 
napsal:

> Dear frnd
> First of all thanks to all for spare your valueable time for
> me.
>
>
>  Now my Server is working and inline CSS also working but Internal and
> External CSS not working.
> In my last project, image css was also working but now it is not working.
>
> Another problem is "python manage.py collectstatic"  commd giving error.
>
> My Whatsapp no is - 9493878322 ( Anyone may contact me through my whatsapp
> also if you feel so)
>
> Regards
>
>
>
> On Mon, May 31, 2021, 22:41 Chelsea Fan  wrote:
>
>> You are welcome))
>>
>> On Mon, 31 May 2021, 6:44 pm sukhy gill, 
>> wrote:
>>
>>> Thanku so much all of you for your valuable guidance to me 
>>>
>>> On Mon, May 31, 2021, 21:07 Chelsea Fan >> wrote:
>>>
 Good luck 

 On Mon, 31 May 2021, 6:31 pm sukhy gill, 
 wrote:

> I deleted my project and will start project again from begining and
> then will let you know the progress.
> Regards
>
> On Sun, May 30, 2021, 16:48 Mehdi Ismail  wrote:
>
>> you want to mention (provide screenshot) of the error?
>>
>> On Sunday, 30 May 2021 at 09:14:22 UTC+5:30 sukhy.g...@gmail.com
>> wrote:
>>
>>> Getting error while using using command python manage.py
>>> collectstatic
>>> Regarda
>>>
>>> On Sat, May 29, 2021, 21:23 Mehdi Ismail >>
 python manage.py collectstatic


 try that... and update
 On Saturday, 29 May 2021 at 20:44:48 UTC+5:30 sukhy.g...@gmail.com
 wrote:

> Project Folder ➡️static ➡️css➡️style.css➡️
>
> On Sat, May 29, 2021, 19:16 Fabiano Leite  wrote:
>
>>
>> Where is located your 'css/style.css';
>> Em sábado, 29 de maio de 2021 às 10:04:50 UTC-3,
>> sukhy.g...@gmail.com escreveu:
>>
>>> No dear
>>>
>>> On Sat, May 29, 2021, 18:29 Chelsea Fan >> wrote:
>>>
 Is it working now?

 On Sat, 29 May 2021, 3:40 pm lalit suthar, <
 sutharl...@gmail.com> wrote:

> read this
> https://docs.djangoproject.com/en/2.2/intro/tutorial06/ and
> check how you are giving paths. Also after loading the page on 
> your browser
> go to "View Page Source" and click on the CSS file link and check 
> if the
> file is opening or not.
>
> On Saturday, 29 May 2021 at 17:57:21 UTC+5:30
> sukhy.g...@gmail.com wrote:
>
>> Yes Sir,There was no mistake in code. Code problem was only
>> in mail content actually code was correct as instruction given 
>> by Aniket Sir
>>
>> Regards
>>
>>
>> On Sat, May 29, 2021, 13:14 lalit suthar <
>> sutharl...@gmail.com wrote:
>>
>>> have you checked Aniket's answer?
>>>
>>> On Saturday, 29 May 2021 at 11:09:07 UTC+5:30
>>> sukhy.g...@gmail.com wrote:
>>>
 Done Sir, but not working

 On Sat, May 29, 2021, 10:50 Venu Gopal <
 reachme...@gmail.com wrote:

> In Firefox  Goto Preferences ---> Choose Privacy and
> Security ---> scroll down until you get cookies and site data 
> --> clear data
> Chrome  Goto Settings ---> Choose Privacy and Security
> ---> select cookies and other site data --> select see all 
> cookies and site
> data --> Remove all
>
> On Sat, May 29, 2021 at 9:50 AM sukhy gill <
> sukhy.g...@gmail.com> wrote:
>
>> @Venu Gopal
>>
>> No Sir, I don't know, how to do this.
>>
>> May I know Sir, how to do the same?
>>
>> Regards
>>
>> On Sat, May 29, 2021, 09:41 Venu Gopal <
>> reachme...@gmail.com wrote:
>>
>>> Hi, Have you tried deleting existing cache and cookies
>>> in the browser?
>>>
>>> On Sat, May 29, 2021 at 12:08 AM sukhy gill <
>>> sukhy.g...@gmail.com> wrote:
>>>
 Dear Frnds
 I am unable to  link CSS with HTML
 HTML working but CSS not working inside the 

How does django-admin work?

2021-05-31 Thread J Lee
I'm new to Django, and I've just been dazzled by the magic of Django. My 
main question is how does Django add django-admin to my path automatically 
and how does django-admin startproject create my files?

It may be wy over my head, but I welcome any and all response. I would 
like to learn from this. 

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5b022968-ac51-4e49-873d-f9a3b7b88ba4n%40googlegroups.com.


Re: Am I being hacked?

2021-05-07 Thread Stephen J. Butler
Unlikely. The local connection is in a high port range and the remote
connection's port is 443, which indicates your machine made an outbound
HTTPS connection to that IP. Does your code make any HTTP requests? Does it
use anything like OpenID Connect for auth? Do you have SSL certs it is
checking the CRL for? There's a ton of things this could be that are legit.

On Fri, May 7, 2021 at 2:59 AM Mike Dewhirst  wrote:

> After testing some code in Django 3.1 on Windows 10 with Python 3.8.3 I
> got the following report on exiting ...
>
> sys:1: ResourceWarning: unclosed  family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0,
> laddr=('192.168.0.63', 64097), raddr=('34.241.162.61', 443)>
>
> laddr is my laptop which was running the code. I presume raddr is the
> remote address because it looks like https://ipinfo.io/34.241.162.61
> which is in Dublin in an Amazon DC.
>
> What do you think? Am I being hacked?
>
> Mike
>
> --
> Signed email is an absolute defence against phishing. This email has
> been signed with my private key. If you import my public key you can
> automatically decrypt my signature and be sure it came from me. Just
> ask and I'll send it to you. Your email software can handle signing.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/dce603a2-0785-34a0-f66a-336f2927328d%40dewhirst.com.au
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxWbWeuhtd28JrRN5CqBm%3DVezndvciW46DrKO0gb2SzkoQ%40mail.gmail.com.


Beginning project of displaying graphical information from a sql database

2021-04-06 Thread J R
Hello,

Fairly new to Django, I've been through a few tutorials and understand the 
basics. 

My goal is to create a page which shows a defined asset's value over time 
compared to various social metrics tying to that asset (volume of reddit 
comments, twitter posts, ect.). The user will input what kind of asset they 
want to look at, a time range, as well as which social metrics to look at 
along with the defined asset. 

I have a dataframe pulled together from an API that has all the data I need 
to display the graphs that I want. 

I guess from here I'm a bit unsure on how to incorporate this dataframe 
into models, to begin working with different views and templates of 
displaying the data. 

Any ideas, examples would be appreciated. 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6cf01d9d-a18b-4d12-98f9-4e79f02b8590n%40googlegroups.com.


channels_redis SSL help

2021-01-19 Thread j
Hi all, hope you are all doing well.  Would someone be available to help me 
figure out how to connect with SSL using channels_redis? 

I made a web app using django channels + channels_redis and I'm having an 
issue with configuring SSL. (I want SSL because I have deployed the app to 
Google App Engine and I don't want users' messages unsecured.) I have a 
Redis instance on RedisLabs with SSL enabled and all the client certs 
needed, but I can't find where to plug them into my app settings. I 
searched the channels documentation and all the issues on the 
channels_redis GitHub page, but the only mention I found was here: 
https://github.com/django/channels_redis#symmetric_encryption_keys, "we 
advise you to also route your Redis connections over TLS for higher 
security."

I noticed that channels_redis/core.py imports aioredis, and the only 
function from aioredis, create_redis, is used in the function pop() here:
https://github.com/django/channels_redis/blob/243eb7e4ecfc2e922508e50210884d3c9bae5403/channels_redis/core.py#L71

aioredis however is able to use "ssl" as an argument when establishing the 
connection, which channels_redis is not using:
https://github.com/aio-libs/aioredis/blob/922ccfc839ae0a1927ef44e7522a726277bce8a5/aioredis/commands/__init__.py#L171

So, I'm thinking that in order to connect with SSL the channels_redis 
module would need a new feature where I could configure SSL in 
settings.py/CHANNEL_LAYERS, and then channels_redis would pass my SSL 
settings to the function create_redis.

I'm super new to the world of Django and Channels and Redis and also 
contributing to open source projects, so hopefully I haven't over or under 
explained anything. Including this information because it was mentioned in 
the channels_redis GitHub "Submit new issue" form:

   - OS: Windows 10
   - Runtime: Python 3.7
   - Browser: Google Chrome
   - requirements.txt file is attached
   - Expectations vs reality: Expected to find SSL config options in 
   home.settings.CHANNEL_LAYERS variable, but there appears to be none
   - How I'm running my project: Testing locally using runserver so far, 
   but also throwing same error using daphne
   - Error traceback attached ("ERR unencrypted connection is prohibited")
   

Am I missing something, or do you suggest I submit this as a new request 
somewhere?

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f6865cca-8c60-4cd6-91c5-a49e70e2962bn%40googlegroups.com.
2021-01-19 17:58:37,041 - ERROR - server - Exception inside application: ERR 
unencrypted connection is prohibited
  File 
"D:\projects\my_project\web_app\env\lib\site-packages\channels\sessions.py", 
line 175, in __call__
return await self.inner(receive, self.send)
  File 
"D:\projects\my_project\web_app\env\lib\site-packages\channels\middleware.py", 
line 41, in coroutine_call
await inner_instance(receive, send)
  File 
"D:\projects\my_project\web_app\env\lib\site-packages\channels\consumer.py", 
line 54, in __call__
await await_many_dispatch([receive, self.channel_receive], self.dispatch)
  File 
"D:\projects\my_project\web_app\env\lib\site-packages\channels\utils.py", line 
50, in await_many_dispatch
await dispatch(result)
  File 
"D:\projects\my_project\web_app\env\lib\site-packages\channels\consumer.py", 
line 67, in dispatch
await handler(message)
  File "D:\projects\my_project\web_app\src\stories\consumers.py", line 40, in 
websocket_connect
self.channel_name # default attribute
  File 
"D:\projects\my_project\web_app\env\lib\site-packages\channels_redis\core.py", 
line 583, in group_add
async with self.connection(self.consistent_hash(group)) as connection:
  File 
"D:\projects\my_project\web_app\env\lib\site-packages\channels_redis\core.py", 
line 820, in __aenter__
self.conn = await self.pool.pop()
  File 
"D:\projects\my_project\web_app\env\lib\site-packages\channels_redis\core.py", 
line 70, in pop
conns.append(await aioredis.create_redis(**self.host, loop=loop))
  File 
"D:\projects\my_project\web_app\env\lib\site-packages\aioredis\commands\__init__.py",
 line 175, in create_redis
loop=loop)
  File 
"D:\projects\my_project\web_app\env\lib\site-packages\aioredis\connection.py", 
line 133, in create_connection
await conn.auth(password)
  File "D:\projects\my_project\web_app\env\lib\site-packages\aioredis\util.py", 
line 52, in wait_ok
res = await fut
  ERR unencrypted connection is prohibitedaioredis==1.3.1
asgiref==2.3.2
async-timeout==3.0.1
attrs==20.3.0
autobahn==20.12.3
Automat==20.2.0
cffi==1.14.4
channels==2.1.2
channels-redis==2.3.2
constantly==15.1.0
cryptography==3.3.1
daphne==2.2.5
Django==2.0.7
et-xmlfile==1.0.1
hiredis==1.1.0
hyperlink==20.0.1
idna==2.10

Re: Apple M1 Silicon + Django = weird results

2020-12-21 Thread Stephen J. Butler
Looking at that code for RangedFileResponse, I'm kind of skeptical that it
properly implements the Range header. Try removing that bit and see if it
works.

Have you tried the download with various browsers? I wonder if Safari or
Chrome released at the same time as the M1 chips is causing different Range
header behavior than that code is designed to handle. So it might not be
the M1 chip, but just an unrelated change in browser software that got
pushed out at the same time. Speculating here.

On Mon, Dec 21, 2020 at 3:19 PM Benjamin Schollnick <
bscholln...@schollnick.net> wrote:

> Folks,
>
> I’m using django for an online gallery application, and I’ve seen some
> weird results since switching over to the M1 Mac Mini.
> (Please note, I am running it under Rosetta / Intel Translation, since
> pillow doesn’t seem to build under M1 native).
>
> So this could be a quirk of Rosetta, Django, or some combination of these.
>
> I don’t think so, but it could be.
>
> *So What is happening?  *
>
> I never saw this under my 2013 intel iMac, but now under M1 (even under
> Rosetta 2 / Intel translation) I am receiving a damaged / altered download
> file roughly 6 out of 8 or 9 times (~25-33% successful).
>
> Just retrying the download will eventually be successful.
>
> This isn’t Pillow related, since the file is just being downloaded
> directly (no thumbnails or alterations to the file is occurring).
>
> Does anyone have a suggestion on what to do at this time?  I’m uncertain
> on where to start to dig.  Although removing ranged_response, might be a
> starting point…
>
> URLs:
> path("download/", frontend.views.new_download,
> name="downloads"),
> path('thumbnails/', frontend.views.thumbnails,
> name="raw thumbnails"),
>
>
> First, I am using these function for all graphics and/or file(s) being
> sent:
>
> def new_download(request, d_uuid=None):
> page = request.GET.get('page', None)
> if page is None:
> download = index_data.objects.filter(uuid=d_uuid,
>  ignore=False,
>  delete_pending=False)[0]
> else:
> print ("Attempting to find page %s in archive" % page)
> print("\tDownloading - %s, %s" % (download.fqpndirectory.lower(),
>   download.name))
> return respond_as_inline(request,
>  "%s%s%s" % (
>
>  configdata["locations"]["albums_path"],
>  os.sep,
>  download.fqpndirectory),
>  download.name)
>
>
> def respond_as_inline(request, file_path, original_filename, ranged=False):
> # https://stackoverflow.com/questions/36392510/django-download-a-file
> #
> https://stackoverflow.com/questions/27712778/video-plays-in-other-browsers-but-not-safari
> #
> https://stackoverflow.com/questions/720419/how-can-i-find-out-whether-a-server-supports-the-range-header
> filename = os.path.join(file_path, original_filename)
> if os.path.exists(filename):
> mtype, encoding = mimetypes.guess_type(original_filename)
> if mtype is None:
> mtype = 'application/octet-stream'
> response = RangedFileResponse(request, file=open(filename, 'rb'),
> as_attachment=False, filename=os.path.basename(filename))
> response["Content-Type"] = mtype
> return response
> raise Http404
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/75E15498-69D8-47B5-94D2-821C6B35CA92%40schollnick.net
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxWgXyHODdqsD%3DCzawv9D08zSPEwfUWda54kG%2B5XrHZmLA%40mail.gmail.com.


Re: NoReverseMatch at /searchlit/customsearch and bigger problem of exporting a filtered queryset

2020-08-29 Thread V. J
Věřte si  Vašek. JOdesláno z mého telefonu Huawei Původní zpráva Od: RANGA BHARATH JINKA Datum: so 29. srp 2020 5:00Komu: django-users@googlegroups.comPředmět: Re: NoReverseMatch at /searchlit/customsearch and bigger problem of exporting a filtered querysetHi,     There is a django module.     https://pypi.org/project/django-datatables-view/On Sat, 29 Aug 2020, 8:25 am RANGA BHARATH JINKA,  wrote:Hi,    Use jQuery datatable for this. It is easy to use and has inbuilt search and export to CSV, Excel options also.https://datatables.net/extensions/buttons/examples/initialisation/export.htmlOn Sat, 29 Aug 2020, 7:54 am RANGA BHARATH JINKA,  wrote:Hi,     Check this.      https://pypi.org/project/django-queryset-csv/On Sat, 29 Aug 2020, 7:33 am RANGA BHARATH JINKA,  wrote:Hi,         Please check this package. This may help you. All the best    https://django-tables2.readthedocs.io/en/latest/pages/filtering.html  On Sat, 29 Aug 2020, 4:36 am Patrick Carra,  wrote:Hello All!  I need some help with a problem I have been struggling with.  One of you generous geniuses has the answer I'm sure of it.  I am working on integrating an export to csv button(link) on my template to export filtered data from one of my tables.  I have previously only been able to dump the entire table to csv which isn't exactly what I need.  So my thoughts were to place a button/link on the template passes a parameter(dictionary of my filter criteria) to a view named ExportSearch.  The view then calls a function that I have defined to perform my filtered query to the table and then writes outs to csv.  In theory I thought this should work but I keep getting errors that I have not been able to resolve and I am at the end of my knowledge capacity here.  Applicable code below.  Did I mention THANK YOUFrom searchLit/urls.pyfrom django.urls import include, pathfrom . import viewsfrom .views import searchapp_name= "searchLit"urlpatterns=[    path('customsearch/', views.search, name='search'),    path('customsearch//', views.search, name='search'),    path('noccustomsearch/', views.nocSearch, name='nocSearch'),    path('nocreport/export/', views.noc_export, name='noc_export'),    path('customsearch/export/', views.searchLit_export, name='SearchLit_export'),    path('customsearch/exportSearch//', views.exportSearch, name='exportSearch'),]From searchLit/views.pydef filterCircuits(params, search_vector):    circuits=[]    if(params['circuitid']==None and params['bandwidth']==None and params['region']==None and params['carrier']==None and params['status']==None and params['segmentname']==None and params['mrcnew']==None):        circuits=Circuitinfotable.objects.all()    else:        if(params['multipleSearch']!=None and params['multipleSearch']!=""):            circuits=Circuitinfotable.objects.annotate(search=search_vector).filter(search=params['multipleSearch'])        else:            circuits = Circuitinfotable.objects.all()        if(params['circuitid']!=None and params['circuitid']!=""):            circuits = Circuitinfotable.objects.all()            circuits=circuits.filter(circuitid__icontains=params['circuitid'])        if(params['bandwidth']!=None and params['bandwidth']!="" and params['bandwidth']!='Select Bandwidth'):            circuits=circuits.filter(bandwidth=params['bandwidth'])        if(params['region']!=None and params['region']!="" and params['region']!='Select Region'):            circuits=circuits.filter(region=params['region'])        if(params['carrier']!=None and params['carrier']!="" and params['carrier']!='Select Carrier'):            circuits=circuits.filter(carrier=params['carrier'])        if(params['status']!=None and params['status']!="" and params['status']!='Select Status'):            circuits=circuits.filter(status=params['status'])        if(params['segmentname']!=None and params['segmentname']!="" and params['segmentname']!='Select Segment'):            circuits=circuits.filter(segmentname=params['segmentname'])        if(params['mrcnew']!=None and params['mrcnew']!=""):            circuits=circuits.filter(mrcnew=params['mrcnew'])        if(params['diversity']!='Select Option'):            if(params['diversity']=='None'):                circuits=circuits.filter(diversity=None)            else:                circuits=circuits.filter(diversity__icontains=params['diversity'])        if(params['kmz']!='Select YES/NO'):            if(params['kmz']=='No'):                circuits=circuits.filter(kmz=None)            else:                circuits=circuits.filter(kmz__isnull=False)    return(circuits)def search(request):    form = CircuitForm    template =  'customsearch/customsearch.html'    search_vector = SearchVector('circuitid', 'carrier', 'pathname', 'segmentname', 'segmentid', 'alocationaddress', 'alocationcity', 'alocst', 'zlocationaddress', 'zlocationcity', 'zlocst', 'handoffalocaddress', 

Re: def__str__(self) not working properly

2020-08-25 Thread Aginjith G J
0


Do this.
def __repr__ (self): return self.title

restart the shell/session.

then check.

i had this issue. only after restarting the section it worked 

On Sunday, 16 September 2018 at 17:14:18 UTC+5:30 Daniel Herrera wrote:

> I was having the same issue, as mentioned above, it was a mere indentation 
> problem, make sure the def __str__ is properly indented inside of the class 
> and not at the same level.
>
>
> On Friday, July 1, 2016 at 5:52:12 PM UTC+8, gary719_list1 wrote:
>>
>> Hi all; 
>>
>> I am working on the official django tutorial 
>> (https//docs.djangoproject.com/en/1.9/intro/tutorial/02/) on the section 
>> that is adding the choices. Specifically: 
>>
>>
>> # Create three choices. 
>>  >>> q.choice_set.create(choice_text='Not much', votes=0) 
>>  
>>  >>> q.choice_set.create(choice_text='The sky', votes=0) 
>>  
>>  >>> c = q.choice_set.create(choice_text='Just hacking again', votes=0) 
>>
>> The "Not much" entry should return  but returns 
>>  instead. 
>>
>> This would seem to be a problem with the models.py def__str__(self) 
>> call, but I can't locate the problem. Question class works fine. The 
>> specific code is : 
>>
>> import datetime 
>>
>> from django.db import models 
>> from django.utils import timezone 
>>
>>
>> class Question(models.Model): 
>>  question_text = models.CharField(max_length=200) 
>>  pub_date = models.DateTimeField('date published') 
>>
>>  def __str__(self): 
>>  return self.question_text 
>>
>>  def was_published_recently(self): 
>>  return self.pub_date >= timezone.now()-  
>> datetime.timedelta(days=1) 
>>
>>
>> class Choice(models.Model): 
>>  question = models.ForeignKey(Question, on_delete=models.CASCADE) 
>>  choice_text = models.CharField(max_length=200) 
>>  votes = models.IntegerField(default=0) 
>>
>>  def __str__(self): 
>>  return self.choice_text 
>>
>> OS Debian Stretch 
>> KDE Desktop 
>> Django 1.9 
>> python 3.5 
>> Eclipse PyDev IDE 
>>
>> All migrations are up to date. 
>>
>> Any help will be sincerely appreciated. 
>>
>> Gary R. 
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/685d0319-ecce-4ece-919c-ce6ea46a3cfan%40googlegroups.com.


Re: Security issue in django.db.models

2020-08-08 Thread Stephen J. Butler
If you look at the documentation for 'blank' it says:

"""
Note that this is different than null. null is purely database-related,
whereas blank is validation-related. If a field has blank=True, *form
validation* will allow entry of an empty value. If a field has blank=False,
the field will be required.
"""

So that is only caught when doing form validation, not when doing model
validation.


On Fri, Aug 7, 2020 at 6:46 AM Juan D.  wrote:

> I've created a model with null and blank set to False in robot_name:
>
> class Robot(models.Model):
> robot_name = models.CharField(max_length=200, null=False, blank=False)
> version = models.CharField(max_length=20, blank=True, null=True)
>
> class Meta:
> unique_together = ('robot_name', 'version',)
>
> On the admin website everything works perfectly and I am not allowed to
> create a robot without a name. However, on the shell:
>
> Robot.objects.create(version="test_version")
>
> doesn't raise any Exception.
>
> What could it be?
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4ff1570e-70a2-495c-82e3-f20d760992d2n%40googlegroups.com
> 
> .
>

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


Re: Trouble getting kwargs into filter

2020-07-05 Thread Stephen J. Butler
get_queryset() isn't documented as taking any args at all, let alone the
kwargs of the request. You sometimes see people do "def get_queryset(self,
**kwargs)" to future-proof themselves in case get_queryset does, one day,
accept args. But it doesn't right now.

To get the kwargs for the request look at self.kwargs. Also, you might want
to save yourself some headache later by using the provided `model = Item`,
then calling super().get_queryset(), and modifying that queryset and
returning the value. It makes it easier to use other mixins later or
provided class-based view attributes.

class UsersItemsView(ListView):
 template_name = 'testapp/user_item_list.html'
 model = Item

 def get_queryset(self):
 qs = super().get_queryset()
 return qs.filter(user__id=self.kwargs['userlist'])

On Sun, Jul 5, 2020 at 9:15 PM Clive Bruton  wrote:

> I am struggling with getting kwarg values into a queryset filter:
>
> class UsersItemsView(ListView):
>  template_name = 'testapp/user_item_list.html'
>
>  def get_queryset(self, **kwargs):
>  print('kwargs-userlist')
>  print(kwargs)
>  #return Item.objects.filter(user__username='clive')
>  #return Item.objects.filter(user__id=2)
>  return Item.objects.filter(user__id=kwargs['userlist'])
>
>  def dispatch(self, *args, **kwargs):
>  print('kwargs-userlist')
>  print(kwargs['userlist'])
>  return super(UsersItemsView, self).dispatch(*args, **kwargs)
>
>
> On dispatch, I can see the value for "kwargs['userlist']" printed in
> the terminal.
>
> But, the queryset returns an error:
>
>  Exception Type: KeyError
>  Exception Value: 'userlist'
>
> I understand this to mean that the key 'userlist' is not in kwargs,
> and this is confirmed if I "print(kwargs)" inside the get_queryset
>
> If I use the hard-coded filters, commented-out above
> ("user__username='clive'", "user__id=2"), I get the result (from the
> template) that I expect.
>
> So, how do I get the "kwargs['userlist']" passed to the queryset?
>
>
> Thanks
>
>
> -- Clive
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5BD32BE1-331F-4AE5-BB8A-2E769D728972%40indx.co.uk
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxWJmZFXqt1%2ByCvGvhV5C_u7ikSghTWVwbmNv9eqWxb%3D4A%40mail.gmail.com.


Django 1.11 security backports

2020-06-09 Thread Nikolas J. Nyby
Is anyone maintaining an unofficial Django 1.11 security backports branch?

I'm migrating to Django 2.2 as soon as possible, but I was just curious if 
anyone has a branch with the recent security fixes ported in to Django 1.11.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/04422a43-c652-496a-b932-7f08f49f2915o%40googlegroups.com.


Re: Ajax and Django and jQuery - .attr()

2020-05-31 Thread Stephen J. Butler
This isn't a jQuery issue, it's a JavaScript/ECMAScript issue. When you use
the "arrow function" style like "() => { ...code... }" then certain
variables are not bound into the function contact, including "this".
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

To get "this" inside your event handler you need to use "function () {
code... }".

$(".upvote").click( function () {
let answerid = $(this).attr("answer-id");
console.log(answerid);
$.post("{% url 'upvote' %}", {answer_id:answerid});
});

But also, it's bad bad form to define your own attribute names on HTML. Use
the "data-answer-id" attribute name to do this, and in your code access it
with $(this).data("answer-id").

On Sun, May 31, 2020 at 2:19 PM Jan Gregorczyk 
wrote:

> I have a problem with Ajax and Django templates. I'm new to Ajax and
> jquery.
> Console log at the end of the script prints undefined. I don't know why
> let answerid = $(this).attr("answer-id"); doesn't extract attribute from
> this line: 
> I also want to know if using template tags in javascript scripts like here
> $.post("{% url 'upvote' %}", {answer_id:answerid}) is a good idea.
>
>
> {% extends 'base.html' %}
> {% block title %}{{question.title|truncatechars:52}}{% endblock %}
> {% block content %}
> {{question.title}}
> {{question.content}}
> {% for answer in question.answers.all %}
> {{answer.author}}
> {{answer.content}}
> 
> 
> {{answer.votes.count}}
> 
> 
> {% endfor %}
> 
> {% csrf_token %}
> {{form.as_p}}
> 
> 
> {% endblock %}
> {% block javascript %}
> {% load static %}
> https://cdn.jsdelivr.net/npm/js-cookie@rc/dist/js.cookie.min.js";>
> 
> //upvote and downvote script
> var csrftoken = window.Cookies.get('csrftoken');
> function csrfSafeMethod(method) {
> // these HTTP methods do not require CSRF protection
> return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
> }
> $.ajaxSetup({
> beforeSend: function(xhr, settings) {
> if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
> xhr.setRequestHeader("X-CSRFToken", csrftoken);
> }
> }
> });
> $(".upvote").click( () => {
> let answerid = $(this).attr("answer-id");
> console.log(answerid);
> $.post("{% url 'upvote' %}", {answer_id:answerid});
> });
> 
> {% endblock %}
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/aa129ea5-dd3d-402f-a297-796b408e8217%40googlegroups.com
> 
> .
>

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


Re: Issue with Heroku Getting Started

2020-05-15 Thread J Maryott
C:\Users\jakem\python-getting-started>pip freeze
asgiref==3.2.7
dj-database-url==0.5.0
Django==3.0.6
django-heroku==0.3.1
django-utils==0.0.2
gunicorn==20.0.4
psycopg2==2.8.5
pytz==2020.1
sqlparse==0.3.1
whitenoise==5.0.1

On Friday, May 15, 2020 at 11:29:29 AM UTC-4, jlgimeno71 wrote:
>
>
>
> On Thu, May 14, 2020 at 5:02 AM J Maryott > 
> wrote:
>
>> Wondering if anyone may be able to shed some light on this...I've cloned 
>> the latest dev. version of Django from Git, and though I'm a bit of a 
>> newbie here, and this might sound totally dumb to the professionals (I'm 
>> unsure), I also tried pip install django.utilsas a last ditch 
>> effort. It seemed to download a package successfully, but still I'm 
>> receiving the same error.
>>
>> I've made it about halfway though the "Getting Started with Python" 
>> tutorial on the Heroku Dev Center (
>> https://devcenter.heroku.com/articles/getting-started-with-python#run-the-app-locally),
>>  
>> and I get the following error when attempting to run collectstatic:
>>
>>
>> python manage.py collectstatic
>>
>> Traceback (most recent call last):
>>   File "manage.py", line 8, in 
>> from django.core.management import execute_from_command_line
>>   File 
>> "C:\Users\jakem\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\__init__.py",
>>  line 1, in 
>> from django.utils.version import get_version
>> ModuleNotFoundError: No module named 'django.utils'
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/1be60359-eb10-4def-90dc-762d1315e66a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/1be60359-eb10-4def-90dc-762d1315e66a%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>
> Can you type pip freeze into your terminal and copy/paste the output here, 
> please?
>
> -Jorge
>

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


Issue with Heroku Getting Started

2020-05-14 Thread J Maryott
Wondering if anyone may be able to shed some light on this...I've cloned 
the latest dev. version of Django from Git, and though I'm a bit of a 
newbie here, and this might sound totally dumb to the professionals (I'm 
unsure), I also tried pip install django.utilsas a last ditch 
effort. It seemed to download a package successfully, but still I'm 
receiving the same error.

I've made it about halfway though the "Getting Started with Python" 
tutorial on the Heroku Dev Center (
https://devcenter.heroku.com/articles/getting-started-with-python#run-the-app-locally),
 
and I get the following error when attempting to run collectstatic:


python manage.py collectstatic

Traceback (most recent call last):
  File "manage.py", line 8, in 
from django.core.management import execute_from_command_line
  File 
"C:\Users\jakem\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\django\__init__.py",
 line 1, in 
from django.utils.version import get_version
ModuleNotFoundError: No module named 'django.utils'

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1be60359-eb10-4def-90dc-762d1315e66a%40googlegroups.com.


Zen of high load & high availability backend

2020-04-18 Thread J . Pablo Martín Cobos
Hi,

I have written a small manifest that I would like to share with the
community.

I hope you like it and entertain you in these days of confinement.

If anyone is interested in contributing, you can do a fork and a pull
request.

English:
https://goinnn.github.io/zen-of-high-load-and-high-availability-backend/index.html
Spanish:
https://goinnn.github.io/zen-of-high-load-and-high-availability-backend/index-es.html

Sincerely,

-- 
Pablo Martín Cobos
Software engineer
Python/Django developer
goi...@gmail.com

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


Re: Looking for Django developers to work on a new and an existing project with our team

2020-03-31 Thread Juan J . Moreno Piña
available now, I'm located remote
Juan

*Teaching to learn *
*Trading to survive*
*M.Sc. Juan J. Moreno*
En Venezuela (Maracaibo)
Skype:studiom2j
Tel (Italy): +39 02320628565






El lun., 30 de mar. de 2020 a la(s) 07:56, Satish Pal (
satishpal...@gmail.com) escribió:

> Hi
>
> I have total of 2 years of experience and I am interested to join your
> team.
> please check my Linkedin profile
> https://www.linkedin.com/in/satish-kumar-2230b3158/
>
> Thanks in Advance.
>
> On Mon, Mar 30, 2020 at 8:51 AM Phako Perez <13.phak...@gmail.com> wrote:
>
>> Hi,
>>
>> I’m also interested to join your team, have 3+ years working with python
>> Currently I’m teaching python to a group in order them to improve theirs
>> career
>>
>> Thanks in advance
>>
>> Sent from my iPhone
>>
>> On 29 Mar 2020, at 20:48, chinna  wrote:
>>
>> 
>> Hi,
>>
>> I am Premkumar having 3 years of experience in web and rest api
>> development using python and Django. I would like to join your team
>>
>> On Sun, Mar 29, 2020 at 11:26 PM Lax Nayak  wrote:
>>
>>> I am looking for a django developer who has expertise in building
>>> enterprise grade solutions.
>>>
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/f93f06b0-883c-4477-9d73-cc429a43380d%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/f93f06b0-883c-4477-9d73-cc429a43380d%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAG%3DmdoCaGy%3DTWh0CY04_TBo8uG__4UWnd8sfWYLOZ8fapfZ%3DCA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAG%3DmdoCaGy%3DTWh0CY04_TBo8uG__4UWnd8sfWYLOZ8fapfZ%3DCA%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/5C30197E-FCE7-4BE8-B169-4E9E74F4EBF3%40gmail.com
>> <https://groups.google.com/d/msgid/django-users/5C30197E-FCE7-4BE8-B169-4E9E74F4EBF3%40gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALzNJXmFb3cSFpEmYs2yB502x%2BB9DtNkDT_L2hqxvmvTPx08jA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALzNJXmFb3cSFpEmYs2yB502x%2BB9DtNkDT_L2hqxvmvTPx08jA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMf5KvxLjfvMEPJZ6j3PTruMpho34FOW3HaLOECfbkGQFV%2B6zA%40mail.gmail.com.


Re: Forienkey to same table

2020-03-29 Thread Stephen J. Butler
Instead of using the model class, or string name of the model class, use
the string value 'self'.

https://docs.djangoproject.com/en/3.0/ref/models/fields/#foreignkey

On Sun, Mar 29, 2020 at 9:44 PM Mohsen Pahlevanzadeh <
m.pahlevanza...@gmail.com> wrote:

> I have table A with my following fields:
> 1. id (PK)
> 2. fname (text)
> 3. name (text)
> 4. A_id (integer)
>
> I have problem with 4th field, Because it has to refrenced to id
> field. I can't implement it into Django.
>
> How can I write model class for above table in models.py ?
>
> --mohsen
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJFFGZKZLQDNMA%2BzSUFKvUX8c0eMe%2B7do73cV1RyZTO1q-A3gg%40mail.gmail.com
> .
>

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


Re: keep getting the Fatal Python error with mod_wsgi and apache

2020-03-26 Thread Stephen J. Butler
Did you recreate the virtualenv on the server, or did you copy it from your
development machine? You should recreate virtualenv's when deploying to a
different server.

On Thu, Mar 26, 2020 at 8:53 AM Fateh Budwal  wrote:

> Yes python 3.8.2 is installed
>
> On Wednesday, March 25, 2020 at 8:30:35 PM UTC-7, Hella Nick wrote:
>>
>> 你的服务器是安装的python3.8.2的版本吗?
>>
>> Fateh Budwal  于2020年3月26日周四 上午6:03写道:
>>
>>> Hello Everyone
>>>  I have complied python 3.8.2 with django 2.2. it run locally fine but
>>> when i try to deploy it with Apache and mod_wsgi 4.7.1 and getting the
>>> below error. Any suggestions ?
>>>
>>> Current thread 0x7f5aa48af880 (most recent call first):
>>> no Python framePython path configuration:
>>>   PYTHONHOME = (not set)
>>>   PYTHONPATH = (not set)
>>>   program name = /var/www/project/venu/bin/python
>>>   isolated = 0
>>>   environment = 1
>>>   user site = 1
>>>   import site = 1
>>>   sys._base_executable = /var/www/project/venu/bin/python
>>>   sys.base_prefix = '/opt/python3.8.2'
>>>   sys.base_exec_prefix = '/opt/python3.8.2'
>>>   sys.executable = '/var/www/project/venu/bin/python
>>>   sys.prefix = '/opt/python3.8.2'
>>>   sys.exec_prefix = '/opt/python3.8.2'
>>>   sys.path = [
>>> '/opt/python3.8.2/lib/python38.zip',
>>> '/opt/python3.8.2/lib/python3.8',
>>> '/opt/python3.8.2/lib/lib-dynload',
>>>   ]
>>> Fatal Python error: init_fs_encoding: failed to get the Python codec of the 
>>> filesystem encoding
>>> Python runtime state: core initialized
>>> ModuleNotFoundError: No module named encodings
>>>
>>> Current thread (most recent call first)
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAOts0r0qLZLyaFczsQvdKNm45uhhRFYZPwo3uTfMK9Jmy%2B1oNQ%40mail.gmail.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5f39f719-94f3-4f30-a7d3-2a65749af0cf%40googlegroups.com
> 
> .
>

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


Re: Django Mails

2020-03-23 Thread Juan J . Moreno Piña
Hello there,
When we accept user input we need to check that it is valid. This
checks to see that it is the sort of data we were expecting.

There are two different ways we can check whether data is valid. (see :
http://www.easypythondocs.com/validation.html)
You can use a flag, e,g:
flagName = False
while not flagName:
if [Do check here]:
flagName = True
else:
print('error message')
or
could use an exception, e.g.
while True:
try:
[run code that might fail here]
break
except:
print('This is the error message if the code fails')

print('run the code from here if code is successfully run in the try
block of code above')
hope this could help.


*Teaching to learn *
*Trading to survive*
*M.Sc. Juan J. Moreno*
En Venezuela (Maracaibo)
Skype:studiom2j
Tel (Italy): +39 02320628565






El lun., 23 de mar. de 2020 a la(s) 02:51, mick (dhruvashah1221...@gmail.com)
escribió:

> I want the admin and the user themselves both to verify the mail on the
> user registration.And then only the user is being validated.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a1363076-8bec-41cc-8f11-dfed41cd9a24%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a1363076-8bec-41cc-8f11-dfed41cd9a24%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMf5Kvzw4eN8_5ZSYod3RFFCvXkiUbRJS_7VfeX%3DAF6carZcGQ%40mail.gmail.com.


Re: User Athentication Issue

2020-03-21 Thread Juan J . Moreno Piña
I would suggest you to look at Django user authentication , please
chech tis documentation to understand its approach.
https://developer.mozilla.org/es/docs/Learn/Server-side/Django/Authentication


2020-03-21 15:19 GMT-04:00, Irfan Khan :
> i am not able to find, can u please suggest any documentation or tutorial
> for that
> With Regards,
> *Irfan khan*
>
>
>
>
>
> On Wed, 18 Mar 2020 at 17:38, Integr@te System 
> wrote:
>
>> Hi Irfan,
>>
>> Plz try to consider cookies with connection session on this user for
>> which
>> other happen.
>>
>> On Wed, Mar 18, 2020, 15:56 Irfan Khan  wrote:
>>
>>> hi every one,
>>>
>>> as  implemented the user authentication i have tested it working fine.
>>> but one issue
>>> is when ever we logged into the portal then if we again clicks on back
>>> option in browser it going back to login page.how to prevent it.
>>>
>>> thanks in advance.
>>>
>>> With Regards,
>>> *Irfan khan*
>>>
>>>
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CALKGVioaLT8gCpH2iwniyefibqMG0QDWkShNVb_jdjfjSQ1U-Q%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CALKGVioaLT8gCpH2iwniyefibqMG0QDWkShNVb_jdjfjSQ1U-Q%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAP5HUWpzRf%2BLagaGezeCAY2km9HGGSR4AHFui3NZYkm%3DUyPBBw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAP5HUWpzRf%2BLagaGezeCAY2km9HGGSR4AHFui3NZYkm%3DUyPBBw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALKGVirTYzYNZQ4juVKsE%3DOyR_cV-QXEngy6vg4%2BzdTN8y1seQ%40mail.gmail.com.
>


-- 

*M.Sc. Juan J. Moreno*
En Venezuela (Maracaibo)
Skype:studiom2j
Tel (Italy): +39 02320628565
NB: Telf. mobil (en reparacion)

<https://www.bitrix24.net/id14591859/>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMf5Kvw2rAWZN5_5Jacp-dc6k_qQismjAHeO9hN2kOoAs9gTLw%40mail.gmail.com.


Re: Uploading images from media folder during runtime.

2020-03-21 Thread Juan J . Moreno Piña
Please follow these steps:

Display Image in a Django Template (using ImageField)
 *   Add this to your settings file: ...
 *   Create a folder named “media” under your project root directory,
meaning the folder will  be on the same level as your apps.
  *  Add these to your main urls.py. ...
  *  In your model, use ImageField for the field being used for the image. ...
 * Add below to your template to load your images.

Yours
JJM

2020-03-21 14:51 GMT-04:00, Sandip Nath :
> I am developing a car rental app. I have esigned it such a way that the car
>
> and driver images will be uploaded from admin page during runtime from
> media folder. The models.py working fine. Images can be uploaded to the
> media folder. But the images are not getting diplayed on the car page.
> Should the img source in car template be changed to the path of the media
> folder?
> Please advice.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/deafdbcf-5b91-436d-a8aa-68d58ab80df3%40googlegroups.com.
>


-- 

*M.Sc. Juan J. Moreno*
En Venezuela (Maracaibo)
Skype:studiom2j
Tel (Italy): +39 02320628565
NB: Telf. mobil (en reparacion)

<https://www.bitrix24.net/id14591859/>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMf5Kvyfu3y%2BF0VSZMsEimNUGgFufvODS%2BecLkuR083bLjXrjg%40mail.gmail.com.


need connection string help to connect to Db Postgresql

2020-03-20 Thread Juan J . Moreno Piña
I am not able to connect Postgresql , due to miss connectio string. also 
filling DB confi table:
Engine=""
Name=""
User
pass
Host: ?
Database_port: ?

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a88c4566-ee7a-481b-ab8c-55222840e399%40googlegroups.com.


Re: Stuck with Django on a Synology Diskstation

2020-03-05 Thread V. J
Zdravím vás, myslíme že přístup byl udělen jen pár lidem kteří odvádí dobrou práci, jelikož by bylo dost nebezpečné udělit přístup všem, tak pokud vas mohu poprosit obraťte se s žádostí na ně. A pokud uznaji za vhodné že je to potřeba, provedou opravu, nebo doplnění. Pokud se mýlím, tak mě kontaktujte a prenastavim pravidla přístupu. Přeji hezký den s pozdravem Vasek JachimOdesláno z mého telefonu Huawei Původní zpráva Předmět: Re: Stuck with Django on a Synology DiskstationOdesílatel: 'MH' via Django users Komu: Django users Kopie: Is there anything particular hat I have to write into that wsgi.py file?



-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0bfe682d-5dda-4f50-85bc-1239b17a82a3%40googlegroups.com.




-- 
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/-kdq1xj-ohu8uudyni2w-qp6yfm-r1fto6-uhymk84wh307-guno8r-c497jr9gy14j-8vrumlx66jke-aw50mvkek1qxdc72ifubmccbwl6u8u-idee96zjjyzg7gdypxqtaqh-jvqrulz2p1np-1icriq.1583442428804%40email.android.com.


Re: Running django admin separately

2020-02-29 Thread Stephen J. Butler
I think so. Haven't tested, one way should be be to have have two url.py's,
one that includes only the admin URLs and one that includes only your
project URLs. Then have two settings modules that look like this:

# main site settings
from .settings import *
ROOT_URLCONF = 'myproject.urls_main'


# admin site settings
from .settings import *
ROOT_URLCONF = 'myproject.urls_admin'

If you want to get even fancier you can also use the sites module support
to define two different sites and set the SITE_ID in each setting file too.
Although you probably don't need that.

On Sat, Feb 29, 2020 at 6:58 PM Agumba  wrote:

> Hello django users is there a way i can run django-admin separately from
> the main site like separate instances..any help will be appreciated
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4d497c5e-55dd-4074-b733-c6e6e2d8b09a%40googlegroups.com
> 
> .
>

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


Re: Why can't Nginx find Django's static files?

2020-02-21 Thread Stephen J. Butler
The way production servers are setup with Django uses this kind of request
workflow:

client /myapp1 --> nginx:8080 ---(proxy)---> gunicorn:8000 (runs python)
client /myapp2 --> nginx:8080 ---(proxy)---> gunicorn:8000 (runs python)
client /myapp3 --> nginx:8080 ---(proxy)---> gunicorn:8000 (runs python)
client /static/somefile1.css ---> nginx:8080 (reads from the filesystem)
client /static/somefile2.css ---> nginx:8080 (reads from the filesystem)

Notice how everything first goes to nginx, and then your nginx either
proxies/forwards the request to gunicorn for the python code, or it serves
up the static file itself. That's what we want to do. gunicorn is very good
at running dynamic python code but it's very bad at serving up static
files. nginx is very good at serving static files but can't run python
code. See how they work together?

Here's another way to think about it. Take a look sometime at the number of
requests a browser makes to a simple Django website that maybe has 10
images on it, 5 CSS files, and 5 JS files. The initial request fetches
dynamic content and the python code, but then there are 20+ (!!) other
requests that fetch all the static things.

So in that case, only 5% of your requests need to run in gunicorn and the
rest of them should be handled by nginx directly. If you did the bad thing
and just let gunicorn handle it all then you'd need to provision x20 the
resources for gunicorn to make your site have good response times under
load! That's because you'd be handling x20 the connections just to serve
static files.

Therefore, every good sysadmin puts gunicorn behind nginx or apache or some
other proxy technology. It says "Let the frontend server (nginx, apache,
CloudFront, CDN, etc) do the easy task of serving up files from /static,
and send everything else to the backend server (gunicorn) for the hard part
of generating dynamic content."

Now, you setup your nginx and gunicorn properly as far as I can tell. The
only bad thing you did was talk to gunicorn directly instead of going
through the nginx proxy like you should have.

On Fri, Feb 21, 2020 at 11:49 AM Robert F. 
wrote:

>
>
> On Thursday, February 20, 2020 at 8:52:31 AM UTC-8, Stephen J. Butler
> wrote:
>>
>> Django only serves up static files itself when run using runserver. This
>> is meant for development and not production use. When you run it through
>> gunicorn the Django framework won't serve up static files. That's why you
>> connections to :8000 (gunicorn directly, bypassing nginx) don't work right.
>>
>> For running in production/gunicorn you need to run "collectstatic" after
>> changes, and connect to nginx (probably port 80/443) so that the
>> "location/alias" block works as intended and you get your static files.
>>
>>
>>> I understand what you're saying but I don't understand specifically what
>>> it is that I'm doing wrong.  Should I not start Gunicorn with ":8000"?  Do
>>> I need to modify my Nginx configuration file?  I don't quite see how all of
>>> these pieces work together and which piece (or pieces) are wrong.  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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f1cd8e78-17ae-47c0-91e8-732a52c9%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f1cd8e78-17ae-47c0-91e8-732a52c9%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxWga%2BXA4N%2BYTBxG9spDLUpXdcK3g9o0s2C54tdfpFZrGQ%40mail.gmail.com.


Re: Why can't Nginx find Django's static files?

2020-02-20 Thread Stephen J. Butler
Django only serves up static files itself when run using runserver. This is
meant for development and not production use. When you run it through
gunicorn the Django framework won't serve up static files. That's why you
connections to :8000 (gunicorn directly, bypassing nginx) don't work right.

For running in production/gunicorn you need to run "collectstatic" after
changes, and connect to nginx (probably port 80/443) so that the
"location/alias" block works as intended and you get your static files.

On Thu, Feb 20, 2020 at 10:36 AM Robert F. 
wrote:

> I'm trying to understand how static files are served up by Django using a
> project I've created on my Mac using Django 3, Gunicorn, and Nginx.  The
> website serves up templates correctly except that the templates can't see
> my CSS stylesheet.  When I go to a page, for example ```
> 127.0.0.1:8000/app1/```  and view the
> source, I see this in my HTML template:
>
> 
>
> If I click on the href link, I get a page "Not Found" at the address ```
> http://127.0.0.1:8000/static/css/main.css```
> .  This seems like it should
> be the correct link but the template can't see the main.css stylesheet as I
> would expect.
>
> Here are the relevant files in my 'mysite' project located in
> /Users/me/projects/django/django-staticfiles:
>
> ├── app1
> │   ├── templates
> │   │   └── app1
> │   │   └── index.html
> ├── mysite
> │   ├── settings.py
> │   └── wsgi.py
> ├── static
> │   └── css
> │   └── main.css
> ├── static-final
> │   ├── admin
> │   │   ├── css
> │   │   ├── fonts
> │   │   ├── img
> │   │   └── js
> │   └── css
> │   └── main.css
>
> Here are the relevant settings:
>
> # mysite/settings.py
> ...
> DEBUG = False
> ALLOWED_HOSTS = ['127.0.0.1', ]
> ...
> INSTALLED_APPS = [
> 'django.contrib.staticfiles',
> 'app1',
> ]
> ...
> STATIC_URL = '/static/'
> STATICFILES_DIRS = (
> os.path.join(BASE_DIR, 'static'),
> )
> STATIC_ROOT = os.path.join(BASE_DIR, 'static-final/')
> ...
>
> I installed Gunicorn into my virtual environment and run it with this
> command:
>
> gunicorn --bind 0.0.0.0:8000 mysite.wsgi
>
> I installed Nginx using Homebrew.  Here is the part of nginx.conf that
> includes my Nginx settings:
>
> # /usr/local/etc/nginx.conf
> ...
> http {
> ...
> server {
> listen  8080;
> server_name localhost;
> }
> ...
> include server/*;
> }
>
> Here is my Nginx configuration:
>
> # /usr/local/etc/nginx/servers/django-staticfiles
> server {
> listen 80;
> server_name 127.0.0.1;
>
> location / {
> proxy_pass http://127.0.0.1:8000;
> }
>
> location /static/ {
> alias /Users/me/projects/django/django-staticfiles/static-final/;
> }
> }
>
> I should add that when I stop Gunicorn and start Django's development
> server with DEBUG = True, the app1 template accesses the main.css file
> correctly.  It just can't see it when I'm running Gunicorn and Nginx.  I
> realize that I don't have a real need to run Gunicorn/Nginx on my Mac, but
> I've just set it up so I can compare and contrast how Django manages static
> files in development versus production.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/75f129a6-2dbf-47cc-b4ea-08008b30b047%40googlegroups.com
> 
> .
>

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


Re: What's the preferred way to implement matching mechanism (radius distance search) in an uber-like app

2020-02-16 Thread V. J
Zdravím vás, přišel jsem o PC tak nejsem schopen dělat víc, vše dělám stále jen po telefonu, budu se snažit o to co chci a pokud se mi to povede bude to báječný, pokud bych dělal špatně věci, rád bych od vás zpětnou vazbu, děkuji vám a napíšeme si. Vašek JachimOdesláno z mého telefonu Huawei Původní zpráva Předmět: What's the preferred way to implement matching mechanism (radius distance search) in an uber-like appOdesílatel: Jose Chacón Komu: Django users Kopie: Hello, django newbie here. I'm from Peru, currently assigned to participate in the development of a  startup app. What this startup wants is to match business with truck drivers to transport stuff.  I was asked to implement a matching mechanism, firstly I have no idea how to do it but then an idea came to my mind. The requirement its that radius distance search should be increased every 40s when it doesn't found a driver ready to take it. And the search goes on until a driver accepts the incoming request ( i omitted this part in my code)  - or until there's no driver left in the database. So just for testing purposes, this returns true when it finds a driver near according to radius distance search   Here it is:def search_simulation():#first filter - i will apply some conditions to the model . Actual filter value for test purposesfirst_filter = TransportistaGeolocalizacion.objects.filter(transportista_id__gt=18)#parameterflag_found = Falsestart_time_search = timezone.now()km = 2#loopwhile not flag_found:#loop break conditionif(km == 10):break#logic to search for driverdiff = timezone.now() - start_time_searchif(diff.seconds > 20):  #every 20seconds ,distance radius increaseskm+=1start_time_search = timezone.now()print("New round")print("New radius: " + str(km))else:search_result = first_filter.annotate(distance=ExpressionWrapper(6371 * Acos(Cos(Radians(-12.17261550001))* Cos(Radians((F('latitud'* Cos(Radians((F('longitud'))) -   Radians(-77.0259502999))+ Sin(Radians(-12.17261550001))* Sin(Radians((F('latitud'),output_field=FloatField())).filter(distance__lte=km)if(len(search_result) > 0):print("Driver found!")flag_found=Trueelse:print("Failed search")return flag_foundProbably it sucks , I'm afraid its not gonna work when deployed due to concurrent requests ,etc.  so what i wanted is to get is some advice from you. I know it's a super basic implementation (sorry i'm not a django expert yet :c). If  you've done this before or you  know a  better solution to what i want to achieve, it'd like to know (also bc i'm afraid my boss also has no idea how to do it) . It'd mean a lot. 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b00b15ec-271f-4ce2-b8e7-7ff438a9d419%40googlegroups.com.




-- 
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/-5o3k3comh7vj-mc2ntg-jwgctzw93b1ofw0pioemwmqs-vkdyad-2m5o7qwi0wbuc5k09z-dvu7yd-gylinor8vywj-jdaieb-h5nbo-9js5ys-tj35rps40tnm-8njg22-2ahl26-l00ztx-9ow44zpa7ub5.1581864081034%40email.android.com.


Re: AutoField & auto-incrementing

2020-02-12 Thread J. Guadalupe Chavez
El mar., 11 de febrero de 2020 4:27 p.m., Mike Dewhirst <
mi...@dewhirst.com.au> escribió:

> On 11/02/2020 7:06 pm, Bruckner de Villiers wrote:
> >
> > Jason,
> >
> > Thank you.  I have changed the title of this mail.  If I have read the
> > 10 year old ticket 8576 correctly, it seems to be a DB restriction and
> > I imagine that there are good reasons for this.  However, then I don’t
> > understand the purpose of the AutoField given the restrictions and
> > that the Django documentation is somewhat ambiguous/vague.
> >
> > The options seem to be:
> >
> >   * Your uuid suggestion (which I have never worked with, but will
> > explore)
> >   * a function in the model that does the incrementing before
> > committing – (anyone have some example code for this?).  The
> > challenge would be to keep track of the last used ticket no.  I
> > haven’t thought this through yet, but it does occur to me that one
> > could use the id (maybe prefix the id with some starting digits)
> > and write the record twice. Probably barking up the wrong tree.
> >
>
> I have a need for a unique identifier in one of my models. I save the id
> to a separate field in the same model. In my case I don't need to see
> the value. It just needs to be unique and never change. It is used for
> generating the equivalent of a bar-code in a different model.
>
>  def save(self, *args, **kwargs):
>  if self.id:
>  if not self.formulation_no:
>  self.formulation_no = str(self.id)
>  super().save(*args, **kwargs)
>
> A downside to this is the formulation number stays blank until the next
> save after creating the record. The upside is that the id isn't going to
> change so uniqueness isn't lost. Another way of doing this is to copy
> the id when it is first required and formulation_no is still blank.
>
> I have also been known to use a weird mechanism for user-resequencing
> records in a display. In that case they are lesson sequences within a
> course and question sequences within a lesson. I use floats and strings
> in a pair of fields so if that is of interest just ask.
>
> Cheers
>
> Mike
>
> >  *
> >
> > Regards,
> >
> > Bruckner de Villiers
> >
> > +27 83 625 1086
> >
> > *From: * on behalf of Jason
> > 
> > *Reply to: *
> > *Date: *Monday, 10 February 2020 at 14:55
> > *To: *Django users 
> > *Subject: *Re: Adding a verbose_name to id field
> >
> > Hmm.  TIL about https://code.djangoproject.com/ticket/8576
> >
> > Would a a uuid for this, rather than an integer?  If not, you'll have
> > to implement a save override to handle the incrementing yourself.
> >
> > In addition, it might be worthwhile bringing this ticket up for
> > discussion at https://groups.google.com/forum/#!forum/django-developers
> >
> > --
> > 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 view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/django-users/dc686528-0a8d-43ff-9973-d478cc765959%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/django-users/dc686528-0a8d-43ff-9973-d478cc765959%40googlegroups.com?utm_medium=email_source=footer
> >.
> >
> > --
> > 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 view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/django-users/7C1BE52B-AFAE-4D38-9003-8A454A284A39%40gmail.com
> > <
> https://groups.google.com/d/msgid/django-users/7C1BE52B-AFAE-4D38-9003-8A454A284A39%40gmail.com?utm_medium=email_source=footer
> >.
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/99dbcba0-22bd-7c1d-5fe6-68984353bfb1%40dewhirst.com.au
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAGnT0hafj5viY5bYw5HioFxGX6dMgCc3yVSZ2CPA_DkqYS4sA%40mail.gmail.com.


Re: Django query with few data(1,000-3,000) takes too long(1min) to load

2020-02-07 Thread Stephen J. Butler
You've got a lot of foreign key fields where the fetch is being
deferred until template render time, and it being done individually for
each row instead of in bulk. I think if you added this attribute to your
ListView subclass you'd see better performance:

queryset = Outgoing.objects.select_related('base_in', 'project_site',
'released_by', 'released_to', 'released_out', 'unit')

Some of those might be better done as prefetch_related() if their
cardinality is low.

Also, although I doubt it's a major factor in your performance, it would be
better to write `str(self.trans_date)` instead of using the more convoluted
`'%s' % (self.trans_date,)`

On Fri, Feb 7, 2020 at 10:57 AM Eric Kiser  wrote:

> I created an app with the following details:
>
> Hosting: PythonAnywhere
> Database: SQLite and MySQL
>
> Problem: When I load the data in a table it takes minutes to load it. My
> data hasn't even reached a million its just a few thousands.
>
> How I did it:
>
> models.py
> class Outgoing(models.Model):
> base_in = models.ForeignKey('warehouse.Incoming', related_name='out',
> on_delete = models.SET_NULL, null=True)
> trans_date = models.DateField('Date', default=timezone.now)
> trans_type = models.CharField('Type', max_length=50, choices =
> OUTGOING_TYPE)
> form_no = models.CharField('FORM No', max_length=20, default=0)
> project_site = models.ForeignKey(ProjectSite,
> related_name='out_project_site', null=True, on_delete = models.SET_NULL)
> released_by = models.ForeignKey(User, related_name='out_released_by',
> default='', on_delete = models.SET_NULL, null=True)
> released_to = models.ForeignKey(User, related_name='out_released_to',
> blank=True, null=True, on_delete = models.SET_NULL)
> released_out = models.ForeignKey(Outsider,
> related_name='outsider_released_to', blank=True, null=True, on_delete =
> models.SET_NULL)
> unit = models.ForeignKey(UnitProfile, related_name='user_unit',
> blank=True, null=True, on_delete = models.SET_NULL)
>
> quantity = models.DecimalField('Quantity', db_index=True,
> max_digits=20, decimal_places=2, default=0)
> details = models.CharField('Details', max_length=200, default='')
> attachment = models.FileField('Form', upload_to='incoming_form',
> blank=True)
>
> create_date = models.DateTimeField('Date Created', auto_now_add=True)
>
> def __str__(self):
> return "%s" %(self.trans_date)
>
> class Meta:
> verbose_name = 'Outgoing'
> verbose_name_plural = 'Outgoings'
>
>
> views.py
> class OutgoingView(ListView):
> model = Outgoing
> template_name = 'warehouse/outgoing_page.html'
> context_object_name = 'all_out'
>
>
> outgoing_page.html
> 
> {% for outgoing in daily_out %}
> 
> {{
> outgoing.trans_date }}
> {{
> outgoing.trans_type }}
> {{
> outgoing.form_no }}
> {{
> outgoing.base_in.item }}
> {{ outgoing.quantity|intcomma }}
> {{
> outgoing.project_site }}
> {{
> outgoing.unit }}
> {{
> outgoing.released_by }}
> {{
> outgoing.released_to }}
> {{
> outgoing.released_out }}
> {{
> outgoing.details }}
> 
> 
> 
> 
> {% endfor %}
> 
>
>
> What I did:
> - simplified my views, I did not even do any sorting as I'm told that hits
> the database again.
> - shift from SQLite to MySQL still the same problem.
> - asked help from the guys at pythonanywhere thinking I might not have
> enough workers, but they said there's no problem with my account
>
> Can someone help me please. 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1f3f70bd-d2f6-41cf-a964-70d9ff68e45c%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 

Re: How to express `foo = (bar < quox)` as a constraint

2020-01-27 Thread Stephen J. Butler
Frankly, if is_on_sale has such a tight constraint I wouldn't have it as
its own column. Why not just make it an annotated field with an F
expression?

https://docs.djangoproject.com/en/3.0/ref/models/expressions/#using-f-with-annotations

Item.objects.annotate(is_on_sale=(F('price') < F('full_price')))



On Mon, Jan 27, 2020 at 11:47 AM Peter Law  wrote:

> Hi,
>
> Thanks for adding support for check constraints in Django 2.2, it's
> great to be able to move constraints into the model definitions.
>
> I've been trying to work out how to express a constraint which
> validates that the value of one field expresses a relation between two
> other fields, but can't find a nice way to do so.
>
> I've read through the docs and also found
> https://groups.google.com/d/topic/django-users/6Olh5V1b7Us/discussion,
> but haven't found a concise spelling.
>
> I've got a model like:
>
> ```
> class Item(Model):
> price = DecimalField()
> full_price = DecimalField()
> is_on_sale = BooleanField()
> ```
>
> I'd like to be able to express neatly that the `is_on_sale` boolean be
> true only when `price < full_price`.
> In Postgres I can express this as:
>
> ```
> ALTER TABLE item
> ADD CONSTRAINT is_on_sale_check
> CHECK (is_on_sale = (price < full_price))
> ```
>
> However in Django I can't find a way to express this directly.
>
> I did find a long spelling which essentially checks the True case and
> the False case explicitly and then ORs them together, however it's
> several lines of `models.Q` combinations and not at all clear about
> what the code is trying to achieve.
>
> Is there a concise way to do this sort of constraint? If not, would it
> be possible for Django to add support for it?
>
> Thanks,
> Peter
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEMtty7rsf2qk_0qXnzqZdA89e6VRCqF%2B4nQSHgxVCE4XfKAnw%40mail.gmail.com
> .
>

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


Re: Error: Key 'groups' not found in 'UserForm'

2020-01-05 Thread Stephen J. Butler
Take another look at the doc's example on formfield_for_manytomany:

https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_manytomany

You need to call super() and this isn't the right way to override the
widget.

def formfield_for_manytomany(self, db_field, request, **kwargs):
if db_field.name == "groups":
kwargs["widget"] = CommonFilteredSelectMultiple
return super().formfield_for_manytomany(db_field, request, **kwargs)

On Sun, Jan 5, 2020 at 11:05 PM Mike Dewhirst  wrote:

> Significant refinement of the error ...
>
> Trying to use formfield_for_manytomany() triggers the error even if all
> it does is "pass"
>
> Something fishy ... I'll write a fresh question.
>
> Mike
>
> On 6/01/2020 12:46 pm, Mike Dewhirst wrote:
> > This error occurs in the Admin for my custom user when I try to
> > specify a custom widget for permission groups. I haven't included
> > 'groups' in any raw_id_fields, radio_fields or autocomplete_fields.
> > The groups are correctly displayed in the Admin user page with the
> > default FilteredSelectMultiple widget.
> >
> > This is the relevant code in admin.py ... (traceback below)
> >
> > class CommonUserAdmin(UserAdmin):
> >
> > model = get_user_model()
> >
> > def formfield_for_manytomany(self, db_field, request, **kwargs):
> >
> > if db_field.name == "groups":
> > formfield_overrides = {
> > models.ManyToManyField: {'widget':
> > CommonFilteredSelectMultiple},
> > }
> > ...
> >
> > If I omit the formfield_for_manytomany() method and just run
> > formfield_overrides nakedly nothing happens - presumably because the
> > admin doesn't consider "groups" is a ManyToManyField at that point.
> >
> > How do I persuade the Admin to use my widget?
> >
> > Thanks for any advice
> >
> > Mike
> >
> >
> >
> > Environment:
> >
> >
> > Request Method: GET
> > Request URL: http://localhost:8000/admin/common/user/59/change/
> >
> > Django Version: 2.2.9
> > Python Version: 3.7.4
> > Installed Applications:
> > ['django.contrib.auth',
> >  'django.contrib.contenttypes',
> >  'django.contrib.sessions',
> >  'django.contrib.sites',
> >  'django.contrib.messages',
> >  'django.contrib.admin',
> >  'django.contrib.admindocs',
> >  'django.contrib.staticfiles',
> >  'common',
> >  'billing',
> >  'company',
> >  'credit',
> >  'refer',
> >  'regulation',
> >  'substance',
> >  'workplace']
> > Installed Middleware:
> > ['django.middleware.cache.UpdateCacheMiddleware',
> >  'django.middleware.security.SecurityMiddleware',
> >  'django.contrib.sessions.middleware.SessionMiddleware',
> >  'django.middleware.locale.LocaleMiddleware',
> >  'django.middleware.common.CommonMiddleware',
> >  'django.middleware.csrf.CsrfViewMiddleware',
> >  'django.contrib.auth.middleware.AuthenticationMiddleware',
> >  'django.contrib.messages.middleware.MessageMiddleware',
> >  'django.contrib.admindocs.middleware.XViewMiddleware',
> >  'django.middleware.clickjacking.XFrameOptionsMiddleware',
> >  'pwned_passwords_django.middleware.PwnedPasswordsMiddleware',
> >  'django.middleware.cache.FetchFromCacheMiddleware']
> >
> >
> > Template error:
> > In template
> >
> D:\Users\mike\envs\xxex3\lib\site-packages\django\contrib\admin\templates\admin\includes\fieldset.html,
>
> > error at line 7
> >Key 'groups' not found in 'UserForm'. Choices are: email,
> > first_name, is_active, is_staff, last_name, password, username.
> >1 : 
> >2 : {% if fieldset.name %}{{ fieldset.name }}{% endif %}
> >3 : {% if fieldset.description %}
> >4 : {{ fieldset.description|safe
> > }}
> >5 : {% endif %}
> >6 : {% for line in fieldset %}
> >7 : 
> >8 : {% if line.fields|length_is:'1' %}{{ line.errors
> > }}{% endif %}
> >9 : {% for field in line %}
> >10 :  > class="fieldBox{% if field.field.name %} field-{{ field.field.name
> > }}{% endif %}{% if not field.is_readonly and field.errors %} errors{%
> > endif %}{% if field.field.is_hidden %} hidden{% endif %}"{% elif
> > field.is_checkbox %} class="checkbox-row"{% endif %}>
> >11 : {% if not line.fields|length_is:'1' and
> > not field.is_readonly %}{{ field.errors }}{% endif %}
> >12 : {% if field.is_checkbox %}
> >13 : {{ field.field }}{{ field.label_tag }}
> >14 : {% else %}
> >15 : {{ field.label_tag }}
> >16 : {% if field.is_readonly %}
> >17 : {{
> > field.contents }}
> >
> >
> > Traceback:
> >
> > File
> > "D:\Users\mike\envs\xxex3\lib\site-packages\django\forms\forms.py" in
> > __getitem__
> >   163. field = self.fields[name]
> >
> > During handling of the above exception ('groups'), another exception
> > occurred:
> >
> > File
> >
> 

Re: SyntaxError SECRET_KEY

2020-01-05 Thread Stephen J. Butler
My guess is that you have an unbalanced '(' on a previous line and the
error doesn't get thrown until here (when it thinks maybe SECRET_KEY is a
kwarg to the function call). What does the previous setting or two look
like?

On Sun, Jan 5, 2020 at 3:06 PM 'Dash LaLonde' via Django users <
django-users@googlegroups.com> wrote:

> Well I can't go any further, I keep getting SyntaxError SECRET_KEY, the
> only thing I changed was I added another os.path.dirname to the
> settings because that is where it exists. I also set the domain and ip
> address, neither of which should create the error. While this is a new
> endeavor to learn something new, I can't waste time on this, when the only
> answer I can find the SyntaxError is due to incorrect spacing between
> command and setting.
> Can only move it one spot in either direction and neither work, so if
> anyone has a better solution let me know, I would like to be able to
> learn Django. this is how my settings look
>
>  # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY = '(%_cwwe@d#gg&+$myg9c%f961^y(kfd*-q=81k28y%#q&*6%o*'
>
> this is my error message
>
> SECRET_KEY = '(%_cwwe@d#gg&+$myg9c%f961^y(kfd*-q=81k28y%#q&*6%o*'
>  ^
> SyntaxError: invalid syntax
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0c5400fb-f27a-4530-8610-9efad5ad8b1f%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxXeQq5AJxxOqgF1w-YPm%2BaiTDDNsg2VUK_Lg-eBVqr9%2Bw%40mail.gmail.com.


Re: SyntaxError SECRET_KEY

2020-01-05 Thread Stephen J. Butler
On Sun, Jan 5, 2020 at 3:13 PM Mohamed A  wrote:

> Be careful your secret key contains a #
>
> Which comment everything after
>
>
Not when it's quoted as part of a string. It should be fine in this case.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxU5rhJ0FtR3UTpfs2MDKfcmb0fE%3D5VLcVkMb9TOb3UENg%40mail.gmail.com.


Re: get user that is member of two different group

2020-01-02 Thread Stephen J. Butler
I don't think that's what the he asked for. It will return users who are
members of either test1 OR test2, but I read the question as returning
users who are members of both test1 AND test2. I think the proper query
would be:

User.objects.filter(groups__name='test1').filter(groups__name='test2')

That does two joins to the groups table and filters the first on 'test1'
and the second on 'test2'.

On Thu, Jan 2, 2020 at 2:34 AM Lunga Baliwe  wrote:

> Hi there,
> maybe you can use  something like
> User.objects.filter(groups__name__in=['test1', 'test2']).
> Also check https://docs.djangoproject.com/en/3.0/ref/models/querysets/#in for
> examples of using __in
>
> On Thu, Jan 2, 2020 at 6:49 AM sum abiut  wrote:
>
>> Hi,
>> I have two separate groups, for example, test1, and test2. I want to get
>> a user that is a member of group test1 and group test2.
>>
>> I've try User.objects.filter(groups__name='test1') to get users of  group
>> test1. not sure how to check if a user belongs to group test1 and is also
>> belong to group test2
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAPCf-y6F2rbgG1%3DgK4QX8FDKDq61b8mVdvtrtv5LwQQmfwhY3g%40mail.gmail.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANDnEWeuXRnMqCiS8co%3DhifuUhC8NrYo8e1j8Y_EVF6r1sBwew%40mail.gmail.com
> 
> .
>

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


How to filter a Window query?

2020-01-01 Thread Tom J. Wassing
I am search for a solution to filter the results of a query which uses
a window function. I would like to reduce the results set to only
include the entries where the row number is smaller than 10. It is not
supported by the ORM to filter directly on this query set
(https://code.djangoproject.com/ticket/28333). Is there a workaround
for this?

For example (not working):

row_number = Window(
expression=RowNumber(),
output_field='row',
partition_by=(TruncDate('created')),
order_by=F('created').desc())

posts_with_row = (Post.objects
 .annotate(row=row_number)
 .filter(row_number__range=(1, 10)))

Best,

Tom

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1674aa7c-6e0e-4157-9178-16bc34226bb0%40googlegroups.com.


Field Select MasterDetail

2019-10-31 Thread J-23
Hello,
I am new to Django. I have a FormFault model, which has two foreign keys 
"BuildingOwner" and "Building", the key "Building" depends on 
"BuildingOwner" on the form, it gives me two fields of type Select 
(ComboBox) or is there a way in Django that the content of ComboBox changes 
depending on "BuildingOwner" values?

from django.db import models

class Items(models.Model):
   Item_Text = models.CharField("Temat", max_length=100)

def __str__(self):
   return self.Item_Text
   

class Meta:
verbose_name = "Temat zgłoszenia"
verbose_name_plural = "Temat zgłoszeń"

class DocumentType(models.Model):
   Document_Text = models.CharField("Rodzaj", max_length=100) 

def __str__(self):
   return self.Document_Text
   
   class Meta:
   verbose_name = "Rodzaj zgłoszenia"
   verbose_name_plural = "Rodzaj zgłoszeń"

class Status(models.Model):
  Status_Text = models.CharField("Status", max_length=100)

   def __str__(self):
 return self.Status_Text

   class Meta:
 verbose_name = "Status zgłoszenia"
 verbose_name_plural = "Status zgłoszeń"

class BuildingOwner(models.Model):
   BuildingOwner_Text = models.CharField("Właściciel", max_length=100)

def __str__(self):
 return self.BuildingOwner_Text

class Meta:
 verbose_name = "Właściciela budynku"
 verbose_name_plural = "Właściciel budynków"

class Building(models.Model):
   BuildingOwner = models.ForeignKey(BuildingOwner, verbose_name="Właściciel 
budynku", on_delete=models.CASCADE)
   Building_Text = models.CharField("Budynek", max_length=150)
 
   def __str__(self):
 return self.Building_Text

class Meta:
 verbose_name = "Budynek"
 verbose_name_plural = "Budynki"

class FormFault(models.Model):
   Person = models.CharField("Imię i Nazwisko",max_length=300)
   Email = models.EmailField("E-mail", max_length=50)
   Items = models.ForeignKey(Items, verbose_name="Temat", on_delete
=models.CASCADE)
   DocumentType = models.ForeignKey(DocumentType, verbose_name="Rodzaj 
dokumentu", on_delete=models.CASCADE)
   Status = models.ForeignKey(Status, on_delete=models.CASCADE)
   BuildingOwner = models.ForeignKey(BuildingOwner, verbose_name="Właściciel 
budynku", on_delete=models.CASCADE)
   Building = models.ForeignKey(Building, verbose_name="Budynek", on_delete
=models.CASCADE)
   Place = models.CharField("Lokal", max_length=10)

class Meta:
verbose_name = "Zgłoszenie"
verbose_name_plural = "Zgłoszenia"






I found a library here: 
https://github.com/runekaagaard/django-admin-flexselect

but I'm wondering if this can't be done in a simpler way.

Best regards,

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1c2bd867-91b3-4434-9604-08eca8e7b8b1%40googlegroups.com.


Re: Component design question

2019-06-20 Thread J. Pic
Damnit, my port was wrong above, here goes, with list for content and
dict for attributes as arguments instead of using *args, **kwargs:


if not request.user.is_authenticated:
content.append(
Li(
[A([_('Log in')], dict(href=reverse('crudlfap:login')))],
dict(cls='no-padding'),
)
)
else:
content.append(Li([A(
[_('Log out')],
{
'class': 'waves-effect',
'data-noprefetch': 'true',
'href': reverse('crudlfap:logout'),
}
)], {'class': 'no-padding'}))

The good side is that this mistake does make it look like it's more
error-prone than relying on some magic with *args, **kwargs. By magic
i mean: constructor take all *args, each arg that is text or a
component goes in self.content, if an arg is an Event then it goes in
self.events, although kwargs['events'] might also be set to a list ...

Would you favor readability in user code over readability in
constructor of core class Component ?

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/CAC6Op1-Hyt_nP2-kNxGyLK7T%2BSa%2BtjHqctWgKimwvw6Hbu1_%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Component design question

2019-06-20 Thread J. Pic
Better for perspective to port the first example in second syntax to compare:


if not request.user.is_authenticated:
content.append(
Li(
A([_('Log in')], dict(href=reverse('crudlfap:login'))),
dict(cls='no-padding'),
)
)
else:
content.append(Li(A(
[_('Log out')],
{
'class': 'waves-effect',
'data-noprefetch': 'true',
'href': reverse('crudlfap:logout'),
}
), {'class': 'no-padding'}))

I think I could get used to it, but I still feel like the first syntax
is nicer to use.

Looking forward to read your opinions on this !

Have a great day

-- 
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/CAC6Op19fRRybpkUxHYy2s7%3DncBq5OB1g0%2BH0f-_BHQbz6ENejA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Component design question

2019-06-20 Thread J. Pic
Hi all,

We're running some experiments replacing templates by Components
(which support channels based data-binding amongst other niceties) in
Python, i would like to run an opinion survey about two syntaxes
before moving on. Syntax 0 is what seems more "pythonic" but requires
a less strict call signature by cooking *args and **kwargs which adds
a little overhead, but in in my opinion more readable:



if not request.user.is_authenticated:
content.append(
Li(
A(_('Log in'), href=reverse('crudlfap:login')),
cls='no-padding',
)
)
else:
content.append(Li(A(
_('Log out'),
**{
'class': 'waves-effect',
'data-noprefetch': 'true',
'href': reverse('crudlfap:logout'),
}
), cls='no-padding'))

The other syntax works with a strict constructor signature, adding no
overhead and less complex but in my opinion less readable and
enjoyable:

content = [Ul([
Li([
A(
router_link_content,
{'class': 'collapsible-header waves-effect waves-teal'},
),
Div(
sublinks,
{'class': 'collapsible-body'}
)
], {
'class': self.active
})
], {
'class': 'collapsible collapsible-accordion'
})]

If you were in the position where you had to decide what syntax to
keep before moving on, how would you decide ?

Thanks in advance for your feedback

More context:
https://yourlabs.io/oss/crudlfap/commit/85cccdfef936d4303c1abde39238b7dbd688eee1
https://yourlabs.io/oss/ryzom/tree/ssr

-- 
∞

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


error passing int values from browser to path

2019-03-20 Thread charan . j . tej
iam oassing an interger valu from browser to the path using but 
it is  showing as an error not an intege
Environment:


Request Method: GET
Request URL: http://localhost:8000/hello/2

Django Version: 2.1.7
Python Version: 3.7.2
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "C:\Users\sai charan 
tej\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\exception.py"
 
in inner
  34. response = get_response(request)

File "C:\Users\sai charan 
tej\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py"
 
in _get_response
  126. response = self.process_exception_by_middleware(e, 
request)

File "C:\Users\sai charan 
tej\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\base.py"
 
in _get_response
  124. response = wrapped_callback(request, *callback_args, 
**callback_kwargs)

Exception Type: TypeError at /hello/2
Exception Value: hello() got an unexpected keyword argument 'int'
r

-- 
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/8ae35e9d-5e8d-4d5a-b386-935ab6af0753%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Re: Composite Primary / Foreign Key support

2019-02-18 Thread 'Ellinghaus, Lance J' via Django users
NONCONFIDENTIAL // EXTERNAL
So, basically, Django will not be supporting Composite Primary Keys in the 
future?

Lance

-Original Message-
From: django-users@googlegroups.com  On Behalf 
Of Michal Petrucha
Sent: Monday, February 11, 2019 8:34 AM
To: Django users 
Subject: [External] Re: Composite Primary / Foreign Key support

NONCONFIDENTIAL // EXTERNAL

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On Mon, Feb 11, 2019 at 01:08:41AM -0800, 'Lance Ellinghaus' via Django users 
wrote:
> I have seen references to people adding the support of composite 
> primary keys to Django for years, but it does not look like it has been added.
>
> I have a number of legacy databases that I cannot add fields to but 
> need to be able to be queried through Django. They are read-only tables.
> A number of the tables are also related through Composite Foreign Keys 
> and I have seen some addons but not sure what is fully supported.
>
> I am trying to use Django 2.1.5.
>
> Any help or ideas would be appreciated, and saying  "Add a field to 
> your tables" is not an option.
>
> Thank you.

Hi Lance,

I haven't been on top of this in recent years, but let me try.

When it comes to just composite primary keys, as long as you only need read 
access, you might be able to get away with marking an arbitrary field as the 
primary key. Using a non-unique field as the primary key would make any writes 
to the database dangerous, but that's not your case here. However, you also 
lose the invariant that filtering on the “pk” field alias will match at most 
one row, which means the admin would probably be off the table, too – since 
that assumes the “pk” is, in fact, unique, and the same holds for any other 
package that makes use of “pk”. You should still be okay in your own code, 
though.

For composite foreign keys, there is nowadays a private, undocumented API, 
ForeignObject, which is what ForeignKey builds on. The general ForeignObject 
lets you specify multiple fields that make up the relation, you should be able 
to find some examples in the test suite (there is a foreign_object package in 
there). Keep in mind that this is an internal API, so it might change without 
warning.

Good luck,

Michal
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQIcBAEBCgAGBQJcYXniAAoJEHA7T/IPM/kl8EAP/Rzaxqe0bDO6vkxb4/Mmmj5S
62t6Cfm3VqqK6NxYjRXG904jKwDI4HMH1SAs5fdVMh9vf+VBj/S5bcIpQbesqXbh
wbkcIn+mmnfhLDaHOGunYqp76tscBJv/rtxJZaX5NRLp7OraCWtbjRBtiw1fJ/tl
iJD0HRIk9zn0pqyX8GjeAyM0UR+uL1wwrvz8Ur85ASsc8pFThTP6ZMQoaEIgo9D+
HB3XfrhiOMd5Nb2SbjG4KCRe7alpFx83nuY53YVsv+8X+Nqp4Ndi7ch2Ni3jxxHf
R7qVJYsMp/l72CNb6KiT85sb6PwQyeVdvU78cXKjkIKDirskGgQIEW2OvK+ZXC3B
Aj4I+AMFXEKje8ITfW3/s/v+UNvVTNZHYC5NPZ6o50+YJFDoiwb0mpQMdUredWZk
nT2cYMgyPQA/XKN9w5vUCNbTebPG/AA7yCthXbOrHn9Xl+kICkXRjjl9fHRUs55Q
wgPqz0CFXPKaE+JFt/NABJzdSrki1y587GHsOb7hKFiQwS8DHU8WOMXkR3BGKEtN
q0gebcqKvVnjRwLLsBvB0h3uI/yifgBTp8G8/+tZ0WuNdongTe+yPzchxuRjgx10
e70xtBjgsyCQGRB3CPsgR2UelQOtAEt8ZyYwyPF5sQYOvQg1xjcYp87FqfqflSTE
6aQIMkXhKjKazmc/ew9F
=Ji5Z
-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/20190211133426.GV10973%40konk.org.
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/5c6a6c98.1c69fb81.eb4fb.5c2cSMTPIN_ADDED_MISSING%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.


Re: What do you think about unify templates feature?

2019-01-18 Thread J . Pablo Martín Cobos
I reply beetween lines,

El vie., 18 ene. 2019 a las 21:25, Jani Tiainen ()
escribió:

> Hi,
>
> Lets try this again.
>
> Your system could be nice if it really helps rendering speed.
>

Yes we get several miliseconds per request.


>
> But does it require changes in Django core itself, or is it completely
> standalone package that doesn't require changing Django itself to operate?
> If it requires changes in Django itself, it would be useful to describe
> what changes are needed and why.
>
>
You don't need any change in Django. This command generates a new template.
I paste another time my first example:

1. news.html

{% extends "base.html" %}

{% block title %}
{% include "inc.news.title.html" %}
{% endblock %}

{% block content %}
{% for news_item in news %}
{{ news_item.title }}
{{ news_item.subtitle }}
{% endfor %}
{% endblock %}

2. base.html

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
http://www.w3.org/1999/xhtml; lang="{{
LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif
%}>

{% block title %}{% endblock %}


{% block content %}{% endblock %}



3. inc.news.title.html
News

With this command I preprocess every template of a settings variable and I
get something like this:

news.unify.html (or if you want the command can overwrite news.html)

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
http://www.w3.org/1999/xhtml; lang="{{
LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif
%}>

News


{% for news_item in news %}
{{ news_item.title }}
{{ news_item.subtitle }}
{% endfor %}



It is only a preprocess to get time for each request.

Note that you can even no build custom rendering engines since Django
> supports those now (with default implementations for Django Templating
> Language and Jinja2) your system actually might fall in this category.
>
>
No, It is not a new render engine. It would be a pre render engine. It is a
new feature.


> Even code is bad you really need to start get some momentum for your
> system. Otherwise it's really hard to provide any feedback for example
> there might be some edgecases you might not have thought of.
>

I want to know if this is a nice feature for Django community, then I will
create a ticket... and if nobody resolve it I will propose a change, but I
know ifor experience it is very hard collaborate with code in Django, and
more difficult with a new feature.

To understand it, the best is to use the command with a simple template
such as admin/index.html.

Best,


>
> On Fri, Jan 18, 2019 at 7:23 PM J. Pablo Martín Cobos 
> wrote:
>
>> Sorry, I reply beetween lines
>>
>> El vie., 18 ene. 2019 16:32, J. Pablo Martín Cobos 
>> escribió:
>>
>>> Hi another time,
>>>
>>> I am tring to reply every people in this email:
>>>
>>> Josh
>>>
>>> I was not using django.template.loaders.cached.Loader, but the result
>>> are very similar i.e:
>>>
>>> App Template Num templates rendered before unify Num templates rendered
>>> after unify AVG Time render template before unify (ms) AVG Time render
>>> template after unify (ms)
>>> Django admin admin/index.html 3 1 80 70
>>> Django constance admin/constance/change_list.html 7 1 330 180
>>> Django su su/login.html 5 3 10 5
>>>
>>> Pavlos:
>>>
>>>1. Yes, I wrote this email to contribute another time. Actually I am
>>>already Django contributor[1][2]
>>>2. I didn't share my code, because it is not a nice code. *For me it
>>>is a teoric question. I don't want anybody have a bad opinion of this
>>>proposal for the implementation*. But I am sharing [3] it without
>>>problems, but please I know this solution is incomplete for many reason.
>>>3. About your question: "I am not sure I understood anything so far.
>>>Are you just pre-rendering {% include %} tags, so the template engine
>>>doesn't have to do that in runtime?" Yes :-)
>>>4. About it: "I think what you did is addressed more neatly with the
>>>django.template.loaders.cached.Loader, as Josh Smeaton mentioned." and
>>>"Experimenting like this, even if you end up rediscovering something that
>>>exists" It is something different than django cache loader, of course I
>>>know django cache loader, I fixed a proble

Re: What do you think about unify templates feature?

2019-01-18 Thread J . Pablo Martín Cobos
Sorry, I reply beetween lines

El vie., 18 ene. 2019 16:32, J. Pablo Martín Cobos 
escribió:

> Hi another time,
>
> I am tring to reply every people in this email:
>
> Josh
>
> I was not using django.template.loaders.cached.Loader, but the result are
> very similar i.e:
>
> App Template Num templates rendered before unify Num templates rendered
> after unify AVG Time render template before unify (ms) AVG Time render
> template after unify (ms)
> Django admin admin/index.html 3 1 80 70
> Django constance admin/constance/change_list.html 7 1 330 180
> Django su su/login.html 5 3 10 5
>
> Pavlos:
>
>1. Yes, I wrote this email to contribute another time. Actually I am
>already Django contributor[1][2]
>2. I didn't share my code, because it is not a nice code. *For me it
>is a teoric question. I don't want anybody have a bad opinion of this
>proposal for the implementation*. But I am sharing [3] it without
>problems, but please I know this solution is incomplete for many reason.
>3. About your question: "I am not sure I understood anything so far.
>Are you just pre-rendering {% include %} tags, so the template engine
>doesn't have to do that in runtime?" Yes :-)
>4. About it: "I think what you did is addressed more neatly with the
>django.template.loaders.cached.Loader, as Josh Smeaton mentioned." and
>"Experimenting like this, even if you end up rediscovering something that
>exists" It is something different than django cache loader, of course I
>know django cache loader, I fixed a problem with django cached loader [4]
>five years ago :-). With django cache loader, we get django get a template
>quickly. But If your view finally render 3 templates, django cached loader
>will have to get 3 templates (from cache). With my proposal your view
>render only 1 template (This is not 100% true, 1 + templates about
>templatetags except extends and include)
>
> Jani:
>
> Currently you only need move the new template result to the old path of
> the template. But it is only because I want. If you change this line [5]
> for this other you don't need any change:
>
> destination_name = template.origin.name
>
>
> 8 years ago I requested a feature related with templates
>

[6]


, now I have a new request :-) 8 years ago I tried resolved my proposal,
> now I only want propose something :-D
>
> I think in this change for Django :-)
>
>
> REF's
>
> 1.
> https://github.com/django/django/pulls?q=is%3Apr+author%3Agoinnn+is%3Aclosed
> 2.
> https://code.djangoproject.com/query?status=assigned=closed=new=~pmartin=id=summary=status=owner=type=component=version=1=id
> 3. https://gist.github.com/goinnn/8a42314fccdd13bcf4df256a277ec1f6
> (tested in Django 1.8 - 1.11)
> 4.
> https://github.com/django/django/pull/1936/commits/e669bca5c8fe6d13ea745d338203cd9e7470ae6b
> 5.
> https://gist.github.com/goinnn/8a42314fccdd13bcf4df256a277ec1f6#file-unify_templates-py-L58
> 6. https://code.djangoproject.com/ticket/15053
>
>
> Best,
>
>
> El vie., 18 ene. 2019 a las 14:11, Jani Tiainen ()
> escribió:
>
>> Hi.
>>
>> Does this require changes to django internals or can it work as an
>> external package?
>>
>> Also you should release it as a package so people can start using it,
>> also preferably releasing it with BSD license like Django itself is.
>> Otherwise there are very little chances that your solution would make to
>> django it self.
>>
>> Improvements to rendering are always welcome, but they must come without
>> too much maintenance burden.
>>
>> On Thu, Jan 17, 2019 at 11:02 AM J. Pablo Martín Cobos 
>> wrote:
>>
>>> Hi,
>>>
>>> From one year ago, I am using an own command for Django templates that
>>> unify them. With an example it is easy to see. If I am to render for
>>> example a template call news.html like it:
>>>
>>> 1. news.html
>>>
>>> {% extends "base.html" %}
>>>
>>> {% block title %}
>>> {% include "inc.news.title.html" %}
>>> {% endblock %}
>>>
>>> {% block content %}
>>> {% for news_item in news %}
>>> {{ news_item.title }}
>>> {{ news_item.subtitle }}
>>> {% endfor %}
>>> {% endblock %}
>>>
>>> 2. base.html
>>>
>>> >> http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
>>> http://www.w3.org/1999/xhtml; lang="{{
>>> LANGUAGE_CODE|default:"en-us&

Re: What do you think about unify templates feature?

2019-01-18 Thread J . Pablo Martín Cobos
Hi another time,

I am tring to reply every people in this email:

Josh

I was not using django.template.loaders.cached.Loader, but the result are
very similar i.e:

App Template Num templates rendered before unify Num templates rendered
after unify AVG Time render template before unify (ms) AVG Time render
template after unify (ms)
Django admin admin/index.html 3 1 80 70
Django constance admin/constance/change_list.html 7 1 330 180
Django su su/login.html 5 3 10 5

Pavlos:

   1. Yes, I wrote this email to contribute another time. Actually I am
   already Django contributor[1][2]
   2. I didn't share my code, because it is not a nice code. *For me it is
   a teoric question. I don't want anybody have a bad opinion of this proposal
   for the implementation*. But I am sharing [3] it without problems, but
   please I know this solution is incomplete for many reason.
   3. About your question: "I am not sure I understood anything so far. Are
   you just pre-rendering {% include %} tags, so the template engine doesn't
   have to do that in runtime?" Yes :-)
   4. About it: "I think what you did is addressed more neatly with the
   django.template.loaders.cached.Loader, as Josh Smeaton mentioned." and
   "Experimenting like this, even if you end up rediscovering something that
   exists" It is something different than django cache loader, of course I
   know django cache loader, I fixed a problem with django cached loader [4]
   five years ago :-). With django cache loader, we get django get a template
   quickly. But If your view finally render 3 templates, django cached loader
   will have to get 3 templates (from cache). With my proposal your view
   render only 1 template (This is not 100% true, 1 + templates about
   templatetags except extends and include)

Jani:

Currently you only need move the new template result to the old path of the
template. But it is only because I want. If you change this line [5] for
this other you don't need any change:

destination_name = template.origin.name


8 years ago I requested a feature related with templates, now I have a new
request :-) 8 years ago I tried resolved my proposal, now I only want
propose something :-D

I think in this change for Django :-)


REF's

1.
https://github.com/django/django/pulls?q=is%3Apr+author%3Agoinnn+is%3Aclosed
2.
https://code.djangoproject.com/query?status=assigned=closed=new=~pmartin=id=summary=status=owner=type=component=version=1=id
3. https://gist.github.com/goinnn/8a42314fccdd13bcf4df256a277ec1f6 (tested
in Django 1.8 - 1.11)
4.
https://github.com/django/django/pull/1936/commits/e669bca5c8fe6d13ea745d338203cd9e7470ae6b
5.
https://gist.github.com/goinnn/8a42314fccdd13bcf4df256a277ec1f6#file-unify_templates-py-L58
6. https://code.djangoproject.com/ticket/15053


Best,


El vie., 18 ene. 2019 a las 14:11, Jani Tiainen ()
escribió:

> Hi.
>
> Does this require changes to django internals or can it work as an
> external package?
>
> Also you should release it as a package so people can start using it, also
> preferably releasing it with BSD license like Django itself is. Otherwise
> there are very little chances that your solution would make to django it
> self.
>
> Improvements to rendering are always welcome, but they must come without
> too much maintenance burden.
>
> On Thu, Jan 17, 2019 at 11:02 AM J. Pablo Martín Cobos 
> wrote:
>
>> Hi,
>>
>> From one year ago, I am using an own command for Django templates that
>> unify them. With an example it is easy to see. If I am to render for
>> example a template call news.html like it:
>>
>> 1. news.html
>>
>> {% extends "base.html" %}
>>
>> {% block title %}
>> {% include "inc.news.title.html" %}
>> {% endblock %}
>>
>> {% block content %}
>> {% for news_item in news %}
>> {{ news_item.title }}
>> {{ news_item.subtitle }}
>> {% endfor %}
>> {% endblock %}
>>
>> 2. base.html
>>
>> > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
>> http://www.w3.org/1999/xhtml; lang="{{
>> LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif
>> %}>
>> 
>> {% block title %}{% endblock %}
>> 
>> 
>> {% block content %}{% endblock %}
>> 
>> 
>>
>> 3. inc.news.title.html
>> News
>>
>> With this command I preproces every template of a settings variable and I
>> get something like this:
>>
>> news.unify.html
>>
>> > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
>> http://www.w3.org/1999/xhtml; lang="{{
>>

Re: What do you think about unify templates feature?

2019-01-18 Thread J . Pablo Martín Cobos
I answer between lines


El vie., 18 ene. 2019 a las 5:03, shiva kumar (<
kannamshivakumar...@gmail.com>) escribió:

> Could you please explain about it. I hadn't understood ur idea.
>


   1. Currently: with you render a view, this render a template. But
   usually, this template extends of another and include others. So Django has
   to get these templates to create an HTML. This process get time.
   2. My proposal: Preprocess templates for some (or all) them. Creating a
   template without extends or includes. So, in my previous email you can see,
   Django render less templates, so Django win time.

We can get a backend a  little faster with very little effort.

Best!



> On Thu 17 Jan, 2019 2:32 pm J. Pablo Martín Cobos 
>> Hi,
>>
>> From one year ago, I am using an own command for Django templates that
>> unify them. With an example it is easy to see. If I am to render for
>> example a template call news.html like it:
>>
>> 1. news.html
>>
>> {% extends "base.html" %}
>>
>> {% block title %}
>> {% include "inc.news.title.html" %}
>> {% endblock %}
>>
>> {% block content %}
>> {% for news_item in news %}
>> {{ news_item.title }}
>> {{ news_item.subtitle }}
>> {% endfor %}
>> {% endblock %}
>>
>> 2. base.html
>>
>> > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
>> http://www.w3.org/1999/xhtml; lang="{{
>> LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif
>> %}>
>> 
>> {% block title %}{% endblock %}
>> 
>> 
>> {% block content %}{% endblock %}
>> 
>> 
>>
>> 3. inc.news.title.html
>> News
>>
>> With this command I preproces every template of a settings variable and I
>> get something like this:
>>
>> news.unify.html
>>
>> > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
>> http://www.w3.org/1999/xhtml; lang="{{
>> LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif
>> %}>
>> 
>> News
>> 
>> 
>> {% for news_item in news %}
>> {{ news_item.title }}
>> {{ news_item.subtitle }}
>> {% endfor %}
>> 
>> 
>>
>> So I have a two improves:
>>
>>1. It is more fast. And in a real project a view can render easyly 50
>>templates
>>2. I use news.html to develop and news.unify.html to production. So I
>>don't lose legilibility.
>>
>>
>> What do you think about "unify templates feature"? Do you know if exists
>> a similar public project in github/gitlab/bitbucket etc?
>>
>>
>> Best,
>>
>> --
>> Pablo Martín Cobos
>> Computer engineer
>> Python/Django developer
>> 652 53 37 36
>> goi...@gmail.com
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-developers+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-develop...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-developers.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-developers/CALNyWLGNcuK8DTnU9w9fyGFhFfT3dAz7vfj3B%2BnDHWTfneLNFw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-developers/CALNyWLGNcuK8DTnU9w9fyGFhFfT3dAz7vfj3B%2BnDHWTfneLNFw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-develop...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/CAMsYeuFV3EV_3H%2BR0q9xi5Q6EQq6L2cLkatcvrTtSYW%3D2zRk7A%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-developers/CAMsYeuFV3EV_3H%2BR0q9xi5

Re: What do you think about unify templates feature?

2019-01-18 Thread J . Pablo Martín Cobos
I answer between lines

El jue., 17 ene. 2019 a las 18:42, Maciek Olko ()
escribió:

> Did you try to measure the difference in time of rendering standard and
> your way?
>
>
Yes. I have several examples:

App Template Num templates rendered before unify Num templates rendered
after unify Time render template before unify (ms) Time render template
after unify (ms) Improve
Django admin admin/index.html 3 1 75 - 110 71 - 79 22%
Django admin admin/change_list.html 26 Command error 180-300 Command error
Django admin admin/change_form.html 16 Command error 350-400 Command error
Django constance admin/constance/change_list.html 7 1 350-400 150-250 75%
Django su su/login.html 5 3 15- 20 10 - 12 54%

My command currently does not work with several complex templates like
admin/change_list.html or admin/change_form.html But we can improve it,
currently it works with almost all.

If there is a nice improve with views that render few templates... imagine
with views with a lot of templates.

I have measure these times with django-debug-toolbar-template-timings

With this email only I want to know if you see it can be a important
feature to add to Django framework... or it is a silly thing.

Best,



> Regards,
> Maciej
>
> czw., 17.01.2019, 10:02 użytkownik J. Pablo Martín Cobos 
> napisał:
>
>> Hi,
>>
>> From one year ago, I am using an own command for Django templates that
>> unify them. With an example it is easy to see. If I am to render for
>> example a template call news.html like it:
>>
>> 1. news.html
>>
>> {% extends "base.html" %}
>>
>> {% block title %}
>> {% include "inc.news.title.html" %}
>> {% endblock %}
>>
>> {% block content %}
>> {% for news_item in news %}
>> {{ news_item.title }}
>> {{ news_item.subtitle }}
>> {% endfor %}
>> {% endblock %}
>>
>> 2. base.html
>>
>> > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
>> http://www.w3.org/1999/xhtml; lang="{{
>> LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif
>> %}>
>> 
>> {% block title %}{% endblock %}
>> 
>> 
>> {% block content %}{% endblock %}
>> 
>> 
>>
>> 3. inc.news.title.html
>> News
>>
>> With this command I preproces every template of a settings variable and I
>> get something like this:
>>
>> news.unify.html
>>
>> > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
>> http://www.w3.org/1999/xhtml; lang="{{
>> LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif
>> %}>
>> 
>> News
>> 
>> 
>> {% for news_item in news %}
>> {{ news_item.title }}
>> {{ news_item.subtitle }}
>> {% endfor %}
>> 
>> 
>>
>> So I have a two improves:
>>
>>1. It is more fast. And in a real project a view can render easyly 50
>>templates
>>2. I use news.html to develop and news.unify.html to production. So I
>>don't lose legilibility.
>>
>>
>> What do you think about "unify templates feature"? Do you know if exists
>> a similar public project in github/gitlab/bitbucket etc?
>>
>>
>> Best,
>>
>> --
>> Pablo Martín Cobos
>> Computer engineer
>> Python/Django developer
>> 652 53 37 36
>> goi...@gmail.com
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-developers+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-develop...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-developers.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-developers/CALNyWLGNcuK8DTnU9w9fyGFhFfT3dAz7vfj3B%2BnDHWTfneLNFw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-developers/CALNyWLGNcuK8DTnU9w9fyGFhFfT3dAz7vfj3B%2BnDHWTfneLNFw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Djan

What do you think about unify templates feature?

2019-01-17 Thread J . Pablo Martín Cobos
Hi,

>From one year ago, I am using an own command for Django templates that
unify them. With an example it is easy to see. If I am to render for
example a template call news.html like it:

1. news.html

{% extends "base.html" %}

{% block title %}
{% include "inc.news.title.html" %}
{% endblock %}

{% block content %}
{% for news_item in news %}
{{ news_item.title }}
{{ news_item.subtitle }}
{% endfor %}
{% endblock %}

2. base.html

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
http://www.w3.org/1999/xhtml; lang="{{
LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif
%}>

{% block title %}{% endblock %}


{% block content %}{% endblock %}



3. inc.news.title.html
News

With this command I preproces every template of a settings variable and I
get something like this:

news.unify.html

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>
http://www.w3.org/1999/xhtml; lang="{{
LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif
%}>

News


{% for news_item in news %}
{{ news_item.title }}
{{ news_item.subtitle }}
{% endfor %}



So I have a two improves:

   1. It is more fast. And in a real project a view can render easyly 50
   templates
   2. I use news.html to develop and news.unify.html to production. So I
   don't lose legilibility.


What do you think about "unify templates feature"? Do you know if exists a
similar public project in github/gitlab/bitbucket etc?


Best,

-- 
Pablo Martín Cobos
Computer engineer
Python/Django developer
652 53 37 36
goi...@gmail.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/CALNyWLGNcuK8DTnU9w9fyGFhFfT3dAz7vfj3B%2BnDHWTfneLNFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-EmailSending with PHP

2018-12-06 Thread Nagarjuna J
sendgrid was paid service so i want price less service. is there any option
to get this service without price

On Thu, Dec 6, 2018 at 2:38 PM Andréas Kühne 
wrote:

> Hi,
>
> I'm sorry, but I think this is a really strange request - why would you
> want to send email with PHP? The thing is that PHP itself needs a SMTP
> server to send the email with - so you'll just be moving the configuration
> to a different place - you can use the SMTP settings from the PHP server in
> Django and you should be good to go?
>
> Or what do you mean by "php mailing"?
>
> Regards,
>
> Andréas
>
>
> Den tors 6 dec. 2018 kl 09:53 skrev :
>
>> hi guys, Now am using sendgrid to send_email in django(using SMTP). But i
>> need to add php mailing  in django (django PHP Email integration ).
>> Is there any way to integrate PHP Email with django?
>>
>> --
>> 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/add62163-c36a-4b3d-a051-58101ca68f77%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/CAK4qSCe0sCACEmDqB87GJg_Pwsvc%2BDLTYeMUHefgaiEz2JPY%2Bw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Thanks,
-
J.V.Nagarjuna Reddy,
7207203544,
8328031020.

-- 
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/CADK%2B6-B4YrQ%2Bf6%2BrvuHKSQ7xXFPfYGj7K%3DqaZ-X6jN4NGzba%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django-EmailSending with PHP

2018-12-06 Thread nagarjuna . j
hi guys, Now am using sendgrid to send_email in django(using SMTP). But i 
need to add php mailing  in django (django PHP Email integration ).
Is there any way to integrate PHP Email with django?  

-- 
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/add62163-c36a-4b3d-a051-58101ca68f77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error in function to return permissions

2018-10-31 Thread Stephen J. Butler
@login_required needs "request" as the first parameter.

On Wed, Oct 31, 2018 at 11:58 AM Joel Mathew  wrote:

> I have a custom function to check if a user is authorized to do
> certain functions:
>
> @login_required
> def checkpermission(request, permiss):
> username = request.user.username
> print(f"username is {username}")
> print(f"User.objects.filter() is {User.objects.filter()}")
> userobj = User.objects.get(username=username)
> print(dir(userobj))
> print(userobj.user_permissions.all())
> print(Permission.objects.filter(group__user=userobj))
> perms = getpermissions(userobj)
> for perm in perms:
> p = perm.name.lower().replace(" ", "_")
> if permiss == p:
> print("Has permission: %s" % p)
> return True
> print("No")
> return False
>
> def getpermissions(userobj):
> if userobj.is_superuser:
> return Permission.objects.all()
> return userobj.user_permissions.all() |
> Permission.objects.filter(group__user=userobj)
>
> The problem arises if I write the previous function with decorator:
>
> @login_required
> def getpermissions(userobj):
> if userobj.is_superuser:
> return Permission.objects.all()
> return userobj.user_permissions.all() |
> Permission.objects.filter(group__user=userobj)
>
> In this case, I get the error:
>
> 2018-10-31 21:26:51,239 django.request ERRORInternal Server Error:
> /clinic/joelent/doctors
> Traceback (most recent call last):
>   File
> "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/exception.py",
> line 34, in inner
> response = get_response(request)
>   File
> "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py",
> line 126, in _get_response
> response = self.process_exception_by_middleware(e, request)
>   File
> "/home/joel/.local/lib/python3.6/site-packages/django/core/handlers/base.py",
> line 124, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File
> "/home/joel/.local/lib/python3.6/site-packages/django/contrib/auth/decorators.py",
> line 21, in _wrapped_view
> return view_func(request, *args, **kwargs)
>   File "/home/joel/myappointments/clinic/views.py", line 2797, in
> clinicdoctorlist
> if checkpermission(request, "can_change_doctor") and
> HasMembership(request, cliniclabel):
>   File
> "/home/joel/.local/lib/python3.6/site-packages/django/contrib/auth/decorators.py",
> line 21, in _wrapped_view
> return view_func(request, *args, **kwargs)
>   File "/home/joel/myappointments/clinic/views.py", line 2970, in
> checkpermission
> perms = getpermissions(userobj)
>   File
> "/home/joel/.local/lib/python3.6/site-packages/django/contrib/auth/decorators.py",
> line 20, in _wrapped_view
> if test_func(request.user):
> AttributeError: 'User' object has no attribute 'user'
>
> Why would this be happening?
>
> Sincerely yours,
>
> 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_94fELQWM873_y6w%2B0S8vCA2xtO44sG45dqMp4DSC8qeQ%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/CAD4ANxVoNhmE78-n0SQFn1QFFz1O9-wXBs9p5G8jfsiXa190Kw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Regarding FileResponse and compressed file objects. Bug?

2018-10-30 Thread Zachary J.
Consider this situation:

import gzip
from django.http import FileResponse


def some_request(request):
return FileResponse(
gzip.open('/path/to/filename.gz'),
content_type="text/plain",
filename="filename.txt",
as_attachment=True
)


This theoretically should work fine, because why shouldn't it?

However the code that determines the Content-Length is as such (
https://github.com/django/django/blob/c1c68d1ac0f0d50eb37df32892b132f31a1179da/django/http/response.py#L425
):

if os.path.isabs(filename):
self['Content-Length'] = os.path.getsize(filelike.name)
elif hasattr(filelike, 'getbuffer'):
self['Content-Length'] = filelike.getbuffer().nbytes


Which gets the file size of the *compressed* gzip file. (the elif branch is 
never run) That means that the Content-Length will be shorter than the 
*uncompressed* content that I am actually sending.

My current "dumb" solution is as such:

from io import BytesIO
import shutil


def some_request(request):
buff = BytesIO()
with gzip.open('/path/to/filename.gz') as g:

shutil.copyfileobj(g, buff)
buff.seek(0)

return FileResponse(

buff,
content_type="text/plain",
filename="filename.txt",
as_attachment=True
)


This reads all the uncompressed content into a separate file-like object 
that does not have the original file name information. Which forces 
FileResponse to run the elif branch. Is there a better way to do things?

-- 
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/f53a5bea-1b52-4e22-8e2b-a88c2c1da5ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Refund issue with paypal using django and python

2018-10-18 Thread nagarjuna . j
I'll use django-paypal for processing payments in my site, but, I need the 
*refund* funcionality, wich I didnt find in the django-paypal docs. How can 
I achieve this, if django-paypal doesnt has this featured I'd to move to 
other package, in that case, any reccommendation?

-- 
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/2d2ef456-75eb-4ecb-af56-92ce8ecf8087%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating superuser

2018-10-05 Thread Nagarjuna J
once migrations are completed successfully.
then check urls.py, bellow two lines are there are not

from django.contrib import admin

path('admin/', admin.site.urls),

then browse this

http://127.0.0.1:8000/admin



On Fri, Oct 5, 2018 at 4:36 PM VIPIN VIPIN  wrote:

> This is not working
>
>
> On Thursday, October 4, 2018 at 11:53:42 PM UTC+5:30, SHUBHAM .SINGH.
> RATHORE wrote:
>>
>> First of all makemigrations and migrate than creatsuperuser
>>
>>
>> On Thu 4 Oct, 2018 11:47 pm VIPIN VIPIN,  wrote:
>>
>>> id is : 12345
>>
>>  password: 12345Vipin
>>>
>>> --
>>> 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/b0f738fc-4b78-47b2-9680-455772b039c3%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/6ae097dc-3615-4f84-9810-6769387eeefa%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Thanks,
-
J.V.Nagarjuna Reddy,
7207203544,
8328031020.

-- 
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/CADK%2B6-ANfNrgw%2BJFoVPF5K_kLFWS5%2B1y1M2JaJhq%3D4zCaK9fOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to call the super class instance variables in sub class in python3

2018-10-03 Thread nagarjuna . j
how i can call super class instance varibles in subclass (python3)

-- 
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/f6a92d85-7311-4f7a-8460-185a51b20154%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: __init__.py Won't Upload To Github Respository

2018-09-01 Thread Stephen J. Butler
GitHub has an excellent set of gitignore files. My first commit to a
project is always one of these:

https://github.com/github/gitignore

In particular:
https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore


On Sat, Sep 1, 2018 at 10:52 AM Kasper Laudrup 
wrote:

> Hi Sandy,
>
> On 01/09/2018 17.18, Sandy Leon wrote:
> > Hello everyone,
> > I am trying to upload my Django site files to github to then deploy with
> > Heroku.
> > I have had no major problems except in trying to upload the folder that
> > contains my Django site, github gets stuck on trying to upload '
> > /mysite/polls/__pycache__/__init__.cpython-36.pyc'
> > Just to be clear, my project is called 'mysite' and the app that I made
> > following the Django tutorial is called polls.
> > Thanks you in advance to anyone who can help.
> >
>
> I have no idea why you are not able to upload these files, but you
> shouldn't be uploading cache files or compiled python modules to you git
> repository anyway.
>
> If you have any of these files in your local git repository, remove them
> using "git rm".
>
> Something like:
>
> # find -name __pycache__ -exec git rm -r {} \;
>
> And:
>
> # find -name *.pyc -exec git rm {} \;
>
> Ought to do it.
>
> Then commit these changes with something like:
>
> # git commit -m "Remove cache and object files from repository"
>
> Finally add cache and compiled object files to you .gitignore. Something
> like:
>
> *.pyc
> __pycache__
>
> And try to push your changes again.
>
> Be aware that I have not actually tested any of these commands, so
> please be careful before blindly executing them.
>
> Hope that helps a bit.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> 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/12e119ed-9ffe-d30a-2f88-71f8c70c37dd%40stacktrace.dk
> .
> 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/CAD4ANxVoJg7y9%2B6jga5PSpCR%3Dc0hGy6F2DBTqDY%3Di9nO7RVv7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Optimizing Prefetch for Postgres IN Limit

2018-07-27 Thread Ram J
Hi Xof,

I realized what you meant regd the optimizer and understood why my query
was doing a full table scan. The issue was that column through which I
prefetching has a lot of NULLs so we have a partial index on NOT NULL and
the optimizer is getting fooled by that. Adding a IS NOT NULL in the same
query makes the optimizer use the index again.

Thanks
Ram


On Thu, Jul 26, 2018 at 10:09 PM Ram J  wrote:

> Hi Xof,
>
> The issue is that, when you do a naive Prefetch you are left with nothing
> but Django’s auto generated IN query. I was asking about he recommended way
> to make this into a JOIN, which is not obvious how to do with Django
>
> Also in my case the naive IN query on the PK *did not* generate a Index
> scan and ended up being a full table scan
>
> I could have however used a Prefetch object to force PG to use a different
> index apart from the PK but a naive Prefetch of the form
> queryset.prefetch(‘table__table2’) does not use any index beyond 100 values
>
> Also it’s hard to estimate how many values will be there in a nested
>  prefetch, to state the obvious, to do anything different on a query by
> query basis
>
>
> On Thu, Jul 26, 2018 at 19:35 Christophe Pettus  wrote:
>
>>
>> > On Jul 25, 2018, at 02:59, Jason  wrote:
>> >
>> > Where do you get that in the pg documentation? I can't find that
>> anywhere (google-fu may be failing me), and we do have some queries with
>> more than 100 values using IN.
>>
>> It's slightly more complicated than that.  Above 100 entries, the
>> PostgreSQL optimizer won't try to do optimizations of the form changing i
>> IN (1, 2 ..., 101) to (i = 1) OR (i = 2) OR  (i = 3)... to see if there's a
>> better way of executing the query.  It *can* still do an index scan in
>> those cases, although the more entries in the IN list, the less efficient
>> that will be.  In general, large IN clauses aren't a great idea; they're
>> better replaced with a join.
>>
>> --
>> -- Christophe Pettus
>>x...@thebuild.com
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/y9sVr9Pbr-o/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/8A21227D-94A9-459F-89D0-771D3052C0C0%40thebuild.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
Ram J

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


Re: Optimizing Prefetch for Postgres IN Limit

2018-07-26 Thread Ram J
Hi Xof,

The issue is that, when you do a naive Prefetch you are left with nothing
but Django’s auto generated IN query. I was asking about he recommended way
to make this into a JOIN, which is not obvious how to do with Django

Also in my case the naive IN query on the PK *did not* generate a Index
scan and ended up being a full table scan

I could have however used a Prefetch object to force PG to use a different
index apart from the PK but a naive Prefetch of the form
queryset.prefetch(‘table__table2’) does not use any index beyond 100 values

Also it’s hard to estimate how many values will be there in a nested
 prefetch, to state the obvious, to do anything different on a query by
query basis


On Thu, Jul 26, 2018 at 19:35 Christophe Pettus  wrote:

>
> > On Jul 25, 2018, at 02:59, Jason  wrote:
> >
> > Where do you get that in the pg documentation? I can't find that
> anywhere (google-fu may be failing me), and we do have some queries with
> more than 100 values using IN.
>
> It's slightly more complicated than that.  Above 100 entries, the
> PostgreSQL optimizer won't try to do optimizations of the form changing i
> IN (1, 2 ..., 101) to (i = 1) OR (i = 2) OR  (i = 3)... to see if there's a
> better way of executing the query.  It *can* still do an index scan in
> those cases, although the more entries in the IN list, the less efficient
> that will be.  In general, large IN clauses aren't a great idea; they're
> better replaced with a join.
>
> --
> -- Christophe Pettus
>x...@thebuild.com
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/y9sVr9Pbr-o/unsubscribe.
> To unsubscribe from this group and all its topics, 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/8A21227D-94A9-459F-89D0-771D3052C0C0%40thebuild.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/CAAW8NzkO4afBsP11yF1SbJq2EZsSBiWhAwSma7QZd%2BtCQULHjg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


help in understanding the sqlite3 backend

2018-07-07 Thread Sumit J
Hello,

I am trying to understand the sqlite3 backend, especially the 
register_converter part.

I wanted to understand why are those converters put in place?
I commented out this registration and even then was able to to query the 
database in django shell via the ORM..
Even raw query execution returned correct results.

Is it there to maintain backward compatibility ? (guessing)

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/047f179e-8d10-4752-8a67-7480d5a7074f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Decorator function argument woes

2018-04-30 Thread Stephen J. Butler
Yes. I don't see it in the documentation for login_required, but I believe
it's so that you can do something like this in your urls.py:

urlpatterns = [
url(r'^example$', login_required(views.example)),
]

That might be an older way of using the decorator? IDK for sure. But you
can see from the code for login_required that the "test" is always a lambda
that checks if the user is authenticated; there's no option to override it.
If the "function" parameter is present then it is used as the function be
wrapped, not the test being done.

On Mon, Apr 30, 2018 at 1:24 AM, Mike Dewhirst <mi...@dewhirst.com.au>
wrote:

> On 30/04/2018 3:35 PM, Stephen J. Butler wrote:
>
>> @login_required doesn't take a test function. You need to use
>> @user_passes_test directly.
>>
>
> Thank you Stephen.
>
> I thought I'd start another thread to ask about my use case of being able
> to require login or not depending on whether the content needed a login or
> not ... but ... just as I was thinking about it I had another look at
> login_required and thought I'd ask one more question.
>
> Its signature is ...
>
> def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME,
> login_url=None):
>
> Are you saying that function is the the view function?
>
> M
>
>
>> On Mon, Apr 30, 2018 at 12:26 AM, Mike Dewhirst <mi...@dewhirst.com.au
>> <mailto:mi...@dewhirst.com.au>> wrote:
>>
>> I'm pretty sure this is a not-understanding-python problem rather
>> than a Django problem but here goes ...
>>
>> In a (FBV) view I'm trying to pass a function in to the
>> login_required decorator. My function is called 'is_login_needed'
>> and I want the login_required decorator to effectively switch
>> itself off if login is not needed.
>>
>> The scenario is on-line training and if the training instruction
>> has questions with scores then obviously the user needs to login.
>> On the other hand if it is simply a demonstration video or plain
>> blah with no questions/answers/scores it should be viewable by
>> anyone whether they are logged in or not.
>>
>> My function goes like this and the docstring reveals my
>> understanding ...
>>
>> def is_login_needed(user):
>>
>> """ the login_required decorator has a user_passes_test()
>> function as
>>
>> its first arg. If it returns True, no login is required.
>> user.login_here
>>
>> is always set equal to the selected course.login_needed. For
>> courses
>>
>> needing a login, self.is_authenticated must be True. For
>> courses not
>>
>> needing a login, self.is_authenticated may return anything but
>> this
>>
>> function passed to the login_required decorator must return True
>>
>> """
>>
>> if not user.login_here:
>>
>> return True
>>
>>
>> So   the problem is that manage.py runserver reports an attribute
>> error saying the function (presumably mine) does not have an
>> attribute 'user' ... like this ...
>>
>>File
>> "C:\Users\mike\envs\xxct3\train\course\urls.py", line 8, in 
>>
>> from .views import (finished_course_view, course_view, index_view,
>>
>>   File "C:\Users\mike\envs\xxct3\train\course\views.py", line 172,
>> in 
>>
>> def course_view(request, pk=None, slug=None):
>>
>>   File
>> "C:\Users\mike\envs\xxct3\lib\site-packages\django\contrib\a
>> uth\decorators.py",
>> line 22, in _wrapped_view
>>
>> if test_func(request.user):
>>
>> AttributeError: 'function' object has no attribute 'user'
>>
>> If that 'function' is my 'is_login_needed' function I'm inclined
>> to think it obviously has a 'user' attribute.
>>
>> Here is the contrib.auth.decorators.login_required source
>> (preceded by user_passes_test which it calls) from Django 1.11
>>
>> My reading of the following  is that my own 'is_login_needed'
>> function passed in via @login_required(is_login_needed,
>> login_url='login') as the first positional argument is then passed
>> to the 'user_passes_test' decorator as 'test_func'  ...
>>
>>
>> def user_passes_test(test_func, login_url=None,
>> redirect_field_name=REDIRECT_FIELD_NAME):
>>
>> """
>>
>> D

Re: Decorator function argument woes

2018-04-29 Thread Stephen J. Butler
@login_required doesn't take a test function. You need to use
@user_passes_test directly.

On Mon, Apr 30, 2018 at 12:26 AM, Mike Dewhirst 
wrote:

> I'm pretty sure this is a not-understanding-python problem rather than a
> Django problem but here goes ...
>
> In a (FBV) view I'm trying to pass a function in to the login_required
> decorator. My function is called 'is_login_needed' and I want the
> login_required decorator to effectively switch itself off if login is not
> needed.
>
> The scenario is on-line training and if the training instruction has
> questions with scores then obviously the user needs to login. On the other
> hand if it is simply a demonstration video or plain blah with no
> questions/answers/scores it should be viewable by anyone whether they are
> logged in or not.
>
> My function goes like this and the docstring reveals my understanding ...
>
> def is_login_needed(user):
>
> """ the login_required decorator has a user_passes_test() function as
>
> its first arg. If it returns True, no login is required. user.login_here
>
> is always set equal to the selected course.login_needed. For courses
>
> needing a login, self.is_authenticated must be True. For courses not
>
> needing a login, self.is_authenticated may return anything but this
>
> function passed to the login_required decorator must return True
>
> """
>
> if not user.login_here:
>
> return True
>
>
> So   the problem is that manage.py runserver reports an attribute error
> saying the function (presumably mine) does not have an attribute 'user' ...
> like this ...
>
>   
>
>   File "C:\Users\mike\envs\xxct3\train\course\urls.py", line 8, in 
>
> from .views import (finished_course_view, course_view, index_view,
>
>   File "C:\Users\mike\envs\xxct3\train\course\views.py", line 172, in 
>
> def course_view(request, pk=None, slug=None):
>
>   File 
> "C:\Users\mike\envs\xxct3\lib\site-packages\django\contrib\auth\decorators.py",
>  line 22, in _wrapped_view
>
> if test_func(request.user):
>
> AttributeError: 'function' object has no attribute 'user'
>
> If that 'function' is my 'is_login_needed' function I'm inclined to think
> it obviously has a 'user' attribute.
>
> Here is the contrib.auth.decorators.login_required source (preceded by
> user_passes_test which it calls) from Django 1.11
>
> My reading of the following  is that my own 'is_login_needed' function
> passed in via @login_required(is_login_needed, login_url='login') as the
> first positional argument is then passed to the 'user_passes_test'
> decorator as 'test_func'  ...
>
>
> def user_passes_test(test_func, login_url=None, 
> redirect_field_name=REDIRECT_FIELD_NAME):
>
> """
>
> Decorator for views that checks that the user passes the given test,
>
> redirecting to the log-in page if necessary. The test should be a callable
>
> that takes the user object and returns True if the user passes.
>
> """
>
> def decorator(view_func):
>
> @wraps(view_func, assigned=available_attrs(view_func))
>
> def _wrapped_view(request, *args, **kwargs):
>
> if test_func(request.user):
>
> return view_func(request, *args, **kwargs)
>
> path = request.build_absolute_uri()
>
> resolved_login_url = resolve_url(login_url or settings.LOGIN_URL)
>
> # If the login url is the same scheme and net location then just
>
> # use the path as the "next" url.
>
> login_scheme, login_netloc = urlparse(resolved_login_url)[:2]
>
> current_scheme, current_netloc = urlparse(path)[:2]
>
> if ((not login_scheme or login_scheme == current_scheme) and
>
> (not login_netloc or login_netloc == current_netloc)):
>
> path = request.get_full_path()
>
> from django.contrib.auth.views import redirect_to_login
>
> return redirect_to_login(
>
> path, resolved_login_url, redirect_field_name)
>
> return _wrapped_view
>
> return decorator
>
>
>
> def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME, 
> login_url=None):
>
> """
>
> Decorator for views that checks that the user is logged in, redirecting
>
> to the log-in page if necessary.
>
> """
>
> actual_decorator = user_passes_test(
>
> lambda u: u.is_authenticated,
>
> login_url=login_url,
>
> redirect_field_name=redirect_field_name
>
> )
>
> if function:
>
> return actual_decorator(function)
>
> return actual_decorator
>
> Could someone please explain where I'm stuffing up. I reckon I'm confused
> about which function the AttributeError is complaining.
>
> Many thanks for any help
>
> Mike
>
>
>
>
> --
> 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 

Create custom widget in django-jet

2018-04-13 Thread j . romeroc97
Hey everybody, I'm here for some help, I'm using django-jet right now and 
trying to create a new widget with a view that I created before, somebody 
has knowledge about how to do this?

-- 
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/8c4799b8-a32d-40a9-b529-4fed246ea83e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: import file from view.py

2018-03-14 Thread Mahesh M J
Hi,
You can try to create a Python module and write a parser there and set the
variables. You can import that file in views.py and use it for getting the
relevant values. Hope this helps.

Thanks,
Mahesh.

On Tue, Mar 13, 2018 at 21:06 sum abiut  wrote:

> I have a conf file containing the parameter of hostmane,db,usernam,pass, db
>
> i want to import that file from view.py and use parameter from the conf
> file to connect to a db.
>
> i did something this from appname.conf import but it doesn't seem to work,
> appreciate any assistance.
>
> 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/CAPCf-y5Og0o5yb_e%3D6ggLjS%2BOtDyZFUoqe_9KYZLbC1w72g7MA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Mahesh M.J
Bioinformatics Consultant
Novartis Pharmaceuticals
1 Health Plaza, East Hanover
New Jersey-07039

-- 
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/CAHJ%2BPuSW1eb4t2bPvgnN8L_LAAt862wwYHCEjamhDRX3cW%2BR%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Redirect to DetailView with success_url.

2018-03-06 Thread j . romeroc97
Hi!, I have a question and I hope you guys can help me, 

I wanna redirect to a DetailView using the success_url from my CreateView.

How is this, I have a CreateView to save a device, and I wanna do that once 
the device is saved, redirect to DetailView to show a QR Code and vinculate 
with Google Authenticator or Authy like apps.

Any advice to do this? Thanks anyway!

-- 
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/c16e199a-5d8e-485a-9e86-f5b154379118%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 2 decimals, always

2018-01-21 Thread Carmelo J . Morales Muñoz
thankd for your help its ok thanks!...

El viernes, 19 de enero de 2018, 14:13:24 (UTC+1), Kasper Laudrup escribió:
>
> Hi Carmelo, 
>
> On 2018-01-19 13:24, Carmelo J. Morales Muñoz wrote: 
> > hello! 
> > 
> > I don´t know how solve this... I need django show always float numbers 
> > in this format: 
> > 
> > 1234.56 
> > 
> > actually use 1 decimal only, example:   1234,1 
> > 
> > I need 1234,10 
> > 
>
> You don't write anything about which context you're talking about, but 
> assuming you're talking about the Django templating system, you should 
> have a look at this: 
>
> https://docs.djangoproject.com/en/2.0/ref/templates/builtins/#floatformat 
>
> Cheers, 
>
> Kasper 
>

-- 
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/021269e8-c6bc-4150-b812-8a87e3ddc1ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and Oracle12C Connection Error

2018-01-20 Thread Stephen J. Butler
Your Django settings 'NAME' is neither a SID nor a service name. Try:

'NAME': 'testdb',
'USERNAME': 'C##TDBUSER',
'PASSWORD': 'testdb',
'HOST': 'localhost',
'PORT': 1521


On Fri, Jan 19, 2018 at 11:37 PM, Rishab Kumar  wrote:

> https://stackoverflow.com/questions/48352888/connect-django-with-oracle12c
>
> --
> 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/51de7b27-425c-4b5b-bf0e-e650b2363e19%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/CAD4ANxXx6ijSDEX_LgJU7CJxyH%2BJkDSGMmCkaXDjP-GSE6MXyg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


2 decimals, always

2018-01-19 Thread Carmelo J . Morales Muñoz
hello!

I don´t know how solve this... I need django show always float numbers in 
this format:

1234.56 

actually use 1 decimal only, example:   1234,1

I need 1234,10

thanks for your 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/4448d0ec-4796-4d88-9b09-0f17a4f3870f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple websites on same host using Apache as Webserver.

2018-01-19 Thread Carmelo J . Morales Muñoz
I have same problen you, i have use gunicorn but I don´t know how can I 
solve it

El miércoles, 17 de enero de 2018, 13:09:16 (UTC+1), Mahesh Vernekar 
escribió:
>
> Can someone provide help on configuring multiple websites on the same host.
> I have tried the appropriate configuration.
> But the new website created opens in the folder of the old website.
>
> 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/c45b6841-0d91-4ddd-8567-018c37db348c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Session Variables

2017-05-28 Thread yeddu . j . prasad
Dear Experts, I am new to Django and need your help.

I want a set of variables populated into session variables. These will be 
fixed values for the user such as which company he belongs to, his email 
id, his role etc. 

These values will be read from the database by the login form. These values 
need to stay in these variables as long as the user is logged into the 
application.

I will be using these variables to decide what data the user can see.

Question I have is "Will these values be different for each user who is 
logged in or are these global to the application and all the users will see 
these same values?

I am using the below code to get the values from the table called "users" 
where userroles, companyid are fields in the table

 tFetchData = users.objects.get(emailid = lEmailId)

request.session['sPassword'] = tFetchData.userroles
request.session['sCompanyId'] = tFetchData.companyid

-- 
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/1b6fdc83-26dd-4d7f-879c-95aacc282f59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple uwsgi apps in one project

2017-05-26 Thread marcin . j . nowak
Thanks.
Could you explain last point about 3 different sites?

As I said I'd like to have separate middlewares and urls.
Currently I have two Django projects defined, they share app paths and most 
of settings (middlewares are redefined and urls are separate).  

Marcin


W dniu piątek, 26 maja 2017 13:31:46 UTC+2 użytkownik Jani Tiainen napisał:
>
> Ok,
> There are several ways how to tackle with this (you can do most of that 
> with webserver configs). Just limit access from proper IP's (if your VPN is 
> setup decently it will give your end users certain IP-range(s) which you 
> can use to filter admin-access) same for "local network" app.
>
> But this doesn't really affect uswgi-serving at all it will still do it's 
> work as usual since it's more problem of frontend parts that sits before 
> uwsgi.
>
> Alternatively you could define 3 different sites that do ran limited 
> ranges of URLs and route them through the front end (and apply same 
> restrictions as one site model)
>
>
> On 26.05.2017 14:22, marcin@gmail.com  wrote:
>
> I think that my reqs are pretty straightforward. 
> I'd like to setup project environment with 3 different apps:
>
>1. main app (public) 
>2. admin app (vpn) 
>3. local network app for api talking with other services in the 
>datacenter   
>
> The whole thing is about preserving same project environment.
> Models, registries, configuration should stay same.
> Middlewares, urls, views and anything related to http will be different.
>
> BR,
> Marcin
>
> W dniu piątek, 26 maja 2017 13:16:49 UTC+2 użytkownik Jani Tiainen 
> napisał: 
>>
>> Hi,
>>
>> Your requirements are a bit contradicting.
>>
>> While you want to use same app with identical settings twice to different 
>> domain, you also want to have different urls? 
>>
>> How these urls should be different compared to that other site?
>>
>> On 26.05.2017 13:26, marcin@gmail.com wrote:
>>
>> Hi. 
>>
>> I'd like to serve more uwsgi apps for the same project. 
>> These apps must have just separate urls and must be served on spearate 
>> domains. 
>> I'd like to have separate appservers. 
>> The rest, i.e. project's environment, should stay same. 
>>
>> How to achieve that? 
>> I know I can create a new django projects and import/copy main app's 
>> settings. Is there an other way? 
>>
>> BR,
>> Marcin
>> -- 
>> 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/0da53e34-428d-4803-ba8f-dddc83c24443%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> -- 
>> Jani Tiainen
>>
>> -- 
> 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/457fa003-6515-40d3-a661-a402cf45b5db%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> -- 
> Jani Tiainen
>
>

-- 
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/aa3c925e-e747-44ce-9238-acd320646e47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple uwsgi apps in one project

2017-05-26 Thread marcin . j . nowak
I think that my reqs are pretty straightforward.
I'd like to setup project environment with 3 different apps:

   1. main app (public)
   2. admin app (vpn)
   3. local network app for api talking with other services in the 
   datacenter  

The whole thing is about preserving same project environment.
Models, registries, configuration should stay same.
Middlewares, urls, views and anything related to http will be different.

BR,
Marcin

W dniu piątek, 26 maja 2017 13:16:49 UTC+2 użytkownik Jani Tiainen napisał:
>
> Hi,
>
> Your requirements are a bit contradicting.
>
> While you want to use same app with identical settings twice to different 
> domain, you also want to have different urls? 
>
> How these urls should be different compared to that other site?
>
> On 26.05.2017 13:26, marcin@gmail.com  wrote:
>
> Hi. 
>
> I'd like to serve more uwsgi apps for the same project. 
> These apps must have just separate urls and must be served on spearate 
> domains. 
> I'd like to have separate appservers. 
> The rest, i.e. project's environment, should stay same. 
>
> How to achieve that? 
> I know I can create a new django projects and import/copy main app's 
> settings. Is there an other way? 
>
> BR,
> Marcin
> -- 
> 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/0da53e34-428d-4803-ba8f-dddc83c24443%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> -- 
> Jani Tiainen
>
>

-- 
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/457fa003-6515-40d3-a661-a402cf45b5db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Multiple uwsgi apps in one project

2017-05-26 Thread marcin . j . nowak
Hi.

I'd like to serve more uwsgi apps for the same project. 
These apps must have just separate urls and must be served on spearate 
domains. 
I'd like to have separate appservers. 
The rest, i.e. project's environment, should stay same. 

How to achieve that? 
I know I can create a new django projects and import/copy main app's 
settings. Is there an other way? 

BR,
Marcin

-- 
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/0da53e34-428d-4803-ba8f-dddc83c24443%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels - unbalanced load for threaded workers

2017-05-17 Thread Stephen J. Butler
CPython uses a global interpreter lock, which means that only one thread
per process can ever be running Python code. Where threading really helps
is if your python project is mostly I/O bound (waiting on database work,
network connections, etc). If it's CPU bound then you probably won't see
much concurrency with multiple threads.

I'm guessing this is why you're seeing all your work being accounted to a
couple processes. You'd get better concurrency moving to a
multiprocess/fork model.

https://www.ploggingdev.com/2017/01/multiprocessing-and-multithreading-in-python-3/


On Wed, May 17, 2017 at 3:53 AM,  wrote:

> I am trying to deploy Django project with Channels. After some trial and
> error I settled on 4 workers with 16 threads each. However as attached
> screen shows, the processes that are spawned by supervisor have CPU usage
> at ~15% while threads are around ~1-2%. Number of connections at the moment
> is less than 100. I tried load testing this setup, and as more messages are
> coming in the CPU usage is increasing both on processes that were spawned
> by supervisor and threads of these processes - so there is still
> disproportion (~50% and ~10%). Is it normal behavior? Any tips to configure
> it some other way to better balance the load?
>
> --
> 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/b566a9bc-5313-4573-9351-d6dd81915251%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/CAD4ANxXhDp3TfhoWVkhhJFT_%3DZ08bHxeQoBP2S7sSOCGbxhYew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to celery

2017-05-11 Thread marcin . j . nowak
RQ is simple, stable and reliable. Redis is also a persistent storage, but 
you should read about this and use the best solution for your case: 
https://redis.io/topics/persistence   
You may also consider deploying a fault-tolerant Redis cluster (min. 3 
nodes AFAIR)

RQ has different architecture than Celery. It is based on fork(), which is 
just slower. So you should ask yourself how many tasks per sec you need to 
handle. RQ may not be enough for all use cases.
Some things aren't OOTB, like repeating failed tasks (you should handle it 
manually, i.e. by using own worker class), nor  tasks scheduling (you 
should use rq-scheduler). 

RQ uses pickle, but there is a feature request about handling json and 
other serializers - https://github.com/nvie/rq/issues/369 


-- 
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/d2fc1e0f-f147-4ccd-991f-1b12e61c8964%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Angular 2 + Django + Postgresql

2017-05-09 Thread marcin . j . nowak
>From my personal experience:

   - make frontend (angular) almost 100% separate from backend (django)
   - if you want to build truly restful service, avoid DRF (more precisely 
   -- avoid whole "magical" model views, which implements CRUD antipattern)
   - focus on hypermedia (i.e. use Hydra, or start with something custom -- 
   going restful is a process)
   - avoid django forms if possible (use Colander, for example)

 
DRF will give you big community, rich features, more skilled devs and rapid 
developemnt (especially at the initial stage), but later it may introduce 
limitations. 
Just my 5 cents.

Marcin

-- 
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/aeec0b8f-388a-497b-8596-239cfd8d7daf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: field cannot be specified for model form as it is a non-editable field

2017-05-09 Thread marcin . j . nowak
Thank you for all replies.


@James

Your proposal about design change is generally OK, but while doing the 
upgrade I definitely DO NOT want to change the implementation. It is just 
too risky. 


@Tim

Sorry for hostile sounding, but I'm just tired of such drastic changes. For 
a x-years long project it is a quite big issue. 
The most important thing is not to destroy the data and to have a security 
patches applied. The rest should remain untouched. 
The big problem with Django lies somewhere in between - to get recent 
patches you must accept whole set of changes, incl. breaking compat ones. 

I'm considering upgrade just because 1.8 is not supported AND it has some 
serious drawbacks (here -- automatic removal of contenttypes).
Where I am doing one step forward, the upgrade takes me "two" steps back.

I was quite happy when more freedom was left to the developer. It was from 
v0.96 up to v1.4. 
The things started getting "worse" when builtin migrations and system 
checks framework were introduced. 
And the "worse" word is very subjective here.  

Anyway, thank you for a quick response and hint about changing auto_now_add 
to the `default` attr.

Marcin

-- 
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/90a293a8-bcf6-4d51-bd1e-5f87ffa83f95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Angular 2 + Django + Postgresql

2017-05-08 Thread Yeddu J Prasad
Thank you Elorm.

 

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Elorm Koku
Sent: Monday, May 8, 2017 7:56 PM
To: django-users@googlegroups.com
Subject: RE: Angular 2 + Django + Postgresql

 

My best bet: expose django with drf and use angular as a frontend. 

 

On May 8, 2017 1:10 PM, "Matthew Pava"  > wrote:

There is a third-party app for Django and Angular called Djangular:

https://github.com/appliedsec/djangular

 

I have used neither Angular nor Djangular.

 

I do use Windows 10 with PostgreSQL without any problems.  You don’t need to 
create tables in PostgreSQL.  Just run the migrate command.

 

From: django-users@googlegroups.com   
[mailto:django-users@googlegroups.com  ] 
On Behalf Of yeddu.j.pra...@gmail.com  
Sent: Monday, May 8, 2017 12:00 AM
To: Django users
Subject: Angular 2 + Django + Postgresql

 

Dear Experts, 

 

I am planning to build an application using this stack. Any blogs / videos / 
Links that can help me understand how these three connect will be a great help.

 

Specific questions I am trying to answer are.

 

1.  Will I be able to integrate Django with Angular easily. Does this need 
to be done using DRF? Will the angular interpolation cause clashes with Django 
if I use Django interpolation?
2.  Can I drop Angular and develop the same Single Page Application 
capabilities with HTML5+Bootstrap? Need to ensure I have ability to refresh a 
specific blocks / regions / components like you can do in Angular SPA.
3.  I am using Windows 10 and looking for some document to make my Django 
setup work with Postresql
4.  Can I create my tables in Postgresql first, create the models in Django 
and then run migrate so the app is in Sync with the database.

-- 
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/af508944-b3a3-4ee5-9841-ac7b796d7e83%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/e00819c76247431581048e96dffbd420%40ISS1.ISS.LOCAL
 

 .
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/CAG%2BabP_jVuWGxis14FEtCza8mnL5moXTms2xKp%2BwQg26pbqGGA%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/01d2c80e%245204cf70%24f60e6e50%24%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: Angular 2 + Django + Postgresql

2017-05-08 Thread Yeddu J Prasad
Thank you Matthew. I will check this out.

 

The only reason I wanted to create the tables first in PostgreSQL is to ensure 
that I have all the relations right. The schema is quite complex with multiple 
levels of hierarchical relations & constraints. If this is not possible, I will 
go the Django way and use migrate.

 

Thank You.

 

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Matthew Pava
Sent: Monday, May 8, 2017 6:39 PM
To: 'django-users@googlegroups.com' 
Subject: RE: Angular 2 + Django + Postgresql

 

There is a third-party app for Django and Angular called Djangular:

https://github.com/appliedsec/djangular

 

I have used neither Angular nor Djangular.

 

I do use Windows 10 with PostgreSQL without any problems.  You don’t need to 
create tables in PostgreSQL.  Just run the migrate command.

 

From: django-users@googlegroups.com   
[mailto:django-users@googlegroups.com] On Behalf Of yeddu.j.pra...@gmail.com 
 
Sent: Monday, May 8, 2017 12:00 AM
To: Django users
Subject: Angular 2 + Django + Postgresql

 

Dear Experts, 

 

I am planning to build an application using this stack. Any blogs / videos / 
Links that can help me understand how these three connect will be a great help.

 

Specific questions I am trying to answer are.

 

1.  Will I be able to integrate Django with Angular easily. Does this need 
to be done using DRF? Will the angular interpolation cause clashes with Django 
if I use Django interpolation?
2.  Can I drop Angular and develop the same Single Page Application 
capabilities with HTML5+Bootstrap? Need to ensure I have ability to refresh a 
specific blocks / regions / components like you can do in Angular SPA.
3.  I am using Windows 10 and looking for some document to make my Django 
setup work with Postresql
4.  Can I create my tables in Postgresql first, create the models in Django 
and then run migrate so the app is in Sync with the database.

-- 
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/af508944-b3a3-4ee5-9841-ac7b796d7e83%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/e00819c76247431581048e96dffbd420%40ISS1.ISS.LOCAL
 

 .
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/00e101d2c80e%240f0440c0%242d0cc240%24%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Angular 2 + Django + Postgresql

2017-05-08 Thread yeddu . j . prasad
Dear Experts, 

I am planning to build an application using this stack. Any blogs / videos 
/ Links that can help me understand how these three connect will be a great 
help.

Specific questions I am trying to answer are.


   1. Will I be able to integrate Django with Angular easily. Does this 
   need to be done using DRF? Will the angular interpolation cause clashes 
   with Django if I use Django interpolation?
   2. Can I drop Angular and develop the same Single Page Application 
   capabilities with HTML5+Bootstrap? Need to ensure I have ability to refresh 
   a specific blocks / regions / components like you can do in Angular SPA.
   3. I am using Windows 10 and looking for some document to make my Django 
   setup work with Postresql
   4. Can I create my tables in Postgresql first, create the models in 
   Django and then run migrate so the app is in Sync with the database.
   

-- 
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/af508944-b3a3-4ee5-9841-ac7b796d7e83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


field cannot be specified for model form as it is a non-editable field

2017-05-08 Thread marcin . j . nowak
Hi.

After upgrading to 1.11 I'm getting this error:

FieldError: created_at cannot be specified for  model form as it 
is a non-editable field.

First of all, the model contains created_at field declared as 
DateTimeField(auto_now_add=True). Probably that's why it is non-editable. 
But I cannot set editable=True - the change has no effect.
My application allows overriding "created_at" value, because there are more 
than one separate input channels, and I have such cases. Other relies on 
auto_now_add. 

I want to leave auto_now_add=True as is, and have possibility to override 
it. 
How to achieve that? 

PS. Somebody asked me why I'm considering leaving Django, and this is a 
real example of worst changes in Django in last years. Breaking 
compatibility and blocking a dev to do what he want. There is nothing wrong 
with overriding such value.

Marcin

-- 
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/f6f18a98-a197-49a1-8d64-8ec26861c028%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Automatic content types removal

2017-05-05 Thread marcin . j . nowak
Thanks, Tim. I'll take a look at this.  
 

> From the Django 1.11 release notes:
>
>- The prompt for stale content type deletion no longer occurs after 
>running the migrate command. Use the new remove_stale_contenttypes 
>
> 
> command instead.
>
> In older versions of Django, stale content type deletion doesn't happen 
> unless you type "yes" to the prompt that happens after migrate.
>
> On Friday, May 5, 2017 at 8:41:18 AM UTC-4, marcin@gmail.com wrote:
>>
>> Hi.
>>
>> Why Django automatically removes content types? 
>>
>> Due to lack of flexibility in auth system I was forced to create custom 
>> content type for custom perms.
>> Now I've realized that my custom content type is missing.
>> I am not sure, of course, but I think that Django removed my CT silently.
>>
>> I know that clearing content types is OK, maybe required, but it SHOULD 
>> NOT to be run automatically!
>> Deleting the data is a risky operation and should be called on demand.
>>
>> Is possible to disable automatic CT deletion?
>>
>>
>> Marcin
>>
>>

-- 
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/e7128eeb-b798-49ee-a60f-400c046ff249%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django forks / clones / wrappers

2017-05-05 Thread marcin . j . nowak
Hi

Does anyone know a web framework, non full-stack / microframework, but 
partially compatible with Django (in terms of the programming interface)?
Django have too many design flaws for big projects, so I'd like to move 
into something less coupled. Any bridges / wrappers for Flask maybe?

The core is highly based on models/db layer, and data input is based mostly 
on forms and modelforms. Everything else is easy to reimplement, relatively.
Admin, postgis and most of contribs are not necessary.

Thanks,
Marcin

-- 
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/54820317-f542-4026-94b6-12375e2c756d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Automatic content types removal

2017-05-05 Thread marcin . j . nowak
Hi.

Why Django automatically removes content types? 

Due to lack of flexibility in auth system I was forced to create custom 
content type for custom perms.
Now I've realized that my custom content type is missing.
I am not sure, of course, but I think that Django removed my CT silently.

I know that clearing content types is OK, maybe required, but it SHOULD NOT 
to be run automatically!
Deleting the data is a risky operation and should be called on demand.

Is possible to disable automatic CT deletion?


Marcin

-- 
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/e3f62088-3d24-42a3-8d21-e0418cfaafd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I access obj in admin.py

2017-05-03 Thread Stephen J. Butler
You want to override get_inline_instances:
https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_inline_instances

On Wed, May 3, 2017 at 12:33 AM, Mike Dewhirst 
wrote:

> I want to adjust inlines based on a property of the object.
>
> class SubstanceAdmin(admin.ModelAdmin):
>
> class SolidInline(admin.StackedInline):
> pass
> class LiquidInline(admin.StackedInline):
> pass
> class GasInline(admin.StackedInline):
> pass
>
> inlines = get_inlines
>
> def get_inlines(self):
> obj = how_do_I_get_this(?)
> if obj.physical_state = None:
> return ((SolidInline), (LiquidInline), (GasInline))
> elif obj.physical_state = 1:
> return ((SolidInline), )
> elif obj.physical_state = 2:
> return ((LiquidInline), )
> elif obj.physical_state = 3:
> return ((GasInline), )
>
> Many thanks for a miracle :)
>
> Mike
>
> --
> 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/ms
> gid/django-users/a138bd6c-46fb-98c7-ba28-69a5959e5fbc%40dewhirst.com.au.
> 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/CAD4ANxWWNxfDSCGUm8GFR_ijGL2WZAC%2Bwz3NCwpA%3DyHyALfWZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


OneToOne mappings

2017-03-13 Thread marcin . j . nowak
Hi.

The problem is:

A   1:1   B
B.a = OneToOne(A)

and there is a vA - an unmanaged model of A's view


A and B are linked together.
vA view is not linked with B, of course.

When I try to declare OneToOne within vA, Django expects vA.b_id field 
which is missing (that's ok).
When I try to declare sedond OneToOne within B (with db_column set to 
B.a_id and on_delete=DO_NOTHING),  Django complains about 
"models.E007": column name 'a_id that is used by another field.
When I declare second 1:1 and ignore models.E007, I can't save B model 
anymore due to "many assignments to the same column" (these values are same 
and will be always same, but "Django knows better").

So how to map a relation for my view? Is Django really so limited? 

Marcin

-- 
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/aff3aa41-c67c-4ebe-ad61-c83c3018804a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrations

2017-03-13 Thread marcin . j . nowak


On Friday, March 10, 2017 at 9:18:42 PM UTC+1, Matthew Pava wrote:
>
> Does anyone else get a migraine when working migrations?
>

Yes*. Long time ago. Stayed with Liquibase wrapped with Liquimigrate.

Builtin migrations are pretty unrielable, because they're strongly 
dependent on your application's code. 
Create custom field, make migration, remove custom field - kaboom! Or 
something like that.

* - Not always. Builtin migrations are awesome, but for blog-like or 
short-maintainable projects. 
I'm using them for very small projects (blogs, homepages, etc) and they 
work well there.
These projects are rarely changed and I have no headache here. 

So the truth is - it depends. Think about maintaining the project and go 
with Liquibase (or something else) where long-term support is required.

Marcin

-- 
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/d0042e0e-27ee-4012-8f9e-14be43cd91d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: group by 3 fields

2017-03-01 Thread marcin . j . nowak


On Wednesday, March 1, 2017 at 2:09:06 PM UTC+1, larry@gmail.com wrote:
>
>
> I had thought of using a view, but that would have been a lot of 
> overhead on such a large table. I also considered adding a column and 
> running a one time script to update the existing rows, and modifying 
> the script that loads data to populate the new column. But doing an 
> alter on such a large table takes longer then we can afford to have 
> the table locked for. 
>

It depends on your needs, of course. Your solution described earlier is 
widely adopted. 
 

> Also, we don't use django migrations on this project. We have found 
> them very hard to manage in an environment where you have 40 
> deployments, all with different versions of the code and database. 
>

Good decision. There are many other factors like unavailability of 
migrations after application's code changes (due to "freezing" class 
references).

BR,
Marcin

-- 
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/d1bfae54-202c-4c9f-9665-200292396642%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: group by 3 fields

2017-03-01 Thread marcin . j . nowak


>
> As is so often the case, the requirements changed. Now what I had to 
> do, if I was doing it in SQL would have been: 
>
> (CASE 
>  WHEN TRIM(IFNULL(roiname, '')) IN ('', 'None') THEN CONCAT_WS('.', 
> CONVERT(roi_type_id, CHAR), roi_id) 
>  WHEN CONCAT_WS('.', CONVERT(roi_type_id, CHAR), roi_id) = roiname THEN 
> roiname 
>  ELSE CONCAT_WS('.', CONVERT(roi_type_id, CHAR), roi_id, roiname) 
>  END) REGEXP '%s' 
>
> But the table I am selecting from has 600,000 rows or more, and that 
> query would cause a table scan. So I did not add that to the existing 
> query, and instead iterated over the result set in python and did that 
> filtering. 
>

Queries like that aren't "compatible" with Django ;)
You may also consider creating a view and map it to a unmanaged django 
model, but do not forget to add on_delete/on_update=DO_NOTHING for FKs.
But I have no idea what Django migration system do with such mapped view - 
I kicked off builtin migrations completely and I am using Liquibase to 
manage dbs.

Marcin

-- 
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/e784-6a38-4bcc-9341-b2f6a59b97c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Flattening model relationships (in APIs)

2017-02-27 Thread marcin . j . nowak
Wanna read something interesting? Look at 
http://t-code.pl/blog/2016/02/rest-misconceptions-0/
You will realize how many "antipatterns" are propagated in turorials on our 
World Wide Web, and where they're already implemented.
 

On Monday, February 27, 2017 at 2:52:46 PM UTC+1, Ankush Thakur wrote:
>
> Marcin, that's exactly where I'm stuck! I know endpoints should never be 
> 1:1 serialization of models, but I just don't know how to do that. I mean, 
> I've been able to create endpoints like "/customers/1/payments/" where I 
> use model relationships to generate JSON structures where Customer contains 
> a Payments array field. My Address endpoint seems to be an oddity, as API 
> consumers don't expect the city to contain state and the state to contain 
> country as a JSON structure. How can I add these to the top-level Address 
> entity directly while serialization? That's where I have no answers. Would 
> it be possible for you to point me towards some article that does that? 
> Thanks in advance!
>
> Regards,
> Ankush
>
> On Monday, February 27, 2017 at 3:41:49 AM UTC+5:30, marcin@gmail.com 
> wrote:
>>
>>
>>
>> On Tuesday, February 21, 2017 at 8:13:25 PM UTC+1, Ankush Thakur wrote:
>>>
>>> If the relationship chain was even deeper, there would be even more 
>>> nesting, which I feel isn't great for API consumers. What is the best 
>>> practice here to put state and country at the same level as the city? 
>>>
>>
>> Just follow REST design. 
>> Forget django models, think about encapsulation.
>> Think about representation of a resource, not about serializing a 
>> model(s).
>> Make semantic representations, as good as possible.
>>
>> You are not forced to do any nested nasty things. This has nothing to do 
>> with REST api.
>> You may feel that DRF is limiting you. You'll be on a good path, if so. :)
>>
>> Good luck!
>> Marcin
>>
>

-- 
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/1fe8f663-8d38-41af-87e8-8a06bf2301d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Flattening model relationships (in APIs)

2017-02-27 Thread marcin . j . nowak


On Monday, February 27, 2017 at 3:38:34 PM UTC+1, Xavier Ordoquy wrote:
>
>
> The more strict RESTfull way would be to use the several entry points and 
> use hyperlinks on them (though it would add some extra requests).
>
>
This is just about representation. Nobody forces you to do such things. 
You may include more or less data, require linking or not - it does not 
matter. Client should just *know* what to do - read *something* or *follow 
link* to read *something*. 
Everything is about semantic, not about a structure.

The most important is hyperlinking, hypermedia and the state transfer. 

Marcin

>

-- 
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/374d2df8-23b1-4bd8-9a22-9203d007d7b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Flattening model relationships (in APIs)

2017-02-27 Thread marcin . j . nowak


On Monday, February 27, 2017 at 3:30:11 PM UTC+1, Ankush Thakur wrote:
>
> I guess this is the library in question: 
> https://github.com/marcinn/restosaur (took some effort to find it!). 
> Thanks, if I decide to stick with the API-first approach, I'll use it. 
> Either way, I've bookmarked it for future use. :-)
>
>
Yes. I'm not annoucing it, because of entering early beta stage. But on the 
other side I've decided to use it in production starting from early alphas, 
and it just works.
This is a thin glue between web framework and your REST(-ful, -ish, plain 
http, what you want) services, so there is no big issues at all.
Last commits gave me possibility to run api top on a Flask framework, so it 
is fun. 
Still alpha-beta, so I can't give you any guarantee of satisfaction ;)

DRF has mature community, support, etc. Use it if it will work for you. 
Otherwise you're welcome to Restosaur community. 

BR,
Marcin

-- 
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/3d957a6d-da43-4f48-80d6-cd82f22a7817%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Flattening model relationships (in APIs)

2017-02-27 Thread marcin . j . nowak
I was limited by DRF long days ago and I realized that it is not following 
REST architecutre. It does good job in automation in exposing models over 
http, but everything else is way complicated.
But there were no problem mix both tools in one project. DRF was for "80%" 
of work and my lib for the rest. Downsides? Two libs used to get the job 
done.

Maybe try using DRF's @api_view decorator for function views, and return a 
pure and manually "flattened" dict?

M.


On Monday, February 27, 2017 at 3:17:35 PM UTC+1, Ankush Thakur wrote:
>
> Hmmm. That's not an answer I wanted to hear, really, but I like it. I'm 
> myself finding DRF too restrictive once you are past the effort-saving 
> magic. Thank you. I might give it up as it's still early days in the 
> project.
>
>
> Regards,
> Ankush Thakur
>
> On Mon, Feb 27, 2017 at 7:43 PM,  
> wrote:
>
>> I'm not sure you want to read my answer, really...  I've finally stopped 
>> using DRF and wrote own library which is focused on resources, linking and 
>> representations.
>> I think you can do some customization in DRF, probably you ca declare 
>> custom serializer class, but this is a hard way, IMO.
>>
>> I like simple things, so with my lib I can just do something like that:
>>
>> payments = api.resource('/payments/')
>> customer = api.resource('/customers/:pk')
>>
>>
>> @payments.representation
>> def payment_as_json(payment, ctx):
>> return {
>> 'customer_address': payment.customer.address,
>> 'customer_url': ctx.link_to(customer, pk=payment.customer_id), # 
>> link resources
>> 'value': payment.value,  # write here
>> 'and_so_on': True,  # what do you want
>> }
>>
>> Yes, it does not validate automatically and this example is not restful, 
>> but you may follow semantic structures like jsonld without any limitation, 
>> and apply validation in a controller:
>>
>> @payments.post(accept='application/json')
>> def add_payment(ctx):
>> form = PaymentForm(data=ctx.body)
>> form.is_valid() and form.save(0
>> [...]
>>
>> Where PaymentForm may be a typical Django Form or ModelForm, or even a 
>> Colander Schema. 
>> There is more code to write, but implementation is more explitic.
>>
>> PEP20: Explicit is better than implicit. Simple is better than complex. 
>> Flat is better than nested. Readability counts.  And so on...
>>
>> BR,
>> Marcin
>>
>>
>>
>> On Monday, February 27, 2017 at 2:52:46 PM UTC+1, Ankush Thakur wrote:
>>>
>>> Marcin, that's exactly where I'm stuck! I know endpoints should never be 
>>> 1:1 serialization of models, but I just don't know how to do that. I mean, 
>>> I've been able to create endpoints like "/customers/1/payments/" where I 
>>> use model relationships to generate JSON structures where Customer contains 
>>> a Payments array field. My Address endpoint seems to be an oddity, as API 
>>> consumers don't expect the city to contain state and the state to contain 
>>> country as a JSON structure. How can I add these to the top-level Address 
>>> entity directly while serialization? That's where I have no answers. Would 
>>> it be possible for you to point me towards some article that does that? 
>>> Thanks in advance!
>>>
>>> Regards,
>>> Ankush
>>>
>>> On Monday, February 27, 2017 at 3:41:49 AM UTC+5:30, 
>>> marcin@gmail.com wrote:



 On Tuesday, February 21, 2017 at 8:13:25 PM UTC+1, Ankush Thakur wrote:
>
> If the relationship chain was even deeper, there would be even more 
> nesting, which I feel isn't great for API consumers. What is the best 
> practice here to put state and country at the same level as the city? 
>

 Just follow REST design. 
 Forget django models, think about encapsulation.
 Think about representation of a resource, not about serializing a 
 model(s).
 Make semantic representations, as good as possible.

 You are not forced to do any nested nasty things. This has nothing to 
 do with REST api.
 You may feel that DRF is limiting you. You'll be on a good path, if so. 
 :)

 Good luck!
 Marcin

>>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/django-users/ttoJbZJOBnU/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/a0b23023-8a5c-4257-ad6d-d72639f85925%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>

  1   2   3   4   5   6   7   >