Re: send_mail not filling mail.outbox in certain circumstance

2020-07-08 Thread Matthew Pava
Well, I discovered that send_mail fails silently when you tell it not to. 
Apparently, I did not have the to_email and recipient_list populated with 
anything. I wonder if we could change the behavior of send_mail to require 
at least one of those two arguments...

On Wednesday, July 8, 2020 at 9:55:21 AM UTC-5, Matthew Pava wrote:
>
> Good day,
> I'm writing a functional test for checking that an email was sent after a 
> record was revised in my project. I placed a print statement to verify that 
> the send_mail function was called within the view that it is called in, and 
> it prints it out at the appropriate time. However, when I check 
> mail.outbox, the email is not in there--nothing is in there. I am using a 
> class that inherits from StaticLiveServerTestCase, so I thought that should 
> automatically handle changing the email setting appropriately. What am I 
> missing?
>
> I did try something else, though. Within the test function, I performed a 
> dummy send_mail call, and mail.outbox was populated with the dummy message. 
> But it is not populated with the message I want to test against. I 
> appreciate any guidance you can offer in this matter.
>
> Thanks,
> Matthew
>

-- 
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/e215ec31-a218-474a-acf4-42d0d79ddcaeo%40googlegroups.com.


send_mail not filling mail.outbox in certain circumstance

2020-07-08 Thread Matthew Pava
Good day,
I'm writing a functional test for checking that an email was sent after a 
record was revised in my project. I placed a print statement to verify that 
the send_mail function was called within the view that it is called in, and 
it prints it out at the appropriate time. However, when I check 
mail.outbox, the email is not in there--nothing is in there. I am using a 
class that inherits from StaticLiveServerTestCase, so I thought that should 
automatically handle changing the email setting appropriately. What am I 
missing?

I did try something else, though. Within the test function, I performed a 
dummy send_mail call, and mail.outbox was populated with the dummy message. 
But it is not populated with the message I want to test against. I 
appreciate any guidance you can offer in this matter.

Thanks,
Matthew

-- 
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/582038f8-58b0-48b5-9bbd-f8e08eff40dfo%40googlegroups.com.


Exception During Testing on Windows, Python 3.8

2020-06-11 Thread Matthew Pava
I continue to receive the following exception error at every single one of 
my tests. I'm running Python 3.8.2 on Windows 10.


Exception happened during processing of request from ('127.0.0.1', 54962)
Traceback (most recent call last):
  File "c:\program files\python38\lib\socketserver.py", line 650, in 
process_request_thread
self.finish_request(request, client_address)
  File "c:\program files\python38\lib\socketserver.py", line 360, in 
finish_request
self.RequestHandlerClass(request, client_address, self)
  File "c:\program files\python38\lib\socketserver.py", line 720, in 
__init__
self.handle()
  File 
"C:\...\.virtualenvs\HWohXs6h\lib\site-packages\django\core\servers\basehttp.py"
, line 174, in handle
self.handle_one_request()
  File 
"C:\...\.virtualenvs\HWohXs6h\lib\site-packages\django\core\servers\basehttp.py"
, line 182, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
  File "c:\program files\python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionAbortedError: [WinError 10053] An established connection was 
aborted by the software in your host machine



I've reviewed a few possible solutions found on the web, but they don't 
seem to help. Besides these exceptions, the tests actually do pass.
Thank you so much!

-- 
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/f4613b3e-2f69-4d07-acc5-85c6ae2128ado%40googlegroups.com.


Changing name of file in FileField field

2020-06-09 Thread Matthew Pava
Good day,
I have been struggling with this issue for weeks, and I can't figure out 
what I'm doing wrong.
I have a model with a FileField with a custom upload_to function. It seems 
to work fine when I'm doing runserver.
Problems arise during my tests.

My assertion error fails:

AssertionError: 'Rev0_2020-06-09_L123_My_Document_63ExUTF.docx' != 
'Rev0_2020-06-09_L123_My_Document.docx'
- Rev0_2020-06-09_L123_My_Document_63ExUTF.docx
? 
+ Rev0_2020-06-09_L123_My_Document.docx


You see, it keeps adding these extra random characters to the filename, 
which is not at all in my upload_to function.

class DocumentTestCase(TestCase):
def create_document(self, **kwargs):
if 'file' not in kwargs:
kwargs['file'] = self.get_test_file()
return Document.objects.create(**kwargs)

 def _create_file(self):
f = tempfile.NamedTemporaryFile(suffix=self.TEST_FILE_EXTENSION, 
delete=False)
with open(f.name, mode='wb'):

f.write(b"NA")

return open(f.name, mode='rb')


TEST_FILE_EXTENSION = ".docx"

def setUp(self):
super().setUp()

settings.MEDIA_ROOT = MEDIA_ROOT

def get_test_file(self):
file = self._create_file()

return File(file, name=file.name)

def test_rename_file_after_upload(self):
d1 = self.create_document(title="My Document", number="L123")

title = d1.title.replace(" ", "_")
extension = Path(d1.file.path).suffix

new_name = 
f"Rev{d1.revision}_{d1.revision_date}_{d1.number}_{title}{extension}"
self.assertEqual(Path(d1.file.name).name, new_name)



-- 
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/cbc812fc-6d5e-4afb-ab64-6bc0fad303a3o%40googlegroups.com.


RE: Legacy DB: ID is null when .save or .create

2019-05-17 Thread Matthew Pava
You may need to reset your auto increment counter in PostgreSQL. I remember 
having this problem once.
https://stackoverflow.com/questions/5342440/reset-auto-increment-counter-in-postgres


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mei B
Sent: Friday, May 17, 2019 2:56 PM
To: Django users
Subject: Legacy DB: ID is null when .save or .create

I'm using a legacy DB with postgres. In one of my models:

class case(models.Model):
 id = models.AutoField(primary_key=True)
 case_id = models.ForeignKey(.)
 user_id = models.ForeignKey(...)

When I'm saving or creating a new case object, I always get "null value in 
column 'id' violates not-null"

How do I get this to auto-increment?
--
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/5d621db9-39e8-44c8-92e2-80fdabc760af%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/c0d915c7229a4bcfb6df1b0a99c3b99a%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Matthew Pava
Well, I had always assumed that they do need to be integers, but it looks like 
this has been discussed at length.
https://groups.google.com/forum/#!topic/django-users/0utRzn98Wxo

It does seem clear, though, that the superior database design uses integers for 
ForeignKeys.
And I didn’t find a way to make it clear to Django not to use an Integer 
ForeignKey.  Maybe something to do with the primary_key attribute on a 
CharField?

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of b...@tanners.org
Sent: Monday, May 6, 2019 12:44 PM
To: Django users
Subject: Re: ORM help with INNER JOIN and GROUP BY

Just want to make sure I understand. ForeighKeys need to be integers?

Only integers?


You need a ForeignKey relationship between the two models, which is an integer 
value, not a char. You’d have to do migrations to get this adjusted properly.
--
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/9697de34-3d20-4023-81a7-8ea9f257f7f1%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/27eee43ff8024c98bcf9a5e9cd4bfd89%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: ORM help with INNER JOIN and GROUP BY

2019-05-06 Thread Matthew Pava
That design could definitely be improved, and it will have to be in order to 
use the ORM effectively. Then you’d have to change every reference to the 
fields in all the raw querysets in the app.

You need a ForeignKey relationship between the two models, which is an integer 
value, not a char. You’d have to do migrations to get this adjusted properly.

Add a facepng_id Integer Field to Monolith. Run makemigrations. Add a RunSQL 
command to the new migrations file 
(https://docs.djangoproject.com/en/2.2/ref/migration-operations/#runsql).  
Something like this:
Update items_monolith SET facepng_id=items_monolith.id FROM items_monolith 
INNER JOIN items_facepng ON items_monolith.object=items_facepng.obj

Then delete the object and obj fields from the models. Run makemigrations 
again. Verify that your app doesn’t reference those fields anywhere else.

Then you could access facepng like so:
monolithic.facepng_set

Of course, this is just a very rough idea of what to do, and I’m not sure what 
the whole structure of your tables is.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of b...@tanners.org
Sent: Monday, May 6, 2019 11:28 AM
To: Django users
Subject: ORM help with INNER JOIN and GROUP BY

I've inherited an application written django 1.11. The old application uses 
raw() with INNER JOIN and GROUP BY.
 I cannot seem to figure out how to do inner join and group by properly the ORM 
way.

The raw() query is below.

SELECT  * FROM items_monolithic
INNER JOIN items_facepng
ON items_monolithic.object == items_facepng.obj
GROUP BY items_monolithic.object
ORDER BY object ASC


Things kind of work with raw() but that doesn't feel right. And I get nasty 
warnings about RawQuerySet not supporting certain things when I try to use the 
query set that is returned.

>From what I understand every monolithic object has 1 or more faces 
>(graphic/picture).

I would call the monolithic a one-to-many relationship with facepng but I see 
django calls this a ForeignKey.

I'm working with these models (yes, a field named object is "bad", it's what I 
was given)


class Monolithic(models.Model):
   object = models.CharField(max_length=128, blank=False, null=False, 
unique=True)

class FacePng(models.Model):
obj = models.CharField(max_length=128, blank=True, null=True)


I do not see the ForeignKey relationship between Monolithic and FacePng.

Changing Monolithic class to models.ForeignKey() breaks lots of things.

So I'd prefer to figure out how to do the inner join and group by query but if 
that's not the django way and I need to change Monolithic.objects to a 
ForeignKey() and fix all the stuff that is broken I can do that that too.

Just need some guidance on how to proceed.



--
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/ab7ecf5b-9ae8-4428-9502-6b7d5dec03b5%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/573f67effc814147bb18f8e4327d2c23%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Simplifying code with multiple loops and logic, into queryset aggregates

2019-04-30 Thread Matthew Pava
It was a little difficult to follow your message because the formatting is 
non-standard, but I think this might be what you’re looking for.
Also, you should try to follow more Python coding conventions: models start 
with an upper case letter. Variables start with a lower case letter.

And you probably want to use a QuerySet Manager on Customer. Maybe a query like 
this:
Customer.objects.annotate(is_admitted=Case(When(admission_set__discharged=False,
 then=True), default=False).distinct()


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel Mathew
Sent: Tuesday, April 30, 2019 9:22 AM
To: django-users@googlegroups.com
Subject: Simplifying code with multiple loops and logic, into queryset 
aggregates

My models:

class customer(models.Model):
cstid = models.AutoField(primary_key=True, unique=True)
insurance_number = models.CharField(max_length=100, blank=True, 
null=True)
name = models.CharField(max_length=35)
ageyrs = models.IntegerField(blank=True)

class Admission(models.Model):
id = models.AutoField(primary_key=True, unique=True)
clinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)
customer = models.ForeignKey(customer, on_delete=models.CASCADE)
diagnosis = models.CharField(max_length=2000, default='', blank=True)
date_admission = models.DateTimeField(default=timezone.now)
ward = models.ForeignKey(Ward, on_delete=models.CASCADE)
bed = models.ForeignKey(Bed, on_delete=models.CASCADE)
discharged = models.BooleanField(default=False)
ip_number = models.IntegerField(blank=True)
ip_prefix = models.CharField(max_length=20, default='', blank=True)

My objective: Set a variable to a query filter, adding a property, 
'is_admitted' to the queryset, so that I can pass this query set to the 
template and use the property while displaying data.

Code:

def is_admitted(cust):
admission = Admission.objects.filter(customer=cust, discharged=False)
admission_results = len(admission)
if admission_results > 0:
return True
return False

my_q = or_q_if_truthfull(
cstid=HospitalID,
name__lower__contains=name.lower() if name else None,
ageyrs=ageyrs if ageyrs.isdigit() else None,
agemnths=agemnths if agemnths.isdigit() else None,
mobile__contains=mobile if mobile else None,
alternate__contains=alternate if alternate else None,
email__lower__contains=email.lower() if email else None,
address__lower__contains=address.lower() if address else None,
city__lower__contains=city.lower() if city else None
)
ORSearchResult = customer.objects.filter(my_q, linkedclinic=clinicobj)
cust_set = []
cust_admission_status = []
for cust in ORSearchResult:
cust_set.append(cust)
cust_admission_status.append(is_admitted(cust))
print(f"Customer name: {cust.name} Admission status: 
{is_admitted(cust)}")
cust_templ_set = zip(cust_set, cust_admission_status)

And in template, I will do:

{% for cust, status in cust_templ_set %}
{{ cust.name }} {{ status }}
{% endfor %}

I want to understand how I can convert my above code by generating an aggregate 
over the queryset, so that I can use a property of the query, and change the 
template code to the following, and avoid the loop in the view, and the zip. So 
that the template code becomes:

{% for cust in customers %}
{{ cust.name }} {{ cust.status }}
{% endfor %}

I am not sure whether I am making complete sense, and can explain further.
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_-8OUE5cd%3DZBahkLMTSTD%3DOXJbYenHjiB3ORGfkY9mSrQ%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 

RE: left join without where condition

2019-04-26 Thread Matthew Pava
Then use the reverse accessor:
https://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward
Product.objects.select_related(‘photo_set’)
{% for photo in product.photo_set.all %}
{{ photo }}
{% empty %}
This product has no photos.
{% endfor %}



From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of chirag soni
Sent: Friday, April 26, 2019 10:58 AM
To: django-users@googlegroups.com
Subject: Re: left join without where condition

You are telling something which I know already. Please observe my question 
keenly I need reverse of what you told. I. e.
Photo modal has Product as ForeignKey
class Photo:
   file=models.FileField()
   product=models.ForeignKey()


On 26 Apr 2019 19:16, "Matthew Pava" 
mailto:matthew.p...@iss.com>> wrote:
Use select_related or just reference it in the template as an attribute.
https://docs.djangoproject.com/en/2.1/ref/models/querysets/#select-related

Product.objects.select_related(‘photo’)

{% if product.photo %}
…
{% endif %}

From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
[mailto:django-users@googlegroups.com<mailto:django-users@googlegroups.com>] On 
Behalf Of pythonwebdja...@gmail.com<mailto:pythonwebdja...@gmail.com>
Sent: Friday, April 26, 2019 8:03 AM
To: Django users
Subject: left join without where condition

What exactly I need?
  I have 2 models Product and Photo(having ForeignKey relationship with 
Product). Now suppose I inserted 3 products in Product table. For the 3rd 
product I not inserted any photo in Photo table. I want to fetch all the 
Products along with Photos but for the 3rd product photo should come as null(or 
None) because I not inserted. why I am doing like this because for the product 
for which no photos are uploaded I can check in the template that if null or 
None is coming as a photo then show a default image referring it from the 
static folder. I know we can achieve it using left join but how to achieve it 
in Django style?

What I have tried?
q=Product.objects.all().filter(photo__isnull=True)
print(q.query)
SELECT "app_product"."id", "app_product"."name"  FROM "app_product" LEFT OUTER 
JOIN "app_photo" ON
("app_product"."id" = "app_photo"."product_id") WHERE "app_photo"."id" IS NOT 
NULL

If in the above query I remove the where clause my problem will be resolved?
So how to do that in a django way?


--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/c8c00d69-f136-4c65-a87b-8466bcb2d866%40googlegroups.com<https://groups.google.com/d/msgid/django-users/c8c00d69-f136-4c65-a87b-8466bcb2d866%40googlegroups.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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/ecf48599ce9d44629e2d0bd68dfbfa34%40iss2.ISS.LOCAL<https://groups.google.com/d/msgid/django-users/ecf48599ce9d44629e2d0bd68dfbfa34%40iss2.ISS.LOCAL?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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/CABCRpYOKy7ZaC0xh%3D8m6AtoeLx0fCvo3irPhPh8SK7YZJ5YC6Q%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CABCRpYOKy7ZaC0xh%3D8m6AtoeLx0fCvo3irPhPh8SK7YZJ5YC6Q%40mail.gmail.com?utm_mediu

RE: How to Update Database

2019-04-26 Thread Matthew Pava
You would use the data from request.POST or request.GET.
Here’s everything you need to know about views:
https://docs.djangoproject.com/en/2.2/topics/http/views/

Here’s an example:

def my_view(request):
   if request.POST:
  field1 = request.POST.get(‘field1’)
  field2 = request.POST.get(‘field2’)
  model = MyModel.objects.create(field1=field1, 
field2=field2)
  return redirect(model.get_absolute_url())
   return whatever

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Aayush Bhattarai
Sent: Friday, April 26, 2019 8:53 AM
To: Django users
Subject: How to Update Database

How can I update database. I am not using forms.py and I am using function 
based view. Can you how example and link for docs. Thanks for 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/41384b09-ed76-4485-9518-8dc10e26f2fa%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/4f036748087c41598da4b7180f3aa231%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: left join without where condition

2019-04-26 Thread Matthew Pava
Use select_related or just reference it in the template as an attribute.
https://docs.djangoproject.com/en/2.1/ref/models/querysets/#select-related

Product.objects.select_related(‘photo’)

{% if product.photo %}
…
{% endif %}

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of pythonwebdja...@gmail.com
Sent: Friday, April 26, 2019 8:03 AM
To: Django users
Subject: left join without where condition

What exactly I need?
  I have 2 models Product and Photo(having ForeignKey relationship with 
Product). Now suppose I inserted 3 products in Product table. For the 3rd 
product I not inserted any photo in Photo table. I want to fetch all the 
Products along with Photos but for the 3rd product photo should come as null(or 
None) because I not inserted. why I am doing like this because for the product 
for which no photos are uploaded I can check in the template that if null or 
None is coming as a photo then show a default image referring it from the 
static folder. I know we can achieve it using left join but how to achieve it 
in Django style?

What I have tried?
q=Product.objects.all().filter(photo__isnull=True)
print(q.query)
SELECT "app_product"."id", "app_product"."name"  FROM "app_product" LEFT OUTER 
JOIN "app_photo" ON
("app_product"."id" = "app_photo"."product_id") WHERE "app_photo"."id" IS NOT 
NULL

If in the above query I remove the where clause my problem will be resolved?
So how to do that in a django way?


--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c8c00d69-f136-4c65-a87b-8466bcb2d866%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/ecf48599ce9d44629e2d0bd68dfbfa34%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Integrating Google calendar API in TODO list

2019-04-24 Thread Matthew Pava
Dr. Joel, I think Sipum doesn’t even know how to begin.
So Sipum, take a look at this document:
https://developers.google.com/calendar/quickstart/python


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel Mathew
Sent: Wednesday, April 24, 2019 2:07 PM
To: django-users@googlegroups.com
Subject: Re: Integrating Google calendar API in TODO list

I fail to see what's your difficulty in integrating this. You just insert the 
code in your views, and display your processed result in your template. Try 
writing code and post your error. There's no specific code needed just for 
django.

If it failed, post your code with the error stream.
On Wed, 24 Apr, 2019, 10:59 PM Sipum Mishra, 
mailto:sipu...@gmail.com>> wrote:
Joel, i know there is python code for yhat API but how to integrate it.. I want 
to know that.. I tried to do but failed.

On Wed, 24 Apr, 2019, 6:55 PM Joel Mathew, mailto:j...@joel.su>> 
wrote:
Just do it. The API has python sample code.
Sincerely yours,
 Joel G Mathew



On Tue, 23 Apr 2019 at 09:58, Sipum 
mailto:sipu...@gmail.com>> wrote:
Hello friends.

I am going to integrate google calendar API in to my TODO List.
can anyone suggest how to integrate so that when I will add any event in my 
TODO List app it will directly show in my google calendar.

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/ebbfbf68-4445-4146-9e49-c18041796343%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA%3Diw_9UTM0izFDbwcGMDxGPZaUHSy9r9L90cEkYA0Vc0JDAmQ%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/CAGHZBzxv28c%3Db8MQEnXiGVY9pM6rj-u%3DwEr1VOVYMNYcZSbCVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA%3Diw_8adPwu6_OoeCieERW9eNzcvzbP6D_2B7ntvghE7TxQLA%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 

RE: Is it possible to value based on another aggregation?

2019-04-23 Thread Matthew Pava
Use annotate.
https://docs.djangoproject.com/en/2.2/topics/db/aggregation/#generating-aggregates-for-each-item-in-a-queryset




From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Kenny Loveall
Sent: Tuesday, April 23, 2019 12:58 PM
To: django-users@googlegroups.com
Subject: Is it possible to value based on another aggregation?

Hi everyone,

I'm trying to figure out if it's possible to get a value for one field based on 
the aggregation of another? Specifically, I've got a model with a created_at 
timestamp, a foreign key, and a created_by user foreign key. I want to group 
the objects based on the foreign key and get the time and user of the most 
recently created object.

I know how to do this with a subquery and how to get the most recently created 
timestamp for each group of objects without a subquery, but I'm not sure how to 
get the user without using a subquery. Is this possible?

Thanks,
Kenny
--
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/CAGABHYC3S-9o_ay1%2BPiANm6vv5py7tFBKyuUCzT1%2Bz49Z%2BpAnA%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/f1b62c769d1248a283e4bae3c904a5db%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Convertingg rendered Model Data in HTML to PDF USING XHTML2PDF

2019-04-18 Thread Matthew Pava
We use Google’s Puppeteer in Node.js.
I use the URL of the HTML page to convert as a GET parameter to the PDF 
generator view.
The PDF generator view then uses subprocess.Popen to run the Node.js script 
that prints that HTML as a PDF page.
As icing on the cake, the user can also automatically print the PDF to a 
printer close by to them on the network.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Irfan Khan
Sent: Thursday, April 18, 2019 9:49 AM
To: Django users
Subject: Convertingg rendered Model Data in HTML to PDF USING XHTML2PDF

hi, all
can any one please guide me how to covert the rendered data from models in html 
to pdf

for example i have developed application and in that implemented search field 
to get the data from the database,till now it now fine but i have used 
xhtml2pdf library to convert
i can see there only some of context passed in views only converting.
please guide me how to implement.

--
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/03530d36-a49f-40ec-b623-dee9138387e7%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/d06d0060aabb4bbaacbd8869032285ee%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Unhashable TypeError when deleted from model, Django 2.2

2019-04-17 Thread Matthew Pava
Okay, the model I’m using specifies an __eq__ function without a corresponding 
__hash__ function. I’ve opened a pull request with the owner of that project.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Matthew Pava
Sent: Wednesday, April 17, 2019 11:18 AM
To: django-users@googlegroups.com
Subject: RE: Unhashable TypeError when deleted from model, Django 2.2

Hi Sithu,
I would still need to a way determine when a record expires. A Boolean wouldn’t 
help in that regard.
But I think this error has something to do with Django’s delete method. The 
filtering aspect works just fine.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Sithembewena L. Dube
Sent: Tuesday, April 16, 2019 2:49 PM
To: django-users@googlegroups.com
Subject: Re: Unhashable TypeError when deleted from model, Django 2.2

Why not use a boolean field on the model to denote expires? Then if that field 
is True, delete the object? I think that would be cheaper and cleaner, 
especially with lookups.

Kind regards,
Sithu


Sent with 
Shift<https://tryshift.com/?utm_source=SentWithShift_campaign=Sent%20with%20Shift%20Signature_medium=Email%20Signature_content=General%20Email%20Group>

On Tue, Apr 16, 2019 at 9:29 PM Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:
I have a model that has a nullable field called expires. If expires is null, 
then the record never expires.
I’m performing a delete on the model for any record that has an expires date 
that has passed, and I keep getting a TypeError that Model is unhashable. Am I 
doing something wrong?

Model.objects.filter(expires__lt=timezone.now()).delete()

Here’s the traceback:

Traceback (most recent call last):
  File "\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
  File "\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
  File "\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
  File "\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
  File "\rest_framework\views.py", line 495, in dispatch
response = self.handle_exception(exc)
  File "\rest_framework\views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
  File "\rest_framework\views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
  File "\rest_framework\decorators.py", line 55, in handler
return func(*args, **kwargs)
  File "C:\project\general\views.py", line 88, in all_messages_for_user
Model.objects.filter(expires__lt=timezone.now()).delete()
  File "\django\db\models\query.py", line 710, in delete
collector.collect(del_query)
  File "\django\db\models\deletion.py", line 192, in collect
reverse_dependency=reverse_dependency)
  File "\django\db\models\deletion.py", line 94, in add
if obj not in instances:
TypeError: unhashable type: 'Model'
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL<https://groups.google.com/d/msgid/django-users/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL?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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%40mail.gmail.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You r

RE: Unhashable TypeError when deleted from model, Django 2.2

2019-04-17 Thread Matthew Pava
Hi Sithu,
I would still need to a way determine when a record expires. A Boolean wouldn’t 
help in that regard.
But I think this error has something to do with Django’s delete method. The 
filtering aspect works just fine.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Sithembewena L. Dube
Sent: Tuesday, April 16, 2019 2:49 PM
To: django-users@googlegroups.com
Subject: Re: Unhashable TypeError when deleted from model, Django 2.2

Why not use a boolean field on the model to denote expires? Then if that field 
is True, delete the object? I think that would be cheaper and cleaner, 
especially with lookups.

Kind regards,
Sithu


Sent with 
Shift<https://tryshift.com/?utm_source=SentWithShift_campaign=Sent%20with%20Shift%20Signature_medium=Email%20Signature_content=General%20Email%20Group>

On Tue, Apr 16, 2019 at 9:29 PM Matthew Pava 
mailto:matthew.p...@iss.com>> wrote:
I have a model that has a nullable field called expires. If expires is null, 
then the record never expires.
I’m performing a delete on the model for any record that has an expires date 
that has passed, and I keep getting a TypeError that Model is unhashable. Am I 
doing something wrong?

Model.objects.filter(expires__lt=timezone.now()).delete()

Here’s the traceback:

Traceback (most recent call last):
  File "\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
  File "\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
  File "\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
  File "\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
  File "\rest_framework\views.py", line 495, in dispatch
response = self.handle_exception(exc)
  File "\rest_framework\views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
  File "\rest_framework\views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
  File "\rest_framework\decorators.py", line 55, in handler
return func(*args, **kwargs)
  File "C:\project\general\views.py", line 88, in all_messages_for_user
Model.objects.filter(expires__lt=timezone.now()).delete()
  File "\django\db\models\query.py", line 710, in delete
collector.collect(del_query)
  File "\django\db\models\deletion.py", line 192, in collect
reverse_dependency=reverse_dependency)
  File "\django\db\models\deletion.py", line 94, in add
if obj not in instances:
TypeError: unhashable type: 'Model'
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL<https://groups.google.com/d/msgid/django-users/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL?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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAH-SnCALGpZGrjVfvkN%2Bt-6Dg6tkX7yW-DhQxyMueTw9rHtqpg%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 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/cbdab94a9c2b481bbddb1b242009de80%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Unhashable TypeError when deleted from model, Django 2.2

2019-04-16 Thread Matthew Pava
I have a model that has a nullable field called expires. If expires is null, 
then the record never expires.
I'm performing a delete on the model for any record that has an expires date 
that has passed, and I keep getting a TypeError that Model is unhashable. Am I 
doing something wrong?

Model.objects.filter(expires__lt=timezone.now()).delete()

Here's the traceback:

Traceback (most recent call last):
  File "\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
  File "\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
  File "\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
  File "\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
  File "\rest_framework\views.py", line 495, in dispatch
response = self.handle_exception(exc)
  File "\rest_framework\views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
  File "\rest_framework\views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
  File "\rest_framework\decorators.py", line 55, in handler
return func(*args, **kwargs)
  File "C:\project\general\views.py", line 88, in all_messages_for_user
Model.objects.filter(expires__lt=timezone.now()).delete()
  File "\django\db\models\query.py", line 710, in delete
collector.collect(del_query)
  File "\django\db\models\deletion.py", line 192, in collect
reverse_dependency=reverse_dependency)
  File "\django\db\models\deletion.py", line 94, in add
if obj not in instances:
TypeError: unhashable type: 'Model'

-- 
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/f2d2e610ffe04dff85edf80be0c7ad2d%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: How to properly use MySQL Generated Fields in Django

2019-04-15 Thread Matthew Pava
I wouldn’t save alpha in the database. I would use a property on the model or 
annotate the field to the object manager.

Property:
class Guest(models.Model):
   @property
   def alpha(self):
  return self.lname[0] if self.lname else ''

Or on the object manager:
class GuestManager(models.Manager):
   def get_queryset(self):
  return 
super().get_queryset().annotate(alpha=Left('lname', 1))

class Guest(models.Model):
   objects = GuestManager()

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of rmschne
Sent: Monday, April 15, 2019 10:57 AM
To: Django users
Subject: How to properly use MySQL Generated Fields in Django

I have a generated field in a MySQL table "alpha = upper(substr(`lname`,1,1))" 
where the field lname is a last name of a person. Idea is that I get a field of 
the first letter of the last name.

In Django, I have in the table 'attendees' a field alpha = 
models.CharField("alpha", max_length=1, db_column='alpha', help_text='leading 
alphabetic letter of lastname.')

This works ok when I a new record into the database and the field "alpha" is 
computed correctly.  It works where I can query out the data using Django.

Now I have discovered that if in Django I adjust one of the the other fields 
(not lname), when I do a "save() on the record", Django throws an error:
"The value specified for generated column 'alpha' in table 'attendees' is not 
allowed.")

The one field i am changing in the "attendee" table is a foreign key field; and 
I'm giving Django the foreign key object.  So I think I'm doing that correctly; 
but the new attendee object is not being saved.

I've searched Google for "Django Mysql generated field" and come up with 
nothing relevant on anything special needed; but I suspect I'm missing 
something hence this query. Looking for something special about generated 
fields in MySQL and Django, if anything special?

Some code extracts:

class Guest(models.Model):
lname = models.CharField(max_length=150, db_column='Lname', 
blank=True,help_text="Last name")
alpha = models.CharField("alpha", max_length=1, db_column='alpha', 
help_text='leading alphabetic letter of lastname.')
contact = models.ForeignKey(Contact, related_name='adcontact', 
db_column='ContactID',blank=True, null=True, help_text="Name of linked contact 
for this guest")
timestamp = 
models.DateTimeField(db_column='timestamp',auto_now=True,blank=False)

cad=Guest.objects.filter(contact__id=idfrom)
print "Guest: ",len(cad)
if cad:
for i in cad:
print "i.contact:",i.id,i.contact
print "contactto:",contactto.id,contactto
i.contact=contactto
try:
i.save(["contact"])
except Exception as e:
print "Exception. cad contact save failed.",e

--
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/45a3e32d-29d7-4129-896b-01698beec3e1%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/60424224db584de3bbed62354230a2f8%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Using forms to handle request.GET data?

2019-04-04 Thread Matthew Pava
You could try something like this:
data = request.GET.copy()
data.setdefault('year', 2019)  # fill 'year' in data if it's not already set; 
returns 2019
year_form = JahrAuswahl(data)


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Carsten Fuchs
Sent: Thursday, April 4, 2019 9:51 AM
To: django-users@googlegroups.com
Subject: Re: Using forms to handle request.GET data?

Am 04.04.19 um 16:23 schrieb Matthew Pava:
> If you need a default year in your template context, put it there.
> 
> def get_context_data(self, request, *args, **kwargs):
> context = super().get_context_data(request, *args, **kwargs)
> context['default_year'] = 2019
> return context
> 
> In your template, you could use this type of construct:
> {{ year or default_year }}
> 

No, the goal is to have a HTTP GET based form that the user can use to 
customize the view, and I'm looking for an elegant way to handle this with 
Django forms.

The key problem is that default values for form fields are not relevant when 
working with POST requests (where `initial` values are used in GET requests or 
request.POST data in POST request), but *are* relevant for HTTP GET 
(request.GET) based forms. As Django forms are tailored to work with `initial` 
and POST data, I've not yet found a really Django-elegant way to deal with this 
problem.

Best regards,
Carsten

-- 
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/fe1a5f18-7319-7358-00b4-2670e8111b08%40cafu.de.
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/d181d870d6a345fd8cf9b96a5fea607e%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Using forms to handle request.GET data?

2019-04-04 Thread Matthew Pava
And, since you really don't want constants littering your code, you probably 
want something like this:
context['default_year'] = timezone.now().year

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Carsten Fuchs
Sent: Thursday, April 4, 2019 9:12 AM
To: django-users@googlegroups.com
Subject: Re: Using forms to handle request.GET data?

To elaborate on this further:

Searching the web for this yields numerous hits, e.g. 
https://stackoverflow.com/questions/16026479/django-forms-default-values-for-bound-forms
 mentions some ways to address this, but I've not come across a fully 
satisfactory solution.

Another approach might be this:


params = {'year': '2019'} # default values
params.update(request.GET)
year_form = JahrAuswahl(params)

# Can now use year_form normally, as intended:

if not year_form.is_valid():
# Pass year_form to the view to re-render the form with errors.
return render(..., {'year_form': year_form})

# year_form is valid, now use the year_form.cleaned_data values.
# If (unrelated) request.POST data turns out to be invalid,
# we may re-render year_form in this code path as well.
# ...


Thoughts?

Best regards,
Carsten

-- 
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/7cce7f43-e5e1-995a-a201-92905ba8f2bc%40cafu.de.
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/0bdfd5f6826342a4ae929ea3a73fbd77%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Using forms to handle request.GET data?

2019-04-04 Thread Matthew Pava
If you need a default year in your template context, put it there.

def get_context_data(self, request, *args, **kwargs):
context = super().get_context_data(request, *args, **kwargs)
context['default_year'] = 2019
return context

In your template, you could use this type of construct:
{{ year or default_year }}

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Carsten Fuchs
Sent: Thursday, April 4, 2019 9:12 AM
To: django-users@googlegroups.com
Subject: Re: Using forms to handle request.GET data?

To elaborate on this further:

Searching the web for this yields numerous hits, e.g. 
https://stackoverflow.com/questions/16026479/django-forms-default-values-for-bound-forms
 mentions some ways to address this, but I've not come across a fully 
satisfactory solution.

Another approach might be this:


params = {'year': '2019'} # default values
params.update(request.GET)
year_form = JahrAuswahl(params)

# Can now use year_form normally, as intended:

if not year_form.is_valid():
# Pass year_form to the view to re-render the form with errors.
return render(..., {'year_form': year_form})

# year_form is valid, now use the year_form.cleaned_data values.
# If (unrelated) request.POST data turns out to be invalid,
# we may re-render year_form in this code path as well.
# ...


Thoughts?

Best regards,
Carsten

-- 
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/7cce7f43-e5e1-995a-a201-92905ba8f2bc%40cafu.de.
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/15ab780e0c214868bde744af7b93452f%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Login by phone number best practice

2019-04-03 Thread Matthew Pava
Check out these:
https://djangopackages.org/grids/g/authentication/

A package for phone number authentication:
https://github.com/wejhink/django-phone-login


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mohammad Etemaddar
Sent: Wednesday, April 3, 2019 1:59 PM
To: Django users
Subject: Login by phone number best practice

I want users to login by phone number (without registration).
But we need username field for authentication.
This is just for make easy for users that don't know about using email. And 
also make it easier to login for them.
But I need also username and email for other users for future.
I need you opinion on how to implement it.
Set username field to phone_number / create random username for users that need 
to login by phone

I also need best practices and documentations if is available for login and 
registration in this situation.

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/56016d6f-d6c6-4368-a7c0-74037d7b3fdb%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/ee56e0fc973b484589814746d8200693%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: BaseModelFormSet > _construct_form

2019-04-03 Thread Matthew Pava
You may want to consider using the django-angular 
(https://github.com/jrief/django-angular) package and reading this question:
https://stackoverflow.com/questions/32978137/using-formsets-in-django-angular

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Nikolay Smirnov
Sent: Wednesday, April 3, 2019 1:53 AM
To: Django users
Subject: Re: BaseModelFormSet > _construct_form

I override add_prefix because on client side I use angularjs. In some cases it 
is impossible or not easy to use hyphens in the names.

I do not overwrite _construct_form! That was just a possibility to solve that. 
But at the moment, I see no other options for solving that.

I find it personally that generating variable pk_key within the _construct_form 
is a bad practice. And becomes not compatible with generating form field ID's 
and -field names.

On Tuesday, 2 April 2019 23:15:15 UTC+2, Matthew Pava wrote:
Why are overwriting add_prefix? Why are you overwriting _construct_form?

From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of nikolaysm
Sent: Tuesday, April 2, 2019 9:37 AM
To: Django users
Subject: BaseModelFormSet > _construct_form

Hello,

In function _construct_form variable "pk_key" is generated as:
 pk_key = "%s-%s" % (self.add_prefix (i), self.model._meta.pk.name) "

So pk_key is not flexible. Because if I overwrite function "add_prefix" from 
class "forms.ModelForm", I get error "MultiValueDictKeyError".

My add_prefix function:
def add_prefix(self, field_name):
  return '%s_%s' % (self.prefix, field_name) if self.prefix else field_name

I see a possibility to solve that for now. Overwrite function _construct_form.

Other options?
--
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 post to this group, send email to djang...@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/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%40googlegroups.com<https://groups.google.com/d/msgid/django-users/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%40googlegroups.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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/95d37c13-d5da-4566-913d-cff89975f897%40googlegroups.com<https://groups.google.com/d/msgid/django-users/95d37c13-d5da-4566-913d-cff89975f897%40googlegroups.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 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/9ed9ee85429c4e73ae34335647f812ac%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: BaseModelFormSet > _construct_form

2019-04-02 Thread Matthew Pava
Why are overwriting add_prefix? Why are you overwriting _construct_form?

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of nikolaysm
Sent: Tuesday, April 2, 2019 9:37 AM
To: Django users
Subject: BaseModelFormSet > _construct_form

Hello,

In function _construct_form variable "pk_key" is generated as:
 pk_key = "%s-%s" % (self.add_prefix (i), self.model._meta.pk.name) "

So pk_key is not flexible. Because if I overwrite function "add_prefix" from 
class "forms.ModelForm", I get error "MultiValueDictKeyError".

My add_prefix function:
def add_prefix(self, field_name):
  return '%s_%s' % (self.prefix, field_name) if self.prefix else field_name

I see a possibility to solve that for now. Overwrite function _construct_form.

Other options?
--
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/92616dd1-1e04-43f6-9e91-edfc56dfe5bc%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/a787d9eb08564642ba811f030080f69a%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Thank you for the HINT

2019-03-15 Thread Matthew Pava
I am working on some migration code, and I did not enter the _id suffix to my 
field name in the RunSQL code. Django was very kind to give me the clue to 
reference the column with the _id suffix. That is an amazing hint, and it 
helped significantly. Thank you so much!

-- 
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/87227bb02a994325b5f32f90ed4de889%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Bug in Django 2.1 on ModelMultipleChoiceField

2019-03-14 Thread Matthew Pava
Well, it is raising an error.  It’s a Python error. Basically, you were passing 
a keyword argument (empty_label), and the class was passing the same keyword 
argument called empty_label. Expanded out, this is what was happening:

field = forms.ModelMultipleChoiceField( queryset = Imodelclass.objects.all(), 
empty_label='' )
= ModelMultipleChoiceField(queryset= Imodelclass.objects.all(), 
empty_label=None, empty_label='')

When you read the error, you see that is actually very clear in this context: 
You passed two arguments for the same keyword.
typeError " __init__() got multiple values for keyword argument 'empty_label'

I think it would be wise to mention this in the documentation; perhaps even 
providing a rationale why ModelMultipleChoiceField should not have an empty 
label. But if there is no rationale behind it, then the clear solution is to do 
exactly as you did: remove the empty_label keyword argument from the super call.

From: Odile Lambert [mailto:pisc...@laposte.net]
Sent: Thursday, March 14, 2019 2:10 AM
To: django-users@googlegroups.com; Matthew Pava
Subject: Re: Bug in Django 2.1 on ModelMultipleChoiceField


Hello

If this is by design Django should raise an error indicating that 
ModelMultipleChoiceField does not allow an empty_label attribute

The present error message in the __init__ of the super_class is not coherent 
and very difficult to understand for beginners. I would strongly suggest that 
it is filed as a bug to improve the code either by allowing the empty label or 
by raising the propoer error.

Modifying the documentation does not seem sufficient from my point of view.

Thanks for your suggestion for creating a specific class.

Odile Lambert


Le 13/03/2019 à 22:06, Matthew Pava a écrit :
Looking at it, I would say that this is by design. You shouldn’t use an empty 
label on a multiple choice field. Perhaps this should be clarified in the docs.
Saying that, if you really want an empty label on a multiple choice field, you 
could create your own class that initializes empty_label however you want it.

From: 'Odile Lambert' via Django users [mailto:django-users@googlegroups.com]
Sent: Wednesday, March 13, 2019 1:57 PM
To: Django users
Subject: Bug in Django 2.1 on ModelMultipleChoiceField


Hello,

I believe Bugs in Django are to be reported in this user list. Below is a 
report for a bug which does not seem to be already filed.

In the documentation reference on the ModelMultipleChoiceField there is no 
restrictios mentioned on the empty_label attribute.

Whenever you declare an attribute empy_label for a ModelMultipleChoiceField, it 
generates an error during the system_checks

 typeError " __init__() got multiple values for keyword argument 'empty_label

To reproduce the bug : :

class MyForm(forms.Form):
field = forms.ModelMultipleChoiceField(
queryset = Imodelclass.objects.all(),)
empty_label=(''))

Another user on stackoverflow encountered  this same problem see here : 
https://stackoverflow.com/questions/52263426/django-empty-label-for-modelmultiplechoicefield-multiple-values-for-keyword-arg

The cause of the error is the following :

the code ( see fdjango/forms/models.py line 1266 sets the empty_label attribute 
to None while calling the super_class (ModelChoiceField):

super().__init__(queryset, empty_label=None, **kwargs)

while the super_class.__init__ sets the empy_label to "-".

removing the empty_label= None in the call to the super_class solved the 
problem for me.

best regards

Odile Lambert

--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/063841b4-5b58-4931-6ea3-29188ccc8171%40laposte.net<https://groups.google.com/d/msgid/django-users/063841b4-5b58-4931-6ea3-29188ccc8171%40laposte.net?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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/c6be6380098a49b6bab737a85e

RE: Bug in Django 2.1 on ModelMultipleChoiceField

2019-03-13 Thread Matthew Pava
Looking at it, I would say that this is by design. You shouldn’t use an empty 
label on a multiple choice field. Perhaps this should be clarified in the docs.
Saying that, if you really want an empty label on a multiple choice field, you 
could create your own class that initializes empty_label however you want it.

From: 'Odile Lambert' via Django users [mailto:django-users@googlegroups.com]
Sent: Wednesday, March 13, 2019 1:57 PM
To: Django users
Subject: Bug in Django 2.1 on ModelMultipleChoiceField


Hello,

I believe Bugs in Django are to be reported in this user list. Below is a 
report for a bug which does not seem to be already filed.

In the documentation reference on the ModelMultipleChoiceField there is no 
restrictios mentioned on the empty_label attribute.

Whenever you declare an attribute empy_label for a ModelMultipleChoiceField, it 
generates an error during the system_checks

 typeError " __init__() got multiple values for keyword argument 'empty_label

To reproduce the bug : :

class MyForm(forms.Form):
field = forms.ModelMultipleChoiceField(
queryset = Imodelclass.objects.all(),)
empty_label=(''))

Another user on stackoverflow encountered  this same problem see here : 
https://stackoverflow.com/questions/52263426/django-empty-label-for-modelmultiplechoicefield-multiple-values-for-keyword-arg

The cause of the error is the following :

the code ( see fdjango/forms/models.py line 1266 sets the empty_label attribute 
to None while calling the super_class (ModelChoiceField):

super().__init__(queryset, empty_label=None, **kwargs)

while the super_class.__init__ sets the empy_label to "-".

removing the empty_label= None in the call to the super_class solved the 
problem for me.

best regards

Odile Lambert

--
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/063841b4-5b58-4931-6ea3-29188ccc8171%40laposte.net.
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/c6be6380098a49b6bab737a85e1b5d5b%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Django credit card redaction app - - MultiValueDictKeyError

2019-03-07 Thread Matthew Pava
Please just paste the error in the email message. The error message that you 
have mentions a ‘method’ object, which is not present in the code that you have 
sent to us.  That would be where the problem is.



From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of drone4four
Sent: Thursday, March 7, 2019 11:29 AM
To: Django users
Subject: Re: Django credit card redaction app - - MultiValueDictKeyError


Thanks, Sam for the help.


You wrote:

I would be careful how you pass the data on get, somewhere in your front end 
code you are probably not passing the data through as you expected. Instead of 
using .GET, use .GET.get to get your data. This will either return the value 
you want, or none.


I looked up GET.get Django and found an SO post titled, “Django 
request.GET” 
which has quite a few up votes. Based on that SO answer, In my views.py I 
changed the line (where I declare the number variable) from `number = 
request.GET['ccEntry']` to `number = request.GET.get['ccEntry', None]`


That gives a different error (a type error this time): 
https://pastebin.com/L81LVtzi


You also mentioned my front end. I had included the template in my original 
post. I have since refined it so it is more readable. Here is my improved 
home.html template:







  Search 



  





 

   Enter your fake Chuckee Cheese Neptune credit card number!

   

  Must be a 16 digit number. 

   

 



   Original Card Number:

   {{ number }}

   Redacted Card Number:

   {{ redacted_num }}

Did this work?










Sam, you also suggested:

I think you have made the error of not passing your data to the get header as 
you didn't explicitly write this on the form element.


I did explicitly include my data in my form element as you can see in the above 
template.

Check the URL and log the get object in Django to make sure the data is 
actually appearing in both.


The data is present as “ccEntry” in both home.html and in views.py.




On Thursday, March 7, 2019 at 10:42:25 AM UTC-5, Sam Taiwo wrote:
I would be careful how you pass the data on get, somewhere in your front end 
code you are probably not passing the data through as you expected. Instead of 
using .GET, use .GET.get to get your data. This will either return the value 
you want, or none. I think you have made the error of not passing your data to 
the get header as you didn't explicitly write this on the form element. Check 
the URL and log the get object in Django to make sure the data is actually 
appearing in both.

On Thu, Mar 7, 2019, 13:52 drone4four > wrote:

Hello!


I’m trying to run a basic Django app which redacts a 16 digit number entered by 
the user. I had a it running a few minutes ago. I’m not sure what I changed, 
but now I am getting a MultiValueDictKeyError. I’ve triple checked every 
variable. The only dictionary in my project is in views.py at line 7. As far as 
I can tell, it’s all accurate and positioned correctly. I don’t recall changing 
this dictionary or any other operator around this line. I’m stumped. What would 
you people suggest? Have a look at my setup.



Here is the error and traceback in full: https://pastebin.com/QwSrmAJx


Here is my urls.py:
from django.conf.urls import  include, url



from django.contrib import admin

from django.urls import path

from . import views


urlpatterns = [

   url(r'^admin/', admin.site.urls),

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




views.py:
from django.http import HttpResponse



from django.shortcuts import render


def home(request):

   number = request.GET['ccEntry']

   redacted_num = '   {}'.format(number[-4:])

   return render(request, 'home.html', {'number':number, 
'redacted_num':redacted_num})




home.html template:









 

   Enter your fake Chuckee Cheese Neptune credit card number!

   

 

 

 

   Must be a 16 digit number.

 

 

   

   

   

   

   Original Card Number:

   

   {{ number }}

   

   Redacted Card Number:

   

   {{ redacted_num }}

   

Did this work?

   





--
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/49da3086-6f3d-415b-b451-7e4c6a6e542c%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 

RE: Is there any inline editing the data and delete data in table in Django?

2019-03-04 Thread Matthew Pava
See https://datatables.net.
They have a nice editor that you do have to pay for.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Derek
Sent: Monday, March 4, 2019 1:10 AM
To: Django users
Subject: Re: Is there any inline editing the data and delete data in table in 
Django?

Grid / tabular editing outside of the admin is tricky; I have not been able to 
manage it and have not found a good app for it.

Here are some suggested reading:

* https://www.ibm.com/developerworks/library/wa-django/index.html
* https://bossanova.uk/jexcel
* 
https://medium.com/ag-grid/building-a-crud-application-with-ag-grid-part-4-3189034df922

You'd also need an app like Django REST Framework to handle GET/POST of JSON 
data to populate your grid.

On Wednesday, 27 February 2019 20:39:04 UTC+2, veera nagaraja sankar Inti wrote:
need help friends ?..

thq..
--
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/3862-8662-4392-bd5b-00d07b4de8b3%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/119f367cac364a7583d7f055bd749558%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: How to create model for this json data

2019-02-19 Thread Matthew Pava
You can use ForeignKey.
Or ArrayField if you're using PostgreSQL as your backend.

https://docs.djangoproject.com/en/2.1/ref/contrib/postgres/fields/#arrayfield


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of optvisi...@gmail.com
Sent: Tuesday, February 19, 2019 10:02 AM
To: Django users
Subject: How to create model for this json data

Hi I have data like this
{
"Name" : "pk",
"Applist" : ["zom","bc"],
 "Url":   ["As","de"]

}

How to define field name for list I am not getting

-- 
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/1dbdd1f4-6d19-4cc7-828b-e360395edf6e%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/b5f32b6b7e4643d19fdb30c83b8bb229%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Re: Composite Primary / Foreign Key support

2019-02-18 Thread Matthew Pava
"As your requirement is read-only if the data is static you could to create a 
second database, with all the PK of the legacy database, and
then as single Pk field to that table, and access everything through a view of 
a join the two tables."

I had such a requirement, and I created a View in PostgreSQL in the same 
database.  The pk field I created was just a Window function for the current 
row in the data set.  Since I didn't need that anyway, I could safely ignore 
it.  Since it was a truly read-only model, I didn't need to worry about the 
composite key.

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Roger Gammans
Sent: Monday, February 18, 2019 11:30 AM
To: django-users@googlegroups.com
Subject: Re: Re: Composite Primary / Foreign Key support

Lance,

I can't speak for the core team, only inform you based on what I've
seen here and in other projects.

I suspect if there was a significant need across a number of users,
then enough work could be done by those that needed it and as long as
it was 
1) fully functional, 
2) had clean good code 
3) the people who wrote where going to stay within the
community to support it 

Then there is a chance a set of code written might get merged, I don't
however thing there is sufficient interest from the core team for them
to do the work themselves.

Those requirements are quite a high bar, I started on some code to do
this, for a project a few years ago and got a limited set of composite
key functionality working in my own tree, which was just about enough
for the project I was working on. So I do have some understanding of
what is needed, and how intrusive and can get.

My code was fine for reading and writing, but you couldn't use
ForeignKey Fields to traverse composite key relationships. Which has a
surprising number of corner cases. This was for Django 1.8 and isn't
compatible with later versions (unfortunately). On the other hand some
of the code changes in the ORM point at a better approach, than we
took.

So it possible, but someone will need to invest some time into it.


The only immediately helpfuly ideas I have are;
As your requirement is read-only if the data is static you could to create a 
second database, with all the PK of the legacy database, and
then as single Pk field to that table, and access everything through a view of 
a join the two tables. 

Of course if another app is adding rows then you are a bit stuck, but if you 
absolutely can't add a autonumber field to use as a fake PK, then there is not 
a lot you can do. I've started adding single PK autonumber fields to legacy 
databases now when I get this issue, and
making the old PK into a unique index. So far that has working and hasn't 
broken my legacy apps.

If those are no good, either you can't use django or you going to need to 
invest in understanding the ORMs internals.

HTH,

-- 
Roger Gammans 
Gamma Science


On Mon, 2019-02-18 at 08:26 +, 'Ellinghaus, Lance J' via Django
users wrote:
> 
> ONCONFIDENTIAL // 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, 

RE: Password Policy Adherence. Cannot use the passwords used before

2019-02-08 Thread Matthew Pava
I completely support this NIST policy, James.  Unfortunately, the PCI Security 
Standards Council does not support this policy at this time.  In order for a 
company to be PCI compliant, users must change their passwords every three 
months.  PCI compliance is essential for companies to adhere to when they are 
processing credit cards.  There are ways around the requirements; companies 
could basically out-source credit card processing to other companies such as 
Stripe or Square, but they need to know what they are doing to maintain 
compliance.

https://www.pcisecuritystandards.org/documents/Payment-Data-Security-Essential-Strong-Passwords.pdf?agreement=true=1549638814227



From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of James Bennett
Sent: Friday, February 8, 2019 9:00 AM
To: django-users@googlegroups.com
Subject: Re: Password Policy Adherence. Cannot use the passwords used before

I'm going to suggest you step back and consider whether the policies you want 
to implement are good policies. A good, solidly-researched set of 
recommendations is NIST SP800-63B:

https://pages.nist.gov/800-63-3/sp800-63b.html

In particular, NIST suggests the following:

* Do not use a policy which automatically "expires" passwords and forces users 
to change them periodically. Only force a password change when you have 
evidence that a password has been compromised.
* Do not try to impose artificial "complexity" rules (like requiring a mix of 
uppercase/lowercase, numbers and symbols).
* When a user changes their password, compare it against lists of 
known-compromised passwords.

Forcing users to change their passwords on a set schedule just encourages them 
to choose weak passwords that are easy to remember. If you force me to change 
my password every three months, for example, here's what I'll do:

* P@ssword!2019_1
* P@ssword!2019_2
* P@ssword!2019_3
* P@ssword!2019_4

These passwords are all different from each other, and they each contain at 
least one uppercase and one lowercase letter, at least one number and at least 
one symbol. They're also terrible passwords that would probably get cracked 
within minutes, if not seconds, by any good automated cracker.
That's a year's worth of passwords, each of which is different from the last, 
each contains one
--
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/CAL13Cg9Xi7QdCCffqROi_FjLzKimtWYBR%3DusMxf6ihf_E6%3D-9A%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/7d7e9de09028498e8fca89973db6484f%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: how to let django return response to web browser at my own function

2019-02-06 Thread Matthew Pava
You probably just want to use the login_required decorator.
https://docs.djangoproject.com/en/2.1/topics/auth/default/#the-login-required-decorator


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of ???
Sent: Wednesday, February 6, 2019 12:40 AM
To: Django users
Subject: how to let django return response to web browser at my own function

I want to write a function 'get_user_or_log_in' to check whether the user has 
logged or not. If logged, return user's name, if not, redirect to the login 
page. I want to use it like function 'get_object_or_404'. But I do not know how 
to let  django response at my own function not just at the end of functions in 
views.py .

-- 
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/1c4981ef-a3bc-40c3-a521-0287442f37b9%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/0893b59667aa435a948909a7dcc24bfa%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Admin form_url breakout problem

2019-02-04 Thread Matthew Pava
The flow looks fine.  And when you click refresh on your browser on step 4 does 
the page refresh properly?

Perhaps it's a caching issue.
Are you wrapping the billing_payment_view with admin_view()?
https://docs.djangoproject.com/en/2.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_urls
 --> scroll towards the bottom of that section


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mike Dewhirst
Sent: Sunday, February 3, 2019 1:42 AM
To: django-users@googlegroups.com
Subject: Re: Admin form_url breakout problem

Matthew

I was wrong. I'm still in trouble. I thought it might be an incomplete 
transaction so I tried making the the subscription.save() atomic but to 
no avail.

Here is what happens ...

1.  Add an ingredient which is payable

2.  Save mixture

3.  SubstanceAdmin.change_view() establishes ...

     subscription = None
     if ingredient.is_payable():
     get or create a subscription record and populate it with fee, 
gst etc.
     if the subscription.token field is blank (ie not paid):
     call billing_payment_view() which interfaces with Stripe 
via a js popup and
     a) gets a token in a hidden field
     b) calls Stripe.charge(token) and gets a json charge 
record back
                 c) populates the subscription.token field
     d) saves the subscription record
     e) creates a receipt record
     f) sends an email receipt
     g) puts thank you text and mixture url into context dict
     h) calls billing_success_view(request, context) to 
display success
    message including link back to mixture
     return super(SubstanceAdmin, self).change_view()

4.  On clicking the back-to-the-mixture link in success.html, the Admin 
brings
     up the Change Substance page without error but which is blank below the
     "Change Substance" heading. At that time the displayed URL in the 
address
     bar is exactly correct.

5.  If the dev server reloads the page will paint properly if refreshed.

Theory:

The subscription record has been saved but not in a way which is visible 
yet thereby confusing change_view() into thinking the token field is blank.

In other words the transaction needs to be committed 
pre-billing_success_view()

In testing this it sadly this makes no difference.

Mike


On 2/02/2019 6:06 pm, Mike Dewhirst wrote:
> I think I know. Don't waste time on this. I'll report back later.
>
> Mike
>
> On 2/02/2019 3:27 pm, Mike Dewhirst wrote:
>> I thought it was fixed but not so. It works perfectly *only* if the 
>> dev server reloads after all the work and prior to clicking the link 
>> on the success.html template back to the mixture (the substance with 
>> ingredients).
>>
>> I tried a workaround of making the link point to the substances list 
>> page first. No difference. All substance pages come up blank.
>>
>> When I reported earlier that it was working I must have changed some 
>> text in a view to improve the screen wording and on saving the dev 
>> server would have reloaded itself and that hid the problem.
>>
>> The admin url is correct  ...
>>
>> http://localhost:8000/admin/substance/substance/1442/change/
>>
>> ... but that refuses to display. There is no delay, no spinner. The 
>> server console window shows nothing.
>>
>> Not sure where to start looking.
>>
>> Maybe something has corrupted Django's in-memory list of url patterns?
>>
>> Is it caching?
>>
>> Thanks for any non-javascript hints
>>
>> Mike
>>
>> On 30/01/2019 5:13 pm, Mike Dewhirst wrote:
>>> Matthew
>>>
>>> I looked for preventDefault and found it in lots of javascript 
>>> scripts. So I decided instead to look at my python code which is 
>>> slightly easier for me to understand. I sort of refactored it and 
>>> cut large swags out to simplify and inserted lots of print 
>>> statements. Then I thought I'd better read your advice again and try 
>>> harder to understand it.
>>>
>>> The bit which made sense to me was ...
>>>
>>> 'let the admin handle it from there'
>>>
>>> ... I noticed that I was returning the billing payment_view. As soon 
>>> as I removed that 'return' and let the change_view return the super 
>>> call it started working.
>>>
>>> Thank you very much for persisting with me.
>>>
>>> The Admin is fabulous! Nobel prize for something is warranted :)
>>>
>>> Much appreciated
>>>
>>> Mike
>>>
>>> On 29/01/2019 2:31 am, Matthew Pava wrote:
>>>> Hi Mike,
&

RE: Get very last object of database

2019-01-30 Thread Matthew Pava
You can try Mydb.objects.last()
You can also try reversing the order and using first:  
Mydb.objects.order_by(‘-pk’).first()

And for some terminology clarification, a database consists of tables.  In 
Django, a model maps to a table, not a database.  A table has fields; a 
database has tables but not fields.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Stéphane Manguette
Sent: Wednesday, January 30, 2019 4:02 PM
To: Django users
Subject: Get very last object of database

Hello guys,

My issue is pretty simple. I want to get the very last record of my database 
(which is populated with thousands of entries)

So far ->very easy. But I want to make sure that the access to the database is 
as light as possible. Don't want django to parse everything in my database.

Kindly note that my DB has Primary key field.

I tried
Mydb.objects.all()[:1]

Mydb.objects.all()[1:]


but both return the first filed instead of the last one.

Thanks for your help

Stephane
--
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/32533a94-d27f-4091-9910-6644cd11ea49%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/cacd493cb77144439571ce4f29aa3514%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Admin form_url breakout problem

2019-01-28 Thread Matthew Pava
Hi Mike,
When Stripe processes the payment, you need to preventDefault on the form 
submit, then add the token from Stripe to a hidden input in your form without 
affecting any other data in the form.  Then you can do form.submit() and let 
the admin handle it from there.  Check out the Stripe documentation for some 
good examples.  I've used it myself.

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mike Dewhirst
Sent: Friday, January 25, 2019 10:26 PM
To: django-users@googlegroups.com
Subject: Re: Admin form_url breakout problem

Matthew

I think I'll back everything out and start again. There must be a basic 
blunder somewhere.

Just talking it through, I can definitely launch payment_view from the 
Admin when all the ducks are in a line. That view populates the hidden 
..._id fields and Stripe API fields in the form then calls the Stripe 
API which initiates the  Stripe javascript in the Payment template which 
resubmits the request with POST direct to Stripe so it can gather the 
card detail and send back the json containing the token which proves the 
card worked. At that point payment is made and my payment_view has lost 
all the context because Stripe made the request not Django. payment_view 
detects the Stripe response and must reconstruct the model instances 
from the data pre-placed in the hidden form fields. Once the instances 
are retrieved that payment_view code updates the subscription record, 
creates a receipt record , assembles a message for the success_view and 
sends an email to the user.

I am having trouble understanding the correct way to launch payment_view 
so that Admin doesn't get confused wanting to add payment/ to the url 
and thus keeping it all within the Admin.

Regarding your comment on using reverse to derive the link, I agree. I 
was just being somewhat paranoid and skipping the reverse code which I 
haven't taken the time to study. I will.

Thanks again

Mike


On 26/01/2019 1:59 am, Matthew Pava wrote:
>
> Based on the error message, it looks like you’re trying to call 
> reverse(‘admin’) somewhere, but that’s not in the code you shared.  
> Actually, you probably want to use a reverse call when populating 
> content[‘link’].
>
> *From:*django-users@googlegroups.com 
> [mailto:django-users@googlegroups.com] *On Behalf Of *Mike Dewhirst
> *Sent:* Friday, January 25, 2019 3:35 AM
> *To:* django-users@googlegroups.com
> *Subject:* Re: Admin form_url breakout problem
>
> On 25/01/2019 2:40 am, Matthew Pava wrote:
>
> Hi Mike,
>
> I'm not really seeing why this is throwing errors at you.  It seems like 
> you've done everything right.  Could you provide the code (or the relevant 
> parts) for the Substance Admin form?
>
> Thanks!
>
>
> Matthew
>
> I'm still in trouble and including some code. I'm not being precious 
> about it just hoping not to overwhelm you. Please ask for the next 
> instalment ...
>
> class SubstanceAdmin(admin.ModelAdmin):
>
>     def subscribe(self, sm2mi, fee_type, fullyear=False):
>     """
>     sm2mi is the substance<-ingredient m2m through record
>     fee_type determines the subscription fee amount
>     fullyear=False means calculate the fee pro-rata to 30 September
>
>     We don't need a request here so this can be imported from 
> elsewhere.
>     Only called if a fee is payable. Only returns a subscription 
> if no token or
>         fullyear == True meaning a subscription renewal is due
>     """
>     subscription, new = Subscription.objects.get_or_create(
>     licensee=sm2mi.substance.division.company,
>     ingredient=sm2mi.ingredient,
>     fee_type=fee_type,
>     )
>     if not subscription.token or fullyear:
>     return subscription
>
>     def change_view(self, request, object_id, form_url='', 
> extra_context=None):
>     """
>     For the billing system we want to include all the context data 
> so the
>     change_form populates itself properly. See collect_content
>     self = SubstanceAdmin
>     request = wsgi request object
>     object_id = substance
>     form_url = no idea!
>     extra_context = no_idea
>     """
>     sm2mis = 
> Substance_Ingredients.objects.filter(substance_id=object_id)
>     for sm2mi in sm2mis:
>     payable, fee_type = sm2mi.fee_payable()  # eg., True, 
> PAID_DATA
>     if payable:
>     subscription = self.subscribe(sm2mi, fee_type)
>     if subscription:    # we need to collect money for the 
> owner
>     self.change_form_template = 'payment.html'
> 

RE: Admin form_url breakout problem

2019-01-25 Thread Matthew Pava
Based on the error message, it looks like you’re trying to call 
reverse(‘admin’) somewhere, but that’s not in the code you shared.  Actually, 
you probably want to use a reverse call when populating content[‘link’].


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mike Dewhirst
Sent: Friday, January 25, 2019 3:35 AM
To: django-users@googlegroups.com
Subject: Re: Admin form_url breakout problem

On 25/01/2019 2:40 am, Matthew Pava wrote:

Hi Mike,

I'm not really seeing why this is throwing errors at you.  It seems like you've 
done everything right.  Could you provide the code (or the relevant parts) for 
the Substance Admin form?

Thanks!

Matthew

I'm still in trouble and including some code. I'm not being precious about it 
just hoping not to overwhelm you. Please ask for the next instalment ...

class SubstanceAdmin(admin.ModelAdmin):

def subscribe(self, sm2mi, fee_type, fullyear=False):
"""
sm2mi is the substance<-ingredient m2m through record
fee_type determines the subscription fee amount
fullyear=False means calculate the fee pro-rata to 30 September

We don't need a request here so this can be imported from elsewhere.
Only called if a fee is payable. Only returns a subscription if no 
token or
fullyear == True meaning a subscription renewal is due
"""
subscription, new = Subscription.objects.get_or_create(
licensee=sm2mi.substance.division.company,
ingredient=sm2mi.ingredient,
fee_type=fee_type,
)
if not subscription.token or fullyear:
return subscription

def change_view(self, request, object_id, form_url='', extra_context=None):
"""
For the billing system we want to include all the context data so the
change_form populates itself properly. See collect_content
self = SubstanceAdmin
request = wsgi request object
object_id = substance
form_url = no idea!
extra_context = no_idea
"""
sm2mis = Substance_Ingredients.objects.filter(substance_id=object_id)
for sm2mi in sm2mis:
payable, fee_type = sm2mi.fee_payable()  # eg., True, PAID_DATA
if payable:
subscription = self.subscribe(sm2mi, fee_type)
if subscription:# we need to collect money for the owner
self.change_form_template = 'payment.html'
content = collect_content(
sm2mi,
subscription,
)
return payment_view(
request,
sm2mi,
subscription,
content=content
)

return super(SubstanceAdmin, self).change_view(
request, object_id, form_url, extra_context=extra_context,
)

Here is the payment form ... which is further down in admin.py

class IngredientsInline(admin.StackedInline):

class PaymentForm(admin.StackedInline.form):
sm2mi_id = forms.CharField(widget=forms.HiddenInput, required=False)
ingredient_id = forms.CharField(widget=forms.HiddenInput, 
required=False)
subscription_id = forms.CharField(widget=forms.HiddenInput, 
required=False)
licensee_id = forms.CharField(widget=forms.HiddenInput, 
required=False)

stripeToken = forms.CharField(widget=forms.HiddenInput, 
required=False)
stripeEmail = forms.CharField(widget=forms.HiddenInput, 
required=False)
stripeBillingName = forms.CharField(widget=forms.HiddenInput, 
required=False)
stripeBillingAddressLine1 = 
forms.CharField(widget=forms.HiddenInput, required=False)
stripeBillingAddressZip = forms.CharField(widget=forms.HiddenInput, 
required=False)
stripeBillingAddressState = 
forms.CharField(widget=forms.HiddenInput, required=False)
stripeBillingAddressCity = 
forms.CharField(widget=forms.HiddenInput, required=False)
stripeBillingAddressCountry = 
forms.CharField(widget=forms.HiddenInput, required=False)

form = PaymentForm

All of the above is working so far as launching the Stripe javascript popup and 
generating the receipt record correctly and so on but does not return to the 
admin nor render the success page.

The try/except block in payment_view() barfs as follows ...

content['sm2mi'] = sm2mi
content['receipt'] = receipt
content['subscription'] = subscription
content['message'] = mark_safe(display_message)
content['link'] = '/admin/substance/substance/{0}/change/'.format(
sm2mi.substance.id
)
# report success to the card payer
try:
   

RE: Admin form_url breakout problem

2019-01-24 Thread Matthew Pava
Hi Mike,
I'm not really seeing why this is throwing errors at you.  It seems like you've 
done everything right.  Could you provide the code (or the relevant parts) for 
the Substance Admin form?
Thanks!

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mike Dewhirst
Sent: Wednesday, January 23, 2019 5:23 PM
To: django-users@googlegroups.com
Subject: Re: Admin form_url breakout problem

On 24/01/2019 9:35 am, Matthew Pava wrote:
> Have you tried setting APPEND_SLASH = False in your settings?

Yes. The result is ...


  Page not found(404)

Request Method: POST
Request URL: 
http://localhost:8000/admin/substance/substance/1442/change/payment

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


... followed by all the urls the most pertinent one of which is ...

^admin/ ^substance/substance/ ^(.+)/change/$ 
[name='substance_substance_change']




>
> -Original Message-
> From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
> Behalf Of Mike Dewhirst
> Sent: Wednesday, January 23, 2019 3:48 PM
> To: django-users@googlegroups.com
> Subject: Re: Admin form_url breakout problem
>
> On 24/01/2019 1:08 am, Matthew Pava wrote:
>> It looks like your second URL is different than the first.
>>
>> */admin/substance/substance/1442/change/payment*
>>
>> */admin/substance/substance/1442/change/payment/change/*
>>
>> If you just want to add a slash, then add it.
>>
>> */admin/substance/substance/1442/change/payment/*
>>
>> I’m guessing that Django is interpreting the second URL like so:
>>
>> */admin/substance/substance/(pk=1442/change/payment)/change/*
>>
> You are right. It looks like Django expects the last element of the url
> to be the id and automatically appends 'change' to a modelAdmin url.
> That apparently invokes the 'change' form.
>
> My mission (I think) is to find a way to launch a non-Admin url from
> inside the Admin. Or perhaps from a model method.
>
> That is what I meant with the word 'breakout' in the subject line.
>
> Derek suggested a modelAdmin wrapper a few days ago ... "Basically you
> can create your own view and use that to display data in a template that
> inherits from, for example, the Django admin form template. A bit tricky
> first time but then it seems straightforward."
>
> I'm finding it a bit tricky for sure!
>
> If you can see a way ...
>
> Thanks
>
> Mike
>
>> *From:*django-users@googlegroups.com
>> [mailto:django-users@googlegroups.com] *On Behalf Of *Mike Dewhirst
>> *Sent:* Wednesday, January 23, 2019 12:57 AM
>> *To:* Django users
>> *Subject:* Admin form_url breakout problem
>>
>> How can I break out of the Admin to a payment gateway? I've tried
>> form_url='billing:payment_view'  in SubstanceAdmin.change_view()
>> unsuccessfully.
>>
>> I can semi-break out of the admin and get the beginning of a payment
>> happening with the following ...
>>
>> SubstanceAdmin.change_form_template = payment.html (which has Stripe
>> js and necessary hidden fields)
>> or
>> ./templates/admin/substance/substance/change_form.html (identical to
>> payment.html except it calls block.super at the end to render the rest
>> of the admin page)
>>
>> SubstanceAdmin.change_view() which collects the contextual data
>> required for either template
>>
>> IngredientsInline.form (inherits  admin.StackedInline.form) for all
>> the hidden fields for each ingredient.
>>
>> With all that, if an ingredient hasn't been paid for, the
>> billing.Subscription record won't have a Stripe token so the Admin
>> will launch the payment page. On entering credit card detail and
>> pressing the button, Stripe happily takes the money and issues a
>> token. BUT the Admin then barfs with ...
>>
>>
>>
>>RuntimeError at /admin/substance/substance/1442/change/payment
>>
>> You called this URL via POST, but the URL doesn't end in a slash and
>> you have APPEND_SLASH set. Django can't redirect to the slash URL
>> while maintaining POST data. Change your form to point to
>> localhost:8000/admin/substance/substance/1442/change/payment/ (note
>> the trailing slash), or set APPEND_SLASH=False in your Django settings.
>>
>>
>> ... If I add a slash in the browser address bar and press Enter the
>> next problem emerges ...
>>
>>
>>
>>ValueError at /admin/substance/substance/1442/change/payment/change/
>>
>> invalid literal for int() with base 10: '1442/change/payment'
>>
>>
>> 

RE: Admin form_url breakout problem

2019-01-23 Thread Matthew Pava
Have you tried setting APPEND_SLASH = False in your settings?

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mike Dewhirst
Sent: Wednesday, January 23, 2019 3:48 PM
To: django-users@googlegroups.com
Subject: Re: Admin form_url breakout problem

On 24/01/2019 1:08 am, Matthew Pava wrote:
>
> It looks like your second URL is different than the first.
>
> */admin/substance/substance/1442/change/payment*
>
> */admin/substance/substance/1442/change/payment/change/*
>
> If you just want to add a slash, then add it.
>
> */admin/substance/substance/1442/change/payment/*
>
> I’m guessing that Django is interpreting the second URL like so:
>
> */admin/substance/substance/(pk=1442/change/payment)/change/*
>

You are right. It looks like Django expects the last element of the url 
to be the id and automatically appends 'change' to a modelAdmin url. 
That apparently invokes the 'change' form.

My mission (I think) is to find a way to launch a non-Admin url from 
inside the Admin. Or perhaps from a model method.

That is what I meant with the word 'breakout' in the subject line.

Derek suggested a modelAdmin wrapper a few days ago ... "Basically you 
can create your own view and use that to display data in a template that 
inherits from, for example, the Django admin form template. A bit tricky 
first time but then it seems straightforward."

I'm finding it a bit tricky for sure!

If you can see a way ...

Thanks

Mike

> *From:*django-users@googlegroups.com 
> [mailto:django-users@googlegroups.com] *On Behalf Of *Mike Dewhirst
> *Sent:* Wednesday, January 23, 2019 12:57 AM
> *To:* Django users
> *Subject:* Admin form_url breakout problem
>
> How can I break out of the Admin to a payment gateway? I've tried 
> form_url='billing:payment_view'  in SubstanceAdmin.change_view() 
> unsuccessfully.
>
> I can semi-break out of the admin and get the beginning of a payment 
> happening with the following ...
>
> SubstanceAdmin.change_form_template = payment.html (which has Stripe 
> js and necessary hidden fields)
> or
> ./templates/admin/substance/substance/change_form.html (identical to 
> payment.html except it calls block.super at the end to render the rest 
> of the admin page)
>
> SubstanceAdmin.change_view() which collects the contextual data 
> required for either template
>
> IngredientsInline.form (inherits  admin.StackedInline.form) for all 
> the hidden fields for each ingredient.
>
> With all that, if an ingredient hasn't been paid for, the 
> billing.Subscription record won't have a Stripe token so the Admin 
> will launch the payment page. On entering credit card detail and 
> pressing the button, Stripe happily takes the money and issues a 
> token. BUT the Admin then barfs with ...
>
>
>
>   RuntimeError at /admin/substance/substance/1442/change/payment
>
> You called this URL via POST, but the URL doesn't end in a slash and 
> you have APPEND_SLASH set. Django can't redirect to the slash URL 
> while maintaining POST data. Change your form to point to 
> localhost:8000/admin/substance/substance/1442/change/payment/ (note 
> the trailing slash), or set APPEND_SLASH=False in your Django settings.
>
>
> ... If I add a slash in the browser address bar and press Enter the 
> next problem emerges ...
>
>
>
>   ValueError at /admin/substance/substance/1442/change/payment/change/
>
> invalid literal for int() with base 10: '1442/change/payment'
>
>
> ... which tells me the Admin is hoping for 
> /admin/substance/substance/1442/
>
> I don't know where to go now.
>
> My preference would be to leave the Admin somehow and handle the 
> payment externally with my billing.payment_view() and 
> billing.success_view() then at the end find a way to give that 
> hoped-for url to the server and expect the substance to come up 
> normally in the admin.
>
> Any advice will be greatly appreciated. Happy to show any code you 
> might want to see.
>
> Many thanks
>
> 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 
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com 
> <mailto: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/f8061a7d-27b5-c929-c364-d8870829ad3e%40dewhirst.com.au
>  
> <https://groups.google.com/d/

RE: Django Databade

2019-01-23 Thread Matthew Pava
The database is just a separate application on your computer.

It is _not_ a Python package, so you can’t use pip  to install it.  If your 
host has MySQL and you can’t install PostgreSQL on it, then you might just want 
to make your life easier and install MySQL on your development computer.

Now, you will need a Python package that acts as an interface between Django 
and the database application.  For PostgreSQL, it is psycopg2.  More details 
are in the Django documentation.


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of RETAIL CYBER
Sent: Wednesday, January 23, 2019 1:01 AM
To: Django users
Subject: Re: Django Databade

when installing on home system will this be like some time of virtual db system 
or should i use like pip to install into the django server? just like 
everything else? im looking to move to my main server I know my host has mysql?
please help me id be very appreciative.

On Tuesday, January 22, 2019 at 12:02:58 PM UTC-6, Matthew Pava wrote:
You can install PostgreSQL on your home system, if I understand your concern 
correctly.

From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of RETAIL CYBER
Sent: Tuesday, January 22, 2019 10:43 AM
To: django...@googlegroups.com
Subject: Re: Django Databade

My thing is I'm trying to get it to my server I have vps most tutorials I see 
are in the view of someone running it on thier home system.


On Tue, Jan 22, 2019, 9:08 AM Matthew Pava  
wrote:
PostgreSQL is my preference.  Stick with the built-in backends:
https://docs.djangoproject.com/en/2.1/ref/settings/#engine



-Original Message-
From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of 
official...@gmail.com
Sent: Tuesday, January 22, 2019 8:06 AM
To: Django users
Subject: Django Databade

Guys please kindly advise me, what db is pleasant for django projects, been 
trying to use firebase with pyrebase but it is slow and not efficient.
Thanks.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users...@googlegroups.com.
To post to this group, send email to djang...@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/8041ecf4-ab38-4ce3-adf1-7341dc309195%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users...@googlegroups.com.
To post to this group, send email to djang...@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/1a4f0e9415bb480f90c6558e5da7b44e%40iss2.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...@googlegroups.com.
To post to this group, send email to djang...@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/CAGNKn_BSeEsKOnN0NyzKebU%2BzbOZcc1T8E1Q_FRJDTyT9FX%2BEA%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAGNKn_BSeEsKOnN0NyzKebU%2BzbOZcc1T8E1Q_FRJDTyT9FX%2BEA%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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/c79ff119-4f6e-4f13-8474-77a039a1a4a5%40googlegroups.com<https://groups.google.com/d/msgid/django-users/c79ff119-4f6e-4f13-8474-77a039a1a4a5%40googlegroups.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 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.

RE: Admin form_url breakout problem

2019-01-23 Thread Matthew Pava
It looks like your second URL is different than the first.
/admin/substance/substance/1442/change/payment
/admin/substance/substance/1442/change/payment/change/

If you just want to add a slash, then add it.
/admin/substance/substance/1442/change/payment/

I’m guessing that Django is interpreting the second URL like so:
/admin/substance/substance/(pk=1442/change/payment)/change/


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mike Dewhirst
Sent: Wednesday, January 23, 2019 12:57 AM
To: Django users
Subject: Admin form_url breakout problem

How can I break out of the Admin to a payment gateway? I've tried 
form_url='billing:payment_view'  in SubstanceAdmin.change_view() unsuccessfully.

I can semi-break out of the admin and get the beginning of a payment happening 
with the following ...

SubstanceAdmin.change_form_template = payment.html (which has Stripe js and 
necessary hidden fields)
or
./templates/admin/substance/substance/change_form.html (identical to 
payment.html except it calls block.super at the end to render the rest of the 
admin page)

SubstanceAdmin.change_view() which collects the contextual data required for 
either template

IngredientsInline.form (inherits  admin.StackedInline.form) for all the hidden 
fields for each ingredient.

With all that, if an ingredient hasn't been paid for, the billing.Subscription 
record won't have a Stripe token so the Admin will launch the payment page. On 
entering credit card detail and pressing the button, Stripe happily takes the 
money and issues a token. BUT the Admin then barfs with ...



RuntimeError at /admin/substance/substance/1442/change/payment

You called this URL via POST, but the URL doesn't end in a slash and you have 
APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST 
data. Change your form to point to 
localhost:8000/admin/substance/substance/1442/change/payment/ (note the 
trailing slash), or set APPEND_SLASH=False in your Django settings.

... If I add a slash in the browser address bar and press Enter the next 
problem emerges ...



ValueError at /admin/substance/substance/1442/change/payment/change/

invalid literal for int() with base 10: '1442/change/payment'

... which tells me the Admin is hoping for /admin/substance/substance/1442/

I don't know where to go now.

My preference would be to leave the Admin somehow and handle the payment 
externally with my billing.payment_view() and billing.success_view() then at 
the end find a way to give that hoped-for url to the server and expect the 
substance to come up normally in the admin.

Any advice will be greatly appreciated. Happy to show any code you might want 
to see.

Many thanks

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/msgid/django-users/f8061a7d-27b5-c929-c364-d8870829ad3e%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/d0ae4053cd254b2bbc982cff3637d0a6%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Django Databade

2019-01-22 Thread Matthew Pava
You can install PostgreSQL on your home system, if I understand your concern 
correctly.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of RETAIL CYBER
Sent: Tuesday, January 22, 2019 10:43 AM
To: django-users@googlegroups.com
Subject: Re: Django Databade

My thing is I'm trying to get it to my server I have vps most tutorials I see 
are in the view of someone running it on thier home system.


On Tue, Jan 22, 2019, 9:08 AM Matthew Pava 
mailto:matthew.p...@iss.com> wrote:
PostgreSQL is my preference.  Stick with the built-in backends:
https://docs.djangoproject.com/en/2.1/ref/settings/#engine



-Original Message-
From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
[mailto:django-users@googlegroups.com<mailto:django-users@googlegroups.com>] On 
Behalf Of officialjoemay...@gmail.com<mailto:officialjoemay...@gmail.com>
Sent: Tuesday, January 22, 2019 8:06 AM
To: Django users
Subject: Django Databade

Guys please kindly advise me, what db is pleasant for django projects, been 
trying to use firebase with pyrebase but it is slow and not efficient.
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<mailto:django-users%2bunsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/8041ecf4-ab38-4ce3-adf1-7341dc309195%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<mailto:django-users%2bunsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/1a4f0e9415bb480f90c6558e5da7b44e%40iss2.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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/CAGNKn_BSeEsKOnN0NyzKebU%2BzbOZcc1T8E1Q_FRJDTyT9FX%2BEA%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAGNKn_BSeEsKOnN0NyzKebU%2BzbOZcc1T8E1Q_FRJDTyT9FX%2BEA%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 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/9fcc47b21b9d4fdda9042710a73e6633%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Django Databade

2019-01-22 Thread Matthew Pava
PostgreSQL is my preference.  Stick with the built-in backends:
https://docs.djangoproject.com/en/2.1/ref/settings/#engine



-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of officialjoemay...@gmail.com
Sent: Tuesday, January 22, 2019 8:06 AM
To: Django users
Subject: Django Databade

Guys please kindly advise me, what db is pleasant for django projects, been 
trying to use firebase with pyrebase but it is slow and not efficient.
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/8041ecf4-ab38-4ce3-adf1-7341dc309195%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/1a4f0e9415bb480f90c6558e5da7b44e%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Is Microsoft Visual Studion 2017 Environment is good for Django development ?

2019-01-21 Thread Matthew Pava
I use PyCharm.
https://www.jetbrains.com/pycharm/


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Django Geek Aditya
Sent: Sunday, January 20, 2019 1:55 AM
To: Django users
Subject: Is Microsoft Visual Studion 2017 Environment is good for Django 
development ?

I am a beginner in Django. Is Microsoft Visual Studio will be a better 
environment to start with django from basics.
They are providing a detailed help on their website 
LINK.
 Please help me and suggest me the ways to proceed further.
I want to enter into the Web Development with Django and I have to work on my 
idea.
--
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/e8a0bf47-2906-41cf-a109-14fef6e60f68%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/8eed738aec364d76b47a35560abc1913%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: problem in activating virtual environment in Django with ". \Scripts\activate" command

2019-01-18 Thread Matthew Pava
I would switch over to pipenv and leave the details to that.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of officialjoemay...@gmail.com
Sent: Friday, January 18, 2019 8:04 AM
To: Django users
Subject: Re: problem in activating virtual environment in Django with ". 
\Scripts\activate" command

I had the same issue today, but i was able to fix it. I use windows 10 too. 
Kindly follow this guide to setup your virtualenv:

Step One: This is really important to do because i really don't know what is 
the major cause of this errors but what i discovered in my time is the 
installation right from the start of python itself needs to be properly done. 
So do this uninstall everything that has to do with python, anaconda, any 
python version you have, pycharm and all the likes, also go to your path 
variable and remove any path that show python.

Step Two: Goto https://www.python.org/downloads/ and download V3.7.2 the latest 
version currently on python official website

Step 3: After download, launch the installer ensure you select Add Python 3.6 
to PATH, secondly choose customize ensure all is selected hit next

Step 4: Ensure you select the following

  *   Install for all users
  *   Add Python to environment variables
  *   Create shortcuts for installed applications
  *   Recompile standard library or whatever this one is
Then hit install
Step 5: once installation is completed, launch your powershell or cmd as admin 
and type python -V and hit enter. It should output Python 3.7.2

Step 6: Ensure your powershell is run as admin then run this command 
Set-ExecutionPolicy Unrestricted, follow the instructions and select choose Y 
to update your powershell
Step 7: Follow this code:
cd ~/
mkdir Env
pip install virtualenv
pip freeze (to verify -- output will be virtualenv==version number)
cd ~/Env
mkdir environment
cd environment
virtualenv .
cd ~\Env\environment
.\Scripts\activate

Gotten here nice work! just try pip freeze (would not returning anything at 
this point, this confirm your virtualevn is working fine.)
Having Challenge installing django, hola me

On Thursday, January 17, 2019 at 8:18:35 PM UTC+1, Django Geek Aditya wrote:
Shell Output after entering command is
PS E:\todo> . \Scripts\activate
. : The term '\Scripts\activate' is not recognized as the name of a cmdlet, 
function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that 
the path is correct and try again.
At line:1 char:3
+ . \Scripts\activate
+   ~
+ CategoryInfo  : ObjectNotFound: (\Scripts\activate:String) [], 
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

PS E:\todo>

--
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/32c3f877-be36-4fc4-8915-18a727803326%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/d0fcde0c2b584c5190e30d00e15aa61d%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Overriding Save in Model

2019-01-16 Thread Matthew Pava
You’re converting an object (ExtractResult) into a list.  That’s just weird.

ext = tldextract.extract(domain)
self.sub_domain = ext.subdomain
self.domain = ext.domain
self.suffix = ext.suffix

Saying that, I would rather use the built-in, Pythonic way of parsing URLs.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of caleor...@gmail.com
Sent: Wednesday, January 16, 2019 11:07 AM
To: Django users
Subject: Re: Overriding Save in Model

thanks,  i've got tldextract which is sufficient for splitting the domain up

the problem is I cannot save the individual parts and only end up saving the 
domain name

On Wednesday, 16 January 2019 16:55:42 UTC, Matthew Pava wrote:
Check out urllib.parse.
https://docs.python.org/3/library/urllib.parse.html


From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of 
cale...@gmail.com
Sent: Wednesday, January 16, 2019 10:41 AM
To: Django users
Subject: Overriding Save in Model

I'm trying to extract an entered domain name and split it up so that i can 
store unique domains in a specific table
The flow
user will enter website address > model takes website address > splits it into 
sub_domain, domain and suffix and stores the values in the appropriate split 
fields

so far my extraction works, i can get the values into a list and assign the 
values to the appropriate variables, using the shell i'm adding new sites but 
and the domain is going into the domain_name field but i am not getting the 
data split

I'm only two weeks into learning python and Django and i love it but this has 
stopped me in my tracks for now, any help appreciated


class Website(models.Model):
name = models.CharField(max_length=100, default=' ')
description = models.TextField(max_length=2000, blank=True)
domain_name = models.URLField(unique=True)
sub_domain =models.CharField(max_length=56, blank=True, default='')
suffix = models.CharField(max_length=56, blank=True, default='')
is_secure = models.BooleanField(null=True)
logo = models.CharField(max_length=256, default="placeholder.png")
type = models.CharField(choices=WEBSITE_TYPES, default='O', max_length=15)

def __str__(self):
return self.name


def validate_and_split_domain(self):
domain = self.domain_name.lower() # make all lower case because django 
isn't case sensitive
values = list(tldextract.extract(domain))
self.sub_domain, self.domain_name, self.suffix = values[0], values[1], 
values[2]

def save(self, *args, **kwargs):
Website.validate_and_split_domain()
super(Website, self).save(*args, **kwargs)
--
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 djang...@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/94d5ffbb-8975-471a-b9bb-30870e893ee8%40googlegroups.com<https://groups.google.com/d/msgid/django-users/94d5ffbb-8975-471a-b9bb-30870e893ee8%40googlegroups.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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/b15fe16b-4eef-4514-a51c-5442a9aca028%40googlegroups.com<https://groups.google.com/d/msgid/django-users/b15fe16b-4eef-4514-a51c-5442a9aca028%40googlegroups.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 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/2c1b91dafe534b1e8ec07b90b4ec92bf%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Overriding Save in Model

2019-01-16 Thread Matthew Pava
Check out urllib.parse.
https://docs.python.org/3/library/urllib.parse.html


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of caleor...@gmail.com
Sent: Wednesday, January 16, 2019 10:41 AM
To: Django users
Subject: Overriding Save in Model

I'm trying to extract an entered domain name and split it up so that i can 
store unique domains in a specific table
The flow
user will enter website address > model takes website address > splits it into 
sub_domain, domain and suffix and stores the values in the appropriate split 
fields

so far my extraction works, i can get the values into a list and assign the 
values to the appropriate variables, using the shell i'm adding new sites but 
and the domain is going into the domain_name field but i am not getting the 
data split

I'm only two weeks into learning python and Django and i love it but this has 
stopped me in my tracks for now, any help appreciated


class Website(models.Model):
name = models.CharField(max_length=100, default=' ')
description = models.TextField(max_length=2000, blank=True)
domain_name = models.URLField(unique=True)
sub_domain =models.CharField(max_length=56, blank=True, default='')
suffix = models.CharField(max_length=56, blank=True, default='')
is_secure = models.BooleanField(null=True)
logo = models.CharField(max_length=256, default="placeholder.png")
type = models.CharField(choices=WEBSITE_TYPES, default='O', max_length=15)

def __str__(self):
return self.name


def validate_and_split_domain(self):
domain = self.domain_name.lower() # make all lower case because django 
isn't case sensitive
values = list(tldextract.extract(domain))
self.sub_domain, self.domain_name, self.suffix = values[0], values[1], 
values[2]

def save(self, *args, **kwargs):
Website.validate_and_split_domain()
super(Website, self).save(*args, **kwargs)
--
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/94d5ffbb-8975-471a-b9bb-30870e893ee8%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/9847dabf01254e1191742f46df6a088a%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: function get_form_kwargs() not being called

2018-12-12 Thread Matthew Pava
Fascinating.  It looks normal, though login_url is not a member of CreateView.
Do you perhaps have another class defined with the same name?
Especially since you do have other class-based views, you must know what you’re 
doing.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Simon A
Sent: Tuesday, December 11, 2018 10:32 PM
To: Django users
Subject: Re: function get_form_kwargs() not being called

I identified that a more efficient way of doing this would be to call the get 
initial method but for some reason it doesn't seem to trigger the function that 
I'm trying to overriede.

class NoteCreate(CreateView):
login_url = 'login'
model = Note
form_class = NoteForm
success_url = reverse_lazy('file_status:list')

def get_initial(self):
print(self.kwargs['file_id'])
print('in get initial')
initial = super(NoteCreate, self).get_initial()
initial['file'] = 2
return initial

Please help me understand. this is really getting frustrating:(

For this one, the text in get initial does not get printed.

What works though is when I don't use Class based view. But I still would like 
to make it work using class based views since my other views are class based.

On Monday, December 10, 2018 at 8:47:28 PM UTC+8, Simon A wrote:

I'm trying to pass a parameter from a redirect to the CreateView and to the 
form.

I have no problem retrieving the value from the redirect to the CreateView.

But my issue is when trying get the value to the form. I'm overriding 
get_form_kwargs function of my CreateView but when I try to do operations from 
that function, I'm not able to get any result. I tried to do a print but the 
print won't display anything.



class NoteCreate(LoginRequiredMixin, CreateView):

login_url = 'login'

model = Note

form_class = NoteForm

success_url = reverse_lazy('note:list')



def get_form_kwargs(self):

kwargs = super(NoteCreate, self).get_form_kwargs()

kwargs.update({'file_id' : self.kwargs['file_id']})

print("im alivveeeEe!")

return kwargs

the print statement doesn't seem to be working. It does not show anything in 
the console.

I'm able to render the form with no errors in the console.
--
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/ddf41020-5e47-4b82-b766-04df52522152%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/a12c788553a5471b9d33a5806a79f603%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Cannot get this ModelForm view to save to the db, what am I doing wrong please

2018-12-10 Thread Matthew Pava
It’s hard to tell with some of the spacing in your email.  Python cares deeply 
about spacing.

When initializing a form, I typically do it as so:
form = RegisterForm(request.POST or None)

Also, the save method on the model has several arguments that you are not 
passing around.

def save(self, *args, **kwargs):

self.postcode = self.postcode.upper()
super(Customer, self).save(*args, **kwargs)

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of MikeKJ
Sent: Monday, December 10, 2018 10:41 AM
To: Django users
Subject: Cannot get this ModelForm view to save to the db, what am I doing 
wrong please


Cannot seem to get .save() to write to the db

This is the model



class Customer(models.Model):

email = models.EmailField()

postcode = models.CharField(max_length=10)

def __unicode__(self):

return self.email

def save(self):

self.postcode=upper(self.postcode)

super(Customer, self).save()


This is the view:

class RegisterForm(ModelForm):

class Meta:

model = Customer



def register(request):

form = RegisterForm(request.POST)

if form.is_valid():

email = form.cleaned_data['email']

postcode = form.cleaned_data['postcode']

postcode = upper(postcode)

try:

user = 
Customer.objects.all().filter(email=email).filter(postcode=postcode)[:1]

if user:

error = "You have already registered this email address and 
postcode, please login."

return render_to_response("customer/register_form.html", 
{'error': error, 'form': form, 'content': 
content,},context_instance=RequestContext(request))

except Customer.DoesNotExist:

cust_obj = Customer(email=email, postcode=postcode)

cust_obj.save()

return HttpResponseRedirect('/registration-thankyou/')

Also tried

new_user = form.save(commit=False)

new_user.save()

It isn't throwing any errors just not saving to the table

Cheers for any insight/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/b55ba86d-65dd-4c33-9144-4b9a5cf15bcc%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/48cdf86ecf1240a99d940d4295ba0d34%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Poor Performance for Form Rendering In Django 1.11

2018-12-10 Thread Matthew Pava
I vaguely remember having this issue when I moved to Django 1.11.  It was 
frustrating.  I have thus far refused to move over to Jinja, and I just use 
autocompletes for my large select widgets.

There is also the possibility of using template fragment caching.  Wrap the 
select in a cache block, and it will loaded into memory once.  See 
https://docs.djangoproject.com/en/1.11/topics/cache/#template-fragment-caching.





From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of John
Sent: Monday, December 10, 2018 9:19 AM
To: Django users
Subject: Re: Poor Performance for Form Rendering In Django 1.11

Yes, the form has about a dozen selects, with two in particular being larger - 
the country and the currency fields - that probably have a couple hundred 
options each.  I have since removed those two fields which leaves about 10 
selects with about 80 options total.  While these numbers fluctuate, the 12 
field form was taking a little over 750ms, and the new form with 10 fields 
totals 375ms. So the two larger fields accounted for about half the time, but 
even the reduced form is still a major problem.

Regarding the reduced version, I cannot say how much the performance issue 
relates to having 10 selects, or to have 80 options. But it seems like 375ms is 
an unreasonable amount of time for this amount of work.  (Just as it seems 
unreasonable to spend 400ms drawing those other two fields).

You can see the form by visiting the site and 
clicking on "options" next to the search bar.

I'm sorry and didn't mean to sound combative, was trying to point out that if 
this is the performance we expect for the default renderer, then I would have 
expected to see a lot more people reacting to 1.11.  Which is why I believe 
something else must be going on.





[Screen Shot 2018-12-10 at 8.59.32 AM.png]




On Monday, December 10, 2018 at 8:40:51 AM UTC-6, James Bennett wrote:
On Mon, Dec 10, 2018 at 6:29 AM John Lehmann > 
wrote:
So my takeaway from what you are saying is that no one is running a production 
site with a Django select field to render a country or currency option (e.g., 
django-countries or django-money), because either of these would have well over 
a hundred entries (and my form happens to have both).  Instead they would be 
loading these options via AJAX or using a different widget all together like an 
auto-complete.  (I get it that a long list is not the best UX but that's a bit 
of a different discussion).

Have you profiled a country select on its own?

Your original post suggested you had multiple large (hundreds of options) 
selects in a single form that you were rendering. Whether any specific 
individual select in the form is the sole culprit, or whether it's the 
combination of them, is something you still haven't pinned down, and it's a bit 
combative to jump to "nobody must have a country select" from that.

In general, a select with a large set of options is going to be slower to 
render. It may turn out that this has nothing whatsoever to do with your 
problem, but we don't have enough information to precisely diagnose your 
problem; all we can do here is give you general advice like "avoid rendering a 
template hundreds of times if you can, or use a faster-rendering template 
option if you can't".
--
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/7e723ec8-be37-49cf-969e-5b484e3e5b65%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/23ed36f946a143f7bffa7128832d9686%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: django-EmailSending with PHP

2018-12-06 Thread Matthew Pava
Here, take a look at this:
https://www.webforefront.com/django/setupdjangoemail.html


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Andréas Kühne
Sent: Thursday, December 6, 2018 2:25 PM
To: django-users@googlegroups.com
Subject: Re: django-EmailSending with PHP

Well

The thing is you will still need to pay for sending emails. Regardless of how 
you want to send your email, you will need to pay for it somehow.

Regards,

Andréas


Den tors 6 dec. 2018 kl 13:20 skrev Nagarjuna J 
mailto:nagarjun...@enthsquare.com>>:
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 
mailto:andreas.ku...@hypercode.se>> 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 
mailto:nagarjun...@enthsquare.com>>:
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.
--
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/CAK4qSCcs%3DOOvZk-mP4Mam%2B9F79orO%2B7HQEZ_6BgKjwp4kDGYEA%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 

RE: Use an aggregation function's filter with aggregate of a value from an annotation with a subquery

2018-12-05 Thread Matthew Pava
Though I can’t address the issue of whether it is a bug, there is a note in the 
documentation:

https://docs.djangoproject.com/en/2.1/topics/db/aggregation/#filtering-on-annotations
“Avoid using the filter argument…”

You may want to consider conditional expressions (Case … When) to achieve your 
goal.
https://docs.djangoproject.com/en/2.1/ref/models/conditional-expressions/




From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Daniel Gilge
Sent: Wednesday, December 5, 2018 6:17 PM
To: Django users
Subject: Use an aggregation function's filter with aggregate of a value from an 
annotation with a subquery

Hi,

I think I've found a bug. But I'm not sure and I never opened a ticket for 
Django before. So, I first wanted to ask here.

I'm using Django 2.0 and this doesn't work:

subquery = Subquery(
Vote.objects
.filter(comment=OuterRef('pk'))
.values('value')[:1]
)

Comment.objects.annotate(vote=subquery).aggregate(
count=Count('vote', filter=Q(vote__gte=4)),
)

It results in a quite useless AssertionError:


django/db/models/expressions.py


168

169 def set_source_expressions(self, exprs):

--> 170 assert len(exprs) == 0

171

172 def _parse_expressions(self, *expressions):



AssertionError:


Vars:
exprs


[Ref(__col8, Col(U0, myapp.Vote.comment))]

self






It probably doesn't make sense because I simplified it. Why I'm using 
subqueries is that I have several sums involved in the query:

subquery = Subquery(
Vote.objects
.filter(comment=OuterRef('pk'))
.values('comment_id')
.annotate(sum=Sum('value', filter=Q(**filter_fields)))
.values('sum')[:1]
)

However, what I had to remove is a filter statement and then it works:

Comment.objects.annotate(vote=subquery).aggregate(
count=Count('vote'),
)

Any advice 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 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/d405cbf2-0a57-4639-aac1-4376a09099b8%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/085f36ad5090413192ff37392f5ea536%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Best way to structure this Django project

2018-12-03 Thread Matthew Pava
I don't think there's a way around it, but that's okay.  I have dependencies 
between several apps in my project, and the apps help organize the project.
If you don't want to necessarily hard-code the app model, you could pass in the 
model as an argument and use apps.get_model(app_name, model_name) inside the 
function.

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Simon Connah
Sent: Sunday, December 2, 2018 5:31 PM
To: django-users@googlegroups.com
Subject: Best way to structure this Django project

Hi,

I have a bit of a problem with structuring a Django project. I have a 
UserProfile app which stores extra information about users using a 
OneToOneField to the Django auth user model.

I have a products app which has two models relating to two types of 
products and finally I have a payments app which contains all the code 
needed to integrate with the Stripe payment processor.

My problem is fairly simple. When someone buys a product I obviously 
want to take them to a payment page but if I carry on with my current 
structure that would require redirecting to a view in the payments app 
as it will contain code to work with the Stripe API but it would also 
require access to the product model(s) which would hard code a 
dependency between the payments app and the products app.

Is there anyway I can rearrange my project so I can avoid this hard 
coded dependency?

-- 
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/12030aa1-69ad-dc7f-c3be-72e8e2f9b50e%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

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


RE: Microsoft deprecation for the Python extensions

2018-11-30 Thread Matthew Pava
I could never get Django working with IIS myself, so I simply installed Apache 
on Windows.  I haven’t had much of a problem since.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of El_Merendero
Sent: Friday, November 30, 2018 3:56 AM
To: Django users
Subject: Microsoft deprecation for the Python extensions

Hi all,
I'm a young developer and I'm working on a Django application (wrote in Python 
2.7) that need to be deployed in a IIS 10 web server (I tryed a first version 
of the app and it works great). Today I read this 
post
 and I realized that Microsoft Server will not support the Python extension. 
So, now I have to decide whether to migrate in a Linux Server or not but before 
I want to understand what really does it involve to me? I'll explain:

  *   It means that future ISS versions (10+) may not have a Python support?
  *   It means that in the future I can have security issues due the absence of 
the IIS updates for python compability?
  *   It means that in the future I can't make a python version upgrade of the 
app?
Or simply it means that we can not foresee what this can entail?

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/c59000ca-6cd0-4583-ae11-ef5b9963a2ee%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/1dd3f41275d043bda8e284694066%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Unexpected behavior on delete of model

2018-11-27 Thread Matthew Pava
You’ll want to review this reference:
https://docs.djangoproject.com/en/2.1/ref/models/fields/#django.db.models.ForeignKey.on_delete

You probably want the option on doc to be SET_NULL.

Actually, I suggest some overall cleanup.
Your model names should follow a standard convention.  Django practices the 
camel case convention.  (CamelCase)
Also, you have a ForeignKey where you probably just want a OneToOneField.
Use related_name to have a reverse relationship.  In my proposal below, you can 
access the profile picture just like you could before.
I would have just let Django handle the primary key field without changing the 
name of it.

doctor.profile_pic

class Doctor(models.Model):
name = models.CharField(max_length=35)
username = models.CharField(max_length=15)

class DoctorProfilePic (models.Model):
name = models.CharField(max_length=255, blank=True)
pic = StdImageField(upload_to="data/media/%Y/%m/%d", blank=True, 
variations={
'large': (600, 400),
'thumbnail': (150, 140, True),
'medium': (300, 200),
})
doctor = models.OneToOneField(Doctor, blank=True,
null=True, on_delete=models.SET_NULL, 
related_name="profile_pic")


…and after saying all that, I wouldn’t make a separate model for the profile 
picture.  This is what I would do:
class Doctor(models.Model):
name = models.CharField(max_length=35)
username = models.CharField(max_length=15)
profile_pic = StdImageField(upload_to="data/media/%Y/%m/%d", 
blank=True, variations={
'large': (600, 400),
'thumbnail': (150, 140, True),
'medium': (300, 200),
})



From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel Mathew
Sent: Tuesday, November 27, 2018 12:24 PM
To: django-users@googlegroups.com
Subject: Unexpected behavior on delete of model

Situation:

I have two Model classes, in two different apps which are part of the same 
project. class doctor defined in appointments.models is a set of attributes 
associated with a doctor, like name, username, email, phone etc. class 
DoctorProfilePic is a Model defined in clinic.models, which has a StdImageField 
which stores images. doctor has a One to One mapping to DoctorProfilePic.

class doctor(models.Model):
docid = models.AutoField(primary_key=True, unique=True) # Need 
autoincrement, unique and primary
name = models.CharField(max_length=35)
username = models.CharField(max_length=15)
...
profilepic = models.ForeignKey(DoctorProfilePic, blank=True, null=True, 
on_delete=models.CASCADE)
...

class DoctorProfilePic (models.Model):
id = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=255, blank=True)
pic = StdImageField(upload_to="data/media/%Y/%m/%d", blank=True, 
variations={
'large': (600, 400),
'thumbnail': (150, 140, True),
'medium': (300, 200),
})
doc = models.ForeignKey('appointments.doctor', blank=True,
null=True, on_delete=models.CASCADE)

Anticipated response:

When user selects one of the profile pics from a selection box, and clicks 
Delete, django is supposed to delete the picture from the collection of 
pictures uploaded by the doctor.

Problem:

When the delete button is clicked, django deletes both the picture and the 
doctor, instead of just the former.

Code:

def removeprofpic(request, docid):
docid = int(docid)
if not IsOwnerorSuperUser(request, docid):
return HttpResponse("You dont have permissions to do this.")
doc = doctor.objects.get(docid = docid)
if request.method == 'POST':
print(request.POST)
picid = int(request.POST.get('profilepic'))
print(f'doc:{doc} picid:{picid}')
pic = DoctorProfilePic.objects.get(doc = doc, id =picid)
pic.delete()
msg = f"Successfully removed profile picture."
else:
msg = "Not a valid POST"
return HttpResponse(msg)

Now I'm guessing my problem is in defining the on_delete=models.CASCADE? Can 
someone explain what I've done wrong?
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 

RE: get_or_delete leading to duplicate creation

2018-11-27 Thread Matthew Pava
Avoid using the created_at time in your get_or_create call.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Ankit Khandewal
Sent: Tuesday, November 27, 2018 2:01 AM
To: Django users
Subject: get_or_delete leading to duplicate creation

Hello,

I am using get_or_create method in my project and this is leading to creating 
duplicate for objects, there created_at time difference is in milliseconds, 
please report this issue to fix.
--
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/4c8f9ca3-1379-49de-b37e-1978fc83444b%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/769c6e8ad3e74b6e96238ce7f1dd7b3d%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Human Readable Values

2018-11-27 Thread Matthew Pava
Override the __str__ method.
https://docs.djangoproject.com/en/2.1/ref/models/instances/#str


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mike Sacauskis
Sent: Monday, November 26, 2018 5:36 PM
To: Django users
Subject: Human Readable Values


[Screenshot.png]
Hi

I'm new to DJango and have a question about how to display some model data in a 
human readable form.  I have three fields, one is an IP Address 
 and two are 
.  When I render the template I get the 
class name but no values.  How do I render the values?

Thanks

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/msgid/django-users/e3067097-f156-43a9-9821-abda50b08b72%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/2af8a2d80d574969b615aae746216c30%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: UpdateView: input always rejected

2018-11-20 Thread Matthew Pava
You are not referencing the form in the template that is generated by the 
UpdateView.
Check out 
https://ccbv.co.uk/projects/Django/2.0/django.views.generic.edit/UpdateView/.
If you want to have two forms in a view, that’s fine, but you’ll need to 
manually add the second form in the get_context_data method, and you’ll have to 
generate your own class for it.

In your template, you’ll need to access the form context variable.
Maybe start out with {{ form.as_p }} to see what is generated, and if you 
really want to get crazy, you can use Django Crispy Forms.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of clavierpla...@gmail.com
Sent: Tuesday, November 20, 2018 8:55 AM
To: Django users
Subject: UpdateView: input always rejected

I need to render some form fields by hand in order to meet style requirements. 
I am using UpdateView instead of a ModelForm since I just need a couple of 
foreign key fields that are already defined on the model, and I am using html 
 elements to prevent invalid data from being entered.

I'm running into trouble because when I choose an option and click the submit 
button, Django rejects the input and raises a validation error because the 
field is required. I know the data should be valid because it all came straight 
from the database, but Django appears to be throwing it away. I can't find 
UpdateView's clean() methods to try to catch the error that way. I've tried 
overriding post() just to see where the problem is occurring, but the option I 
chose seemed to just disappear; I don't know what Django is doing with it or 
why it thinks its invalid, so I don't know where to try to catch and fix the 
problem.

I have two separate html forms with two submit buttons; I separated them 
because they seemed easier to style that way, and also because users will 
generally need to change one or the other, not both; but two forms might be the 
wrong way to go about it. But that doesn't explain why data that came straight 
from the database is invalid. They both fail with the same ValidationErrors 
(i.e. fields are required).

Thank you for any ideas or insight!
Heather



class Order(models.Model):

order_id = models.IntegerField(primary_key=True)

# (Some additional model fields.)

service_level = models.ForeignKey('manifest.ServiceLevel', 
on_delete=models.PROTECT)
priority = models.ForeignKey('fulfillment.Priority', 
on_delete=models.PROTECT)





class Priority(models.Model):
"""fulfillment priority levels"""
TYPES = Choices(
('FR', 'FLASH_RUSH', 'Flash Rush'),
('RU', 'RUSH', 'Rush'),
('RG', 'REGULAR', 'Regular'),
)

code = models.CharField(max_length=2, choices=TYPES)
name = models.CharField(max_length=50)





class ServiceLevel(models.Model):
"""levels of service which a carrier provides"""

code = models.CharField(max_length=10, primary_key=True)
name = models.CharField(max_length=50)

# (Some additional model fields.)





class WMSOrderUpdateView(UpdateView):
context_object_name = 'order'
template_name = 'fulfillment/order_detail.html'
fields = ['priority', 'service_level']

def get_context_data(self, **kwargs):
context = super().get_context_data()
context['priorities'] = Priority.objects.all()
context['ship_methods'] = ServiceLevel.objects.all()
return context








{% csrf_token %}

{% if order.priority.code == 'FR' %}

{% elif order.priority.code == 'RU' %}

{% else %}

Priority:
{% endif %}



{% for priority in priorities %}
{{ priority.name }}
{% endfor %}







{% csrf_token %}
Shipping Method: 

{% for method in ship_methods %}
{{ method.name|title }}
{% endfor %}







--
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/26b1dcbd-54c7-431c-bd0e-5740ba470aa3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received 

Error Email Template

2018-11-19 Thread Matthew Pava
Hi Django users,
I would like to change the color scheme of the error trace back in Django, even 
if it's emailed to me.  Is there an easy way to do 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 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/b5f7f064bdfe4668b1a16cbbd94128ab%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Fascinating Problem

2018-11-19 Thread Matthew Pava
I have resolved the issue.  I have a custom 500 view that just renders a 
template.  The render call never specified that status code.  Amazingly, it 
worked in the past.  I have specified the status code in the function, and now 
the emails are coming through.

So previously, I had this:
def my_500(request, *args, **kwargs):
return render(request, "errors/500.html")


Now, I have this, and it works:

def my_500(request, *args, **kwargs):
return render(request, "errors/500.html", status=500)


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Matthew Pava
Sent: Monday, November 19, 2018 1:04 PM
To: django-users@googlegroups.com
Subject: RE: Fascinating Problem

Okay, I’ve managed to deduce that I’m able to get an email when Debug is True.  
When Debug is False, I do not get the email.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Ryan Nowakowski
Sent: Sunday, November 18, 2018 9:21 AM
To: django-users@googlegroups.com
Subject: Re: Fascinating Problem

Posting the view code might be helpful for folks to help you debug.
On November 16, 2018 2:52:12 PM CST, Matthew Pava  wrote:
I have come across an interesting issue with my error handling.  Whenever I go 
to a URL that throws an exception (I have one for testing) as one of the ADMINS 
when DEBUG is False, I get the 500 error, and the email from the server 
indicating it.  When a different user navigates to the URL, the development 
server returns a 200, but it renders the 500 error message page, and I get no 
email message.  I have tried restoring all email and logging settings to their 
Django defaults, but I continue to get this issue.  If you have any ideas, I’m 
quite interested.
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/44E3122D-F6A8-466F-AF50-D1386191747A%40fattuba.com<https://groups.google.com/d/msgid/django-users/44E3122D-F6A8-466F-AF50-D1386191747A%40fattuba.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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/46b1cafcc0224160b3efbde9e14f1726%40iss2.ISS.LOCAL<https://groups.google.com/d/msgid/django-users/46b1cafcc0224160b3efbde9e14f1726%40iss2.ISS.LOCAL?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 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/dfc0f32b8cfc439db462ce0677a3646f%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Fascinating Problem

2018-11-19 Thread Matthew Pava
Okay, I’ve managed to deduce that I’m able to get an email when Debug is True.  
When Debug is False, I do not get the email.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Ryan Nowakowski
Sent: Sunday, November 18, 2018 9:21 AM
To: django-users@googlegroups.com
Subject: Re: Fascinating Problem

Posting the view code might be helpful for folks to help you debug.
On November 16, 2018 2:52:12 PM CST, Matthew Pava  wrote:
I have come across an interesting issue with my error handling.  Whenever I go 
to a URL that throws an exception (I have one for testing) as one of the ADMINS 
when DEBUG is False, I get the 500 error, and the email from the server 
indicating it.  When a different user navigates to the URL, the development 
server returns a 200, but it renders the 500 error message page, and I get no 
email message.  I have tried restoring all email and logging settings to their 
Django defaults, but I continue to get this issue.  If you have any ideas, I’m 
quite interested.
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/44E3122D-F6A8-466F-AF50-D1386191747A%40fattuba.com<https://groups.google.com/d/msgid/django-users/44E3122D-F6A8-466F-AF50-D1386191747A%40fattuba.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 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/46b1cafcc0224160b3efbde9e14f1726%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Fascinating Problem

2018-11-16 Thread Matthew Pava
I have come across an interesting issue with my error handling.  Whenever I go 
to a URL that throws an exception (I have one for testing) as one of the ADMINS 
when DEBUG is False, I get the 500 error, and the email from the server 
indicating it.  When a different user navigates to the URL, the development 
server returns a 200, but it renders the 500 error message page, and I get no 
email message.  I have tried restoring all email and logging settings to their 
Django defaults, but I continue to get this issue.  If you have any ideas, I'm 
quite interested.

-- 
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/2ac5947cc43a45c3a6b71bf773fa640f%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Migrations - moving model between apps

2018-11-16 Thread Matthew Pava
Hi Simon,
Thank you so very much for your assistance.
It was a very simple model, so it had no foreign keys, and I’m relieved that I 
won’t have to do some manual database operations to get this working.
It has migrated successfully!
Thank you,
Matthew

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Simon Charette
Sent: Thursday, November 15, 2018 6:33 PM
To: Django users
Subject: Re: Migrations - moving model between apps

Hello Matthew,

I'm going to assume no foreign keys are pointing to the model "Foo" you are
trying to move from the app "old" to "new". If it's the case then simply repoint
them and run makemigrations once the following steps are completed. You
could wrap the generated AlterField in SeparateDatabaseAndState to avoid
database level foreign key constraints reconstruction if it's critical to your
application.

Start by setting old.Foo.Meta.db_table = 'new_foo' and run makemigrations old.

That should generate you a new migration with an AlterModelTable('foo', 
'new_foo') operation.

Within this migration you'll want to add a DeleteModel('foo') operation wrapped 
in a
SeparateDatabaseAndState[0] after the AlterModelTable one. Your migration's 
operations
should look like:

operations = [
AlterModelTable('foo', 'new_foo'),
SeparateDatabaseAndState([], [DeleteModel('foo')]),
]

Now, move your "old.Foo" model definition to your "new" app, remove the
new.Foo.Meta.db_table and run "makemigrations new".

Edit the created "new" migration and wrap the CreateModel into a 
SeparateDatabaseAndState
and make sure the migration depends on the "old" migration you just created. 
You migration
should look like the following:

dependencies = [
('old', '000N_old_migration_name'),
]

operations = [
SeparateDatabaseAndState([], [
CreateModel('foo, ...)
)]),
]

Note that this will not take care of renaming the content types and permissions 
that
might have been created for your old.Foo model definition. You could use a 
RunPython
operation to rename them appropriately.

Cheers,
Simon

Le jeudi 15 novembre 2018 18:09:45 UTC-5, Matthew Pava a écrit :
I’m moving a model to a different app in my project, and I want to keep the 
same data that I already have.  I created a migration with a RunSQL operation 
that simply renames the table with the new app prefix.  However, when I run 
makemigrations, Django insists on adding a migrations.CreateModel operation for 
me in the new app.  How do I avoid that?
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/20606f64-15b4-4946-bb3e-65276de63e40%40googlegroups.com<https://groups.google.com/d/msgid/django-users/20606f64-15b4-4946-bb3e-65276de63e40%40googlegroups.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 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/59362e8a8331457b85670b56eb4e2d2b%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Migrations - moving model between apps

2018-11-15 Thread Matthew Pava
I'm moving a model to a different app in my project, and I want to keep the 
same data that I already have.  I created a migration with a RunSQL operation 
that simply renames the table with the new app prefix.  However, when I run 
makemigrations, Django insists on adding a migrations.CreateModel operation for 
me in the new app.  How do I avoid that?

-- 
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/4959b2480e4044d8b48a74b22457d7a4%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Sending PDF from javascript to django

2018-11-14 Thread Matthew Pava
There is django-hardcopy.

However, I’m in process of changing my PDF generation algorithm.  I originally 
used PhantomJS with gs-print and gs-view for Windows.  Unfortunately, PhantomJS 
has been discontinued, and it wasn’t taking advantage of rendering changes to 
HTML (especially for printing or PDF generation) that had developed over the 
years, especially with Google Chrome’s Blink engine, which used to formerly be 
Webkit, the same engine that PhantomJS was using.  My current goal is to 
utilize headless Chrome with Puppeteer, which is a NodeJS package.  Since 
PhantomJS was a NodeJS package, too, it shouldn’t be to involved to get a 
script working for Puppeteer.  And then I am guaranteed to always have the 
latest version of Chrome.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel
Sent: Wednesday, November 14, 2018 8:07 AM
To: django-users@googlegroups.com
Subject: Re: Sending PDF from javascript to django

Ideally I would love to generate the pdf on the server. Hovered I am yet to 
discover an easy way to create a pdf easily with the ease of jspdf's table 
plugin.

Perhaps someone can shed light on a good python library to do this without much 
ado.

On Wed, 14 Nov, 2018, 7:12 PM Jason 
mailto:jjohns98...@gmail.com> wrote:
your original error was due to exceding django's max upload size.  check out 
https://docs.djangoproject.com/en/2.1/ref/settings/#data-upload-max-memory-size

also, you should check out https://djangopackages.org/grids/g/pdf/

What I would do is generate the pdf in the view from a rendered template and 
then send from email.  No need to generate it on the client and upload for an 
email.
--
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/506231af-2c44-4e8c-9c9d-36d8ea913b7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA%3Diw_9QAr_Y2deWgjsXmZcmM8HALA3Gg0jDz_dZVtnSt9Vtog%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/95f81d5cad9e4abb87af8d794ca745e6%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Link ID's To Detail Page

2018-11-07 Thread Matthew Pava
Oh, I see it now.
Your second URL doesn’t correspond with the object that is inside the cell.
You probably meant {% url ‘kpi_eftdetail’ incident.eft_lead.id %}

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Gregory Strydom
Sent: Wednesday, November 7, 2018 8:58 AM
To: Django users
Subject: Re: Link ID's To Detail Page

Sorry I typed it in here incorrectly. Thank you for spotting that though :) It 
is the correct way in my source file.

On Wednesday, 7 November 2018 16:55:15 UTC+2, Matthew Pava wrote:
If you just copied and pasted from your template into this email, the problem 
is a syntax error.  You did not close your URL tag with a %}.
http://incident.id> %}">{{ 
incident.ir_num }}
http://eftlead.id> %}">{{ 
incident.eft_lead}}


From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of Gregory Strydom
Sent: Wednesday, November 7, 2018 8:50 AM
To: Django users
Subject: Link ID's To Detail Page

Hi there.

I am really not sure how to phrase this questions so I will just do my best.

On the homepage of my app I have a table with information. Most of the 
information in each cell is also a link to a details page like so:

http://incident.id>">{{ 
incident.ir_num }}

What I am struggling to get working is adding another link to a different cell 
in the same table.

http://eftlead.id>">{{ 
incident.eft_lead}}

My 2 urls are set us as such:

url(r'^detail/(?P\d+)$', views.incident_detail, name='kpi_detail'),

url(r'^eftlead/(?P\d+)$', views.eftlead_detail, name='kpi_eftdetail')

My index view is like so:

def kpi_index(request):
  context = dict()
  context['incidents'] = KPIIncidents.objects.all()
  return render(request, 'kpi/index.html', context)

If I set everything up like that I am getting an error of no reverse match on 
the index page. I think  the problem I am having is  I am not setting up the 
eft_lead link properly in the index view, but I am not sure how I would go 
about this.

It is very difficult to explain without showing my whole source code I think 
but I am not sure how to do that on Google groups.

Any help would be much appreciated. 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...@googlegroups.com.
To post to this group, send email to djang...@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/6ac26c7e-be21-468c-9146-25be6b28ee57%40googlegroups.com<https://groups.google.com/d/msgid/django-users/6ac26c7e-be21-468c-9146-25be6b28ee57%40googlegroups.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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/84ef7752-b46d-4158-9128-b80fc58850e4%40googlegroups.com<https://groups.google.com/d/msgid/django-users/84ef7752-b46d-4158-9128-b80fc58850e4%40googlegroups.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 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/bd05ace6295741c39634059eb343c335%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: SyntaxError: keyword argument repeated

2018-11-07 Thread Matthew Pava
The error message says “keyword argument repeated”
Look at the keyword arguments and check for repeated ones.
I see it in the definition of parent.  Do you see it?


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Dennis Alabi
Sent: Wednesday, November 7, 2018 8:51 AM
To: Django users
Subject: SyntaxError: keyword argument repeated


django.setup()
  File 
"C:\Users\User\Anaconda3\envs\myprogv\lib\site-packages\django\__init__.py", 
line 24, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"C:\Users\User\Anaconda3\envs\myprogv\lib\site-packages\django\apps\registry.py",
 line 112, in populate
app_config.import_models()
  File 
"C:\Users\User\Anaconda3\envs\myprogv\lib\site-packages\django\apps\config.py", 
line 198, in import_models
self.models_module = import_module(models_module_name)
  File "C:\Users\User\Anaconda3\envs\myprogv\lib\importlib\__init__.py", line 
126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 994, in _gcd_import
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 665, in _load_unlocked
  File "", line 674, in exec_module
  File "", line 781, in get_code
  File "", line 741, in source_to_code
  File "", line 219, in _call_with_frames_removed
  File 
"C:\Users\User\Documents\cctv_project\openCV\cam_project\customers\models.py", 
line 85
on_delete=models.CASCADE,related_name="'zone's", null=True, 
related_name='children'
   ^
SyntaxError: keyword argument repeated


I get the above error and the potion of my code causing it in models.py is 
given below, please help out

# Relationship Fields
user = ForeignKey(
'customers.User',
on_delete=models.CASCADE, related_name="users"
)
parent = ForeignKey(
'customers.Zone',
on_delete=models.CASCADE, related_name="'zone's", null=True, 
related_name='children'
)

--
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/277c4a05-6744-4d77-b571-db4e5a42386d%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/624423a6bae949b5966429bb426a3426%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Link ID's To Detail Page

2018-11-07 Thread Matthew Pava
If you just copied and pasted from your template into this email, the problem 
is a syntax error.  You did not close your URL tag with a %}.
{{ incident.ir_num }}
{{ 
incident.eft_lead}}


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Gregory Strydom
Sent: Wednesday, November 7, 2018 8:50 AM
To: Django users
Subject: Link ID's To Detail Page

Hi there.

I am really not sure how to phrase this questions so I will just do my best.

On the homepage of my app I have a table with information. Most of the 
information in each cell is also a link to a details page like so:

{{ incident.ir_num }}

What I am struggling to get working is adding another link to a different cell 
in the same table.

{{ incident.eft_lead}}

My 2 urls are set us as such:

url(r'^detail/(?P\d+)$', views.incident_detail, name='kpi_detail'),

url(r'^eftlead/(?P\d+)$', views.eftlead_detail, name='kpi_eftdetail')

My index view is like so:

def kpi_index(request):
  context = dict()
  context['incidents'] = KPIIncidents.objects.all()
  return render(request, 'kpi/index.html', context)

If I set everything up like that I am getting an error of no reverse match on 
the index page. I think  the problem I am having is  I am not setting up the 
eft_lead link properly in the index view, but I am not sure how I would go 
about this.

It is very difficult to explain without showing my whole source code I think 
but I am not sure how to do that on Google groups.

Any help would be much appreciated. 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/6ac26c7e-be21-468c-9146-25be6b28ee57%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/66b71828e2564644a38327d875693e43%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Setting up admin in visual studio

2018-11-06 Thread Matthew Pava
PyCharm

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Saeed Pooladzadeh
Sent: Tuesday, November 6, 2018 3:31 PM
To: Django users
Subject: Re: Setting up admin in visual studio

There are some tools for visual studio which can make it a python IDE.
.I want just want to make the admin.py to work.
What are other IDE's for Django?

در سه‌شنبه 6 نوامبر 2018، ساعت 6:03:32 (UTC-8)، Jason نوشته:
visual studio, the .net/C# IDE, is not for python (at least none of the 
versions I've used)

So not sure how to help you other than suggest another IDE
--
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/bd5ffb6d-18b0-43fc-ac59-b25dca55c097%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/6af5e6672bfe4b97960d2d21ed590d8a%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Turning DEBUG=True causes a tornado of Error 500s

2018-11-02 Thread Matthew Pava
Did you run collectstatic?


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel Mathew
Sent: Friday, November 2, 2018 2:19 PM
To: django-users@googlegroups.com
Subject: Turning DEBUG=True causes a tornado of Error 500s

When I turned DEBUG = False in my project/settings.py, I suddenly got
a whole bunch of HTTP Error 500. Most of the css reources showed the
error. I have two apps in this project, and I've been sharing static
resources between these apps. Would these be the cause of these
errors?

See the following with DEBUG=True:

joel@hp:~/myappointments$ python3 manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
November 03, 2018 - 00:46:23
Django version 2.1.2, using settings 'myappointments.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
In livelist for clinic: joelent
Checking for membership
In HasMembership function.
In IsMemberof function.. Got arguments: cliniclabel:joelent username:joel
permobj.viewperms: 1
Verified that ... is a member of joelent
Username is ...
Showhelp for Joel G Mathew  is False
[03/Nov/2018 00:46:27] "GET /clinic/joelent/live HTTP/1.1" 200 19802
[03/Nov/2018 00:46:27] "GET
/appointments/static/appointments/css/calcustomcolors.css?dev=82444302
HTTP/1.1" 200 246
[03/Nov/2018 00:46:27] "GET
/appointments/static/appointments/css/mytheme.css?dev=82444302
HTTP/1.1" 200 884
[03/Nov/2018 00:46:27] "GET
/appointments/static/clinic/css/colorbuttons.css?dev=82444302
HTTP/1.1" 200 3596
[03/Nov/2018 00:46:27] "GET
/appointments/static/appointments/js/search.js?dev=82444302 HTTP/1.1"
200 6554
[03/Nov/2018 00:46:27] "GET
/appointments/static/appointments/js/jquery-ui/jquery-ui.js?dev=82444302
HTTP/1.1" 200 520714
[03/Nov/2018 00:46:27] "GET
/appointments/static/appointments/js/appointment.js?dev=82444302
HTTP/1.1" 200 17716
[03/Nov/2018 00:46:27] "GET
/appointments/static/clinic/icons/favicon.ico HTTP/1.1" 200 311737




And now with DEBUG = False:

python3 manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
November 03, 2018 - 00:47:39
Django version 2.1.2, using settings 'myappointments.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
In livelist for clinic: joelent
Checking for membership
In HasMembership function.
In IsMemberof function.. Got arguments: cliniclabel:joelent username:joel
permobj.viewperms: 1
Verified that ... is a member of joelent
Username is 
Showhelp for Joel G Mathew  is False
[03/Nov/2018 00:47:44] "GET /clinic/joelent/live HTTP/1.1" 200 19802
2018-11-03 00:47:44,523 django.request ERRORInternal Server Error:
/appointments/static/clinic/css/colorbuttons.css
2018-11-03 00:47:44,525 django.request ERRORInternal Server Error:
/appointments/static/appointments/css/calcustomcolors.css
2018-11-03 00:47:44,532 django.request ERRORInternal Server Error:
/appointments/static/appointments/css/mytheme.css
2018-11-03 00:47:44,562 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/jquery-ui/jquery-ui.js
2018-11-03 00:47:44,567 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/search.js
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/css/mytheme.css?dev=82846267
HTTP/1.1" 500 27
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/css/calcustomcolors.css?dev=82846267
HTTP/1.1" 500 27
[03/Nov/2018 00:47:44] "GET
/appointments/static/clinic/css/colorbuttons.css?dev=82846267
HTTP/1.1" 500 27
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/search.js?dev=82846267 HTTP/1.1"
500 27
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/jquery-ui/jquery-ui.js?dev=82846267
HTTP/1.1" 500 27
2018-11-03 00:47:44,632 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/appointment.js
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/appointment.js?dev=82846267
HTTP/1.1" 500 27
2018-11-03 00:47:44,697 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/jquery-ui/jquery-ui.js
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/jquery-ui/jquery-ui.js?dev=82846267
HTTP/1.1" 500 27
2018-11-03 00:47:44,849 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/search.js
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/search.js?dev=82846267 HTTP/1.1"
500 27
2018-11-03 00:47:44,875 django.request ERRORInternal Server Error:
/appointments/static/appointments/js/appointment.js
[03/Nov/2018 00:47:44] "GET
/appointments/static/appointments/js/appointment.js?dev=82846267
HTTP/1.1" 500 27
2018-11-03 00:47:45,152 django.request ERRORInternal Server Error:

RE: Handling Database Tables without a unique column

2018-10-29 Thread Matthew Pava
I certainly do hope that it’s filled with more than just junk.  If it truly is 
just junk, scrap it, and create something else.
If you are adding a column named “id”, I don’t think there is a need to set 
managed to False or really do much of anything else with your model.  You could 
rename the columns and tables to match Django conventions.

Something I do with actual “managed = False” models is use a row number window 
statement to calculate the “id” field in the database view rather than use 
concatenation.  But your way may be faster.

Even so, both solutions are handled at the database level, so I’m not sure what 
changes you are asking about on the manager methods.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Dan Davis
Sent: Monday, October 29, 2018 2:14 PM
To: Django users
Subject: Handling Database Tables without a unique column

I am currently leading a team handling a 16 year old database filled with junk. 
 I think it has existed since its HTML application was served by Oracle forms.
We are in production with Django, and turning off the more recent ColdFusion 
version this Thursday.

However, some of our ways of working reflect the deep SQL roots of the team.   
For some tables, we have multi-column unique keys.

At the time I wrote these things, these seemed the best practices:
* For read-only tables, manufacture a unique column through concatenation in a 
corresponding database view.   Base the Django model on the database view.
* For read-write tables, do the work of adding a new unique ID column, but keep 
the table as managed = False.


Now that I am better at thinking in querysets, and can regularly use 
annotations, including F, Subquery and OuterRef expressions, I wonder whether 
there is a better way.   Has anyone ever tried doing this by adding to the SQL 
expressions code to manufacture a unique column in a QuerySet subclass or in 
the ModelManager?


--
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/e5eedb52-0add-4f3c-902b-4e6e9bfe3d05%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/64a3b97a215b4a91bd535ad2b10c047b%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Identify failed insert field

2018-10-29 Thread Matthew Pava
I usually get this error when I assign an object to a field rather than its pk.
So this is probably where your problem is:
clinicid=clinicobj.pk

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel Mathew
Sent: Saturday, October 27, 2018 10:04 PM
To: django-users@googlegroups.com
Subject: Identify failed insert field

Is there anyway to identify which database field update failed,
instead of a generic message like "ValueError: invalid literal for
int() with base 10: ''?

For example, I have the following save():

tempcust = unconfirmedappointment(name=name, ageyrs=ageyrs,
agemnths=agemnths, gender=gender, mobile=phone,
docid=doc,clinicid=clinicobj, seldate=seldate, seltime=slot,
email=email, address=address, city=city, uniquestring=uniquestring,
otp=otp)
tempcust.save()

Apparently one of the values is wrong for the field. But all I get is
the following:

2018-10-28 08:29:48,842 django.request ERRORInternal Server Error:
/clinic/madhav/doctor/4/setappointment
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/myappointments/clinic/views.py", line 896, in setappointment
tempcust.save()
  File "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
line 718, in save
force_update=force_update, update_fields=update_fields)
  File "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
line 748, in save_base
updated = self._save_table(raw, cls, force_insert, force_update,
using, update_fields)
  File "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
line 831, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/home/joel/.local/lib/python3.6/site-packages/django/db/models/base.py",
line 869, in _do_insert
using=using, raw=raw)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/manager.py",
line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/query.py",
line 1136, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
line 1288, in execute_sql
for sql, params in self.as_sql():
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
line 1241, in as_sql
for obj in self.query.objs
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
line 1241, in 
for obj in self.query.objs
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
line 1240, in 
[self.prepare_value(field, self.pre_save_val(field, obj)) for
field in fields]
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
line 1182, in prepare_value
value = field.get_db_prep_save(value, connection=self.connection)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
line 790, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, prepared=False)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
line 785, in get_db_prep_value
value = self.get_prep_value(value)
  File 
"/home/joel/.local/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
line 1807, in get_prep_value
return int(value)
ValueError: invalid literal for int() with base 10: ''

How to trace which field is problematic, other than manually debugging
each variable and seeing if it is non integer? Can django tell me
which field is causing the  issue?

Sincerely yours,

Dr 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_-5bzYQfCw2BY38rDSS4aFkR48YC-zMDCWbiTDorRs%3DgQ%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 

RE: Django auto-deletes field related to MySQL Transactions

2018-10-24 Thread Matthew Pava
In that case, is there something in a template that is possibly calling the 
delete view based on some user trigger, i.e. some Javascript function?

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of RyanW
Sent: Wednesday, October 24, 2018 10:11 AM
To: Django users
Subject: Re: Django auto-deletes field related to MySQL Transactions

I've tried two separate MySQL db's on two separate servers.  They both have 
given me deletes.  What's strange is that I've set up a local copy on my laptop 
with both a local Postgres DB and MySQL connection, and I don't get the same 
deletes.

I've narrowed it down that it must be something the users are doing to trigger 
these deletes, based on logs that would've put them active during a time of a 
delete.

On Wednesday, October 24, 2018 at 10:03:00 AM UTC-5, Matthew Pava wrote:
I can’t see anything wrong with what you’ve presented.  Try generating a new 
database and using that.  See if you still get random deletes on that database.

From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of RyanW
Sent: Wednesday, October 24, 2018 9:51 AM
To: Django users
Subject: Re: Django auto-deletes field related to MySQL Transactions

Hi Matthew and Joel. Thanks for your help.

I'm attaching the models.py, views.py and templates for your reference.  I'm 
drawing a blank on the implementation that could trigger a delete.

Thanks again

On Tuesday, October 23, 2018 at 11:54:17 AM UTC-5, Matthew Pava wrote:
And make sure your form is posting to the save view and not the delete view.  
Maybe show us your template.

From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf 
Of Joel
Sent: Tuesday, October 23, 2018 11:32 AM
To: django...@googlegroups.com
Subject: Re: Django auto-deletes field related to MySQL Transactions

You could have a signal which captures all these and logs its origin.

On Tue, 23 Oct, 2018, 9:35 PM RyanW,  wrote:
Yes, I honestly don't see how Django could be doing this either.  The only I 
could think of was user deletion, but no one has claimed to have done so.

No other apps are connected.

Thanks for the tip!!

On Tuesday, October 23, 2018 at 10:05:51 AM UTC-5, Matthew Pava wrote:
It doesn’t seem like Django would be doing this.
Do you have any other apps connected to the database?
You’ll probably want to surround your URL in quotation marks.  http://epe.id> %}”>


From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf 
Of RyanW
Sent: Tuesday, October 23, 2018 9:33 AM
To: Django users
Subject: Re: Django auto-deletes field related to MySQL Transactions

I have a button to delete a record by the user, displayed inside a template as:



and the function in views.py

def delete(request, part_id=None):
obj = epe.objects.get(id=part_id)
obj.delete()
return HttpResponseRedirect(reverse('epe_home'))

Other than that, I have some ForeignKey restraints on_delete to preserve 
integrity, like so:
epe_ani2 = models.ForeignKey(
Subjects,
on_delete=models.PROTECT,
null=True,
blank=True
)

As for the authentication backend, I'm using the default provided by Django:

['django.contrib.auth.backends.ModelBackend']

Thank you for the help!

On Tuesday, October 23, 2018 at 9:16:24 AM UTC-5, Matthew Pava wrote:
Check your source code for any delete commands.
This might also be your authentication backend.  Which one are you using?

From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf 
Of RyanW
Sent: Monday, October 22, 2018 7:55 PM
To: Django users
Subject: Django auto-deletes field related to MySQL Transactions

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

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

6798 Connect
rya...@cobb.eyes.uab.edu on downswebdb2
6798 Query
SET NAMES utf8
6798 Query
set autocommit=0
6798 Query
set autocommit=1
6798 Query
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
6798 Query
SELECT `Epe_epe`.`id`, `Epe_epe`.`epe_type`, `Epe_epe`.`epe_type2_id`, 
`Epe_epe`.`epe_date`, `Epe_epe`.`epe_ani`, `Epe_epe`.`epe_ani2_id`, 
`Epe_epe`.`epe_apn`, `Epe_epe`.`epe_apn2_id`, `Epe_epe`.`epe_weight`, 
`Epe_epe`.`epe_drug_type1`, `Epe_epe`.`epe_drug1`, `Epe_epe`.`epe_dose1`, 
`Epe_epe`.`epe_amount1`, `Epe_epe`.`epe_route1`, `Epe_epe`.`epe_time1`, 
`Epe_epe`.`epe_drug_type2`, `Epe_epe`.`epe_drug2`, `Epe_epe`.`epe_dose2`, 
`Epe_epe`.`epe_amount2`, `Epe_epe`.`epe_route2`, `Epe_epe`.`epe_time2`, 
`Epe_epe`.`epe_drug_type3`, `Epe_epe`.`epe_drug3`, `Epe_epe`.`epe_dose3`, 
`Epe_epe`.`epe_amount3`, `Epe_epe`.`epe_route3`, `Epe_epe`.`epe_time3`, 
`Epe_epe`.`epe_drug_type4`, `Epe_epe`.`epe

RE: Django auto-deletes field related to MySQL Transactions

2018-10-24 Thread Matthew Pava
I can’t see anything wrong with what you’ve presented.  Try generating a new 
database and using that.  See if you still get random deletes on that database.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of RyanW
Sent: Wednesday, October 24, 2018 9:51 AM
To: Django users
Subject: Re: Django auto-deletes field related to MySQL Transactions

Hi Matthew and Joel. Thanks for your help.

I'm attaching the models.py, views.py and templates for your reference.  I'm 
drawing a blank on the implementation that could trigger a delete.

Thanks again

On Tuesday, October 23, 2018 at 11:54:17 AM UTC-5, Matthew Pava wrote:
And make sure your form is posting to the save view and not the delete view.  
Maybe show us your template.

From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of Joel
Sent: Tuesday, October 23, 2018 11:32 AM
To: django...@googlegroups.com
Subject: Re: Django auto-deletes field related to MySQL Transactions

You could have a signal which captures all these and logs its origin.

On Tue, 23 Oct, 2018, 9:35 PM RyanW, > wrote:
Yes, I honestly don't see how Django could be doing this either.  The only I 
could think of was user deletion, but no one has claimed to have done so.

No other apps are connected.

Thanks for the tip!!

On Tuesday, October 23, 2018 at 10:05:51 AM UTC-5, Matthew Pava wrote:
It doesn’t seem like Django would be doing this.
Do you have any other apps connected to the database?
You’ll probably want to surround your URL in quotation marks.  http://epe.id> %}”>


From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf 
Of RyanW
Sent: Tuesday, October 23, 2018 9:33 AM
To: Django users
Subject: Re: Django auto-deletes field related to MySQL Transactions

I have a button to delete a record by the user, displayed inside a template as:



and the function in views.py

def delete(request, part_id=None):
obj = epe.objects.get(id=part_id)
obj.delete()
return HttpResponseRedirect(reverse('epe_home'))

Other than that, I have some ForeignKey restraints on_delete to preserve 
integrity, like so:
epe_ani2 = models.ForeignKey(
Subjects,
on_delete=models.PROTECT,
null=True,
blank=True
)

As for the authentication backend, I'm using the default provided by Django:

['django.contrib.auth.backends.ModelBackend']

Thank you for the help!

On Tuesday, October 23, 2018 at 9:16:24 AM UTC-5, Matthew Pava wrote:
Check your source code for any delete commands.
This might also be your authentication backend.  Which one are you using?

From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf 
Of RyanW
Sent: Monday, October 22, 2018 7:55 PM
To: Django users
Subject: Django auto-deletes field related to MySQL Transactions

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

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

6798 Connect
rya...@cobb.eyes.uab.edu on downswebdb2
6798 Query
SET NAMES utf8
6798 Query
set autocommit=0
6798 Query
set autocommit=1
6798 Query
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
6798 Query
SELECT `Epe_epe`.`id`, `Epe_epe`.`epe_type`, `Epe_epe`.`epe_type2_id`, 
`Epe_epe`.`epe_date`, `Epe_epe`.`epe_ani`, `Epe_epe`.`epe_ani2_id`, 
`Epe_epe`.`epe_apn`, `Epe_epe`.`epe_apn2_id`, `Epe_epe`.`epe_weight`, 
`Epe_epe`.`epe_drug_type1`, `Epe_epe`.`epe_drug1`, `Epe_epe`.`epe_dose1`, 
`Epe_epe`.`epe_amount1`, `Epe_epe`.`epe_route1`, `Epe_epe`.`epe_time1`, 
`Epe_epe`.`epe_drug_type2`, `Epe_epe`.`epe_drug2`, `Epe_epe`.`epe_dose2`, 
`Epe_epe`.`epe_amount2`, `Epe_epe`.`epe_route2`, `Epe_epe`.`epe_time2`, 
`Epe_epe`.`epe_drug_type3`, `Epe_epe`.`epe_drug3`, `Epe_epe`.`epe_dose3`, 
`Epe_epe`.`epe_amount3`, `Epe_epe`.`epe_route3`, `Epe_epe`.`epe_time3`, 
`Epe_epe`.`epe_drug_type4`, `Epe_epe`.`epe_drug4`, `Epe_epe`.`epe_dose4`, 
`Epe_epe`.`epe_amount4`, `Epe_epe`.`epe_route4`, `Epe_epe`.`epe_time4`, 
`Epe_epe`.`epe_drug_type5`, `Epe_epe`.`epe_drug5`, `Epe_epe`.`epe_dose5`, 
`Epe_epe`.`epe_amount5`, `Epe_epe`.`epe_route5`, `Epe_epe`.`epe_time5`, 
`Epe_epe`.`epe_drug_type6`, `Epe_epe`.`epe_drug6`, `Epe_epe`.`epe_dose6`, 
`Epe_epe`.`epe_amount6`, `Epe_epe`.`epe_route6`, `Epe_epe`.`epe_time6`, 
`Epe_epe`.`epe_iso_start`, `Epe_epe`.`epe_iso_end`, `Epe_epe`.`epe_o2_end`, 
`Epe_epe`.`epe_start1`, `Epe_epe`.`epe_start2`, `Epe_epe`.`epe_start3`, 
`Epe_epe`.`epe_start4`, `Epe_epe`.`epe_start5`, `Epe_epe`.`epe_start6`, 
`Epe_epe`.`epe_start7`, `Epe_epe`.`epe_start8`, `Epe_epe`.`epe_hr1`, 
`Epe_epe`.`epe_hr2`, `Epe_epe`.`epe_hr3`, `Epe_epe`.`epe_hr4`, 
`Epe_epe`.`epe_hr5`, `Epe_epe`.`epe_hr6`, `Epe_epe`.`epe_hr7`, 
`Epe_epe`.`epe_hr8`, `Epe_epe`.`e

RE: Django auto-deletes field related to MySQL Transactions

2018-10-23 Thread Matthew Pava
And make sure your form is posting to the save view and not the delete view.  
Maybe show us your template.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel
Sent: Tuesday, October 23, 2018 11:32 AM
To: django-users@googlegroups.com
Subject: Re: Django auto-deletes field related to MySQL Transactions

You could have a signal which captures all these and logs its origin.

On Tue, 23 Oct, 2018, 9:35 PM RyanW, 
mailto:rwhitle...@gmail.com>> wrote:
Yes, I honestly don't see how Django could be doing this either.  The only I 
could think of was user deletion, but no one has claimed to have done so.

No other apps are connected.

Thanks for the tip!!

On Tuesday, October 23, 2018 at 10:05:51 AM UTC-5, Matthew Pava wrote:
It doesn’t seem like Django would be doing this.
Do you have any other apps connected to the database?
You’ll probably want to surround your URL in quotation marks.  http://epe.id> %}”>


From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf 
Of RyanW
Sent: Tuesday, October 23, 2018 9:33 AM
To: Django users
Subject: Re: Django auto-deletes field related to MySQL Transactions

I have a button to delete a record by the user, displayed inside a template as:



and the function in views.py

def delete(request, part_id=None):
obj = epe.objects.get(id=part_id)
obj.delete()
return HttpResponseRedirect(reverse('epe_home'))

Other than that, I have some ForeignKey restraints on_delete to preserve 
integrity, like so:
epe_ani2 = models.ForeignKey(
Subjects,
on_delete=models.PROTECT,
null=True,
blank=True
)

As for the authentication backend, I'm using the default provided by Django:

['django.contrib.auth.backends.ModelBackend']

Thank you for the help!

On Tuesday, October 23, 2018 at 9:16:24 AM UTC-5, Matthew Pava wrote:
Check your source code for any delete commands.
This might also be your authentication backend.  Which one are you using?

From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf 
Of RyanW
Sent: Monday, October 22, 2018 7:55 PM
To: Django users
Subject: Django auto-deletes field related to MySQL Transactions

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

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

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

RE: Django auto-deletes field related to MySQL Transactions

2018-10-23 Thread Matthew Pava
It doesn’t seem like Django would be doing this.
Do you have any other apps connected to the database?
You’ll probably want to surround your URL in quotation marks.  


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of RyanW
Sent: Tuesday, October 23, 2018 9:33 AM
To: Django users
Subject: Re: Django auto-deletes field related to MySQL Transactions

I have a button to delete a record by the user, displayed inside a template as:



and the function in views.py

def delete(request, part_id=None):
obj = epe.objects.get(id=part_id)
obj.delete()
return HttpResponseRedirect(reverse('epe_home'))

Other than that, I have some ForeignKey restraints on_delete to preserve 
integrity, like so:
epe_ani2 = models.ForeignKey(
Subjects,
on_delete=models.PROTECT,
null=True,
blank=True
)

As for the authentication backend, I'm using the default provided by Django:

['django.contrib.auth.backends.ModelBackend']

Thank you for the help!

On Tuesday, October 23, 2018 at 9:16:24 AM UTC-5, Matthew Pava wrote:
Check your source code for any delete commands.
This might also be your authentication backend.  Which one are you using?

From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of RyanW
Sent: Monday, October 22, 2018 7:55 PM
To: Django users
Subject: Django auto-deletes field related to MySQL Transactions

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

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

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

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

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

RE: Django auto-deletes field related to MySQL Transactions

2018-10-23 Thread Matthew Pava
Check your source code for any delete commands.
This might also be your authentication backend.  Which one are you using?

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of RyanW
Sent: Monday, October 22, 2018 7:55 PM
To: Django users
Subject: Django auto-deletes field related to MySQL Transactions

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

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

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

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

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

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

RE: There's a complete CRUD app for django, like Admin?

2018-10-23 Thread Matthew Pava
You might want to have a look at YourLabs CRUDLFAP+:
https://yourlabs.io/oss/crudlfap


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Fellipe Henrique
Sent: Tuesday, October 23, 2018 7:02 AM
To: Django Users
Subject: There's a complete CRUD app for django, like Admin?

Hello,

I have a site here, using django admin, but it's been complicated to maintain.. 
I ned to add several javascript, import sessions etc.. and Admin was good so 
far, but now I spent several time to try to modify any admin model screen...

So.. I thought, maybe there's a app to do exactly like admin, to give me 
complete list, create, update, delete and form with auto-create fields..

i try to google about that, but found only admin templates, so, I`m here... 
asking if anyone know any app like these..

Thanks!

T.·.F.·.A.·. S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
Blog: http:www.fellipeh.eti.br
GitHub: https://github.com/fellipeh
Twitter: @fh_bash
--
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/CAF1jwZEcXC1eF%2B9Y0JOsWZA4K-a9d2qe-msy%3DANS2o09twpHig%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/8cd80c09dbbc45848abc082d5874dec1%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Creating seperate unique ids within the same table

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

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

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

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

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

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

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

PRs welcome!

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

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


RE: Creating seperate unique ids within the same table

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

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


Joel,

I completely agree that UUIDs are not memorable.

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

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

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

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

Sincerely yours,

Joel G Mathew


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

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

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

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

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

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


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

How to implement built in signals, for my app?

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

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

appointments/models.py:

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

appointments/__init__.py:

default_app_config = 'appointments.apps.AppointmentsConfig'

appointments/apps.py:

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

appointments/signals.py:

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

What other modifications do I need to do this?

- Joel G Mathew

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

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


RE: Creating seperate unique ids within the same table

2018-10-18 Thread Matthew Pava
Hi Dr. Joel,
In that case, I would add a function on the customer model that simply 
concatenates the customer ID with the clinic ID.  I would avoid generating a 
whole new table for this.

def get_card_id(self, clinic):
return f"{self.id}-{clinic.id}"


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel Mathew
Sent: Thursday, October 18, 2018 9:19 AM
To: django-users@googlegroups.com
Subject: Re: Creating seperate unique ids within the same table

Hi Matthew,
Yes, and I am using the id field to query the database for many operations. But 
I do not want to share this id to the patient. The reason is that the data of 
one clinic is supposed to be seperate from another. If a patient visits another 
clinic using the same software, yes, the software should generate a different 
id for that clinic. In short, different ids for the same person in different 
clinics. Data will not be shared between the clinics.

And no, they dont get a new card at each visit. Checkid is just used internally 
to reference the data between the tables.

So how can I get a unique id for each customer per clinic? I thought of getting 
the last id from the database and then incrementing one, but that wouldnt work 
if the last customer was deleted. So I'm thinking a seperate table to store the 
last generated hospital id, and use this while creating a new customer record. 
And then incrementing the id in the table. Is this the right approach? Is there 
a better way?

To help understand what I mean, just check the GG ID printed on this hospital 
card. This id can be memorized by the patient and his records fetched and 
checked in.

https://imgur.com/bU4Bz8W

Sincerely yours,

Joel G Mathew


On Thu, 18 Oct 2018 at 19:01, Matthew Pava  wrote:
>
> Hi Dr Joel,
> Each patient already has a unique number--the id or pk of the 
> model--regardless of what clinic the patient goes to.  I even recommend 
> maintaining this structure.  Any other numbers you add to the ID are just 
> noise.  Besides, a patient could go to more than one clinic.  Would you want 
> to add the ID of all the clinics that they are associated with?
>
> If you want to see all the patients at a specific clinic, you could do 
> something like this:
> Customer.objects.filter(linkedclinic=[provided_clinic])
>
> With your new Checkins model, I’m thinking that hospitalid and linkedclinic 
> should be a OneToOne relation.  You could also combine date and time into one 
> field: a DateTimeField.  You can always split that apart for your UI.
> And each checkin also has its own ID, so you may want to use that to put on 
> the patient's card.  Do they get a new card every time they checkin?
>
>
> -Original Message-
> From: django-users@googlegroups.com 
> [mailto:django-users@googlegroups.com] On Behalf Of Joel Mathew
> Sent: Wednesday, October 17, 2018 10:41 PM
> To: django-users@googlegroups.com
> Subject: Re: Creating seperate unique ids within the same table
>
> Hi Phako,
> Thank you. I'm already following this practise. I have the following 
> additional Model:
>
> class Checkins(models.Model):
> checkinno = models.AutoField(primary_key=True, unique=True)
> hospitalid = models.ForeignKey(
> customer, on_delete=models.CASCADE, null=True)
> date = models.DateField(default=timezone.now)
> time = models.CharField(max_length=25)
> consulted = models.IntegerField(default=0)
> closed = models.IntegerField(default=0)
> linkedclinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)
>
> Right now, the program's policy allows any doctor of that clinic to see a 
> patient who checked in to that clinic, so doctor is not a ForeignKey for 
> this. But later I may need to add this too.
>
> What would you suggest for adding a unique number which gets incremented for 
> each new patient registration, and unique to each clinic?
> Sincerely yours,
>
> Dr Joel G Mathew
>
>
>
> On Thu, 18 Oct 2018 at 09:00, Phako Perez <13.phak...@gmail.com> wrote:
> >
> > I suggest to use another table for visit so you can add which doctor, 
> > schedule time, and comments or so as a patient may have 1 visit or n...
> >
> > Sent from my iPhone
> >
> > On Oct 17, 2018, at 9:59 PM, Joel Mathew  wrote:
> >
> > A hospital id needs to be assigned to a patient and printed on their id 
> > card. When they present their card or this number, their records can be 
> > retrieved at any time. A checkin id is additionally generated each day 
> > based on the date and time. A patient can have only one patient id but many 
> > checkin ids.
> >
> > What can be a good approach to solve this? Should I perhaps create another 
> > table ju

RE: Creating seperate unique ids within the same table

2018-10-18 Thread Matthew Pava
Hi Dr Joel,
Each patient already has a unique number--the id or pk of the model--regardless 
of what clinic the patient goes to.  I even recommend maintaining this 
structure.  Any other numbers you add to the ID are just noise.  Besides, a 
patient could go to more than one clinic.  Would you want to add the ID of all 
the clinics that they are associated with?

If you want to see all the patients at a specific clinic, you could do 
something like this:
Customer.objects.filter(linkedclinic=[provided_clinic])

With your new Checkins model, I’m thinking that hospitalid and linkedclinic 
should be a OneToOne relation.  You could also combine date and time into one 
field: a DateTimeField.  You can always split that apart for your UI.
And each checkin also has its own ID, so you may want to use that to put on the 
patient's card.  Do they get a new card every time they checkin?


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel Mathew
Sent: Wednesday, October 17, 2018 10:41 PM
To: django-users@googlegroups.com
Subject: Re: Creating seperate unique ids within the same table

Hi Phako,
Thank you. I'm already following this practise. I have the following additional 
Model:

class Checkins(models.Model):
checkinno = models.AutoField(primary_key=True, unique=True)
hospitalid = models.ForeignKey(
customer, on_delete=models.CASCADE, null=True)
date = models.DateField(default=timezone.now)
time = models.CharField(max_length=25)
consulted = models.IntegerField(default=0)
closed = models.IntegerField(default=0)
linkedclinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)

Right now, the program's policy allows any doctor of that clinic to see a 
patient who checked in to that clinic, so doctor is not a ForeignKey for this. 
But later I may need to add this too.

What would you suggest for adding a unique number which gets incremented for 
each new patient registration, and unique to each clinic?
Sincerely yours,

Dr Joel G Mathew



On Thu, 18 Oct 2018 at 09:00, Phako Perez <13.phak...@gmail.com> wrote:
>
> I suggest to use another table for visit so you can add which doctor, 
> schedule time, and comments or so as a patient may have 1 visit or n...
>
> Sent from my iPhone
>
> On Oct 17, 2018, at 9:59 PM, Joel Mathew  wrote:
>
> A hospital id needs to be assigned to a patient and printed on their id card. 
> When they present their card or this number, their records can be retrieved 
> at any time. A checkin id is additionally generated each day based on the 
> date and time. A patient can have only one patient id but many checkin ids.
>
> What can be a good approach to solve this? Should I perhaps create another 
> table just to store the last patient id issued to each clinic?
>
>
>
>
> On Wed, 17 Oct 2018 at 21:49, Matthew Pava  wrote:
>>
>> A number is a number, and we don’t need to attach meaning to it.
>>
>> Why do you need to have continuous ids unique to each clinic?  As a 
>> developer, I would object to anyone forcing such a requirement.  If they 
>> insisted, then I would add a property that is calculated each time based on 
>> the count of patients in the clinic.
>>
>>
>>
>> From: django-users@googlegroups.com 
>> [mailto:django-users@googlegroups.com] On Behalf Of Joel Mathew
>> Sent: Wednesday, October 17, 2018 11:01 AM
>> To: django-users@googlegroups.com
>> Subject: Creating seperate unique ids within the same table
>>
>>
>>
>> I have an application which is a clinic management software which allows 
>> login into different clinics, and needs to keep patient records of each 
>> clinic seperately. The patient records are filed in one common model, with a 
>> ForeignKey referring to the clinic to which a patient belongs.
>>
>>
>>
>> Hitherto I had used the AutoField primary key of the customer model as a 
>> hospital identification number for the patient. This number is unique and 
>> used throughout the application to retrieve querysets related to the 
>> customer. My problem is this. I want each patient to have a unique 
>> automatically incrementing id which can be given to them. Obviously since 
>> all patient records (irrespective of which clinic the patient belongs to) 
>> are stored in one model, the ids are not seperated by clinic. cstid 1 may be 
>> of clinic 1, cstid 5 may again be of clinic 1, but cstid 6 may be of clinic 
>> 2.
>>
>>
>>
>> I need patients  of one clinic to have continuous ids unique to each clinic. 
>> What can I do to achieve this, within my defined models?
>>
>>
>>
>> class Clinic(models.Model):
>>
>> clinicid = mo

RE: Creating seperate unique ids within the same table

2018-10-17 Thread Matthew Pava
A number is a number, and we don’t need to attach meaning to it.
Why do you need to have continuous ids unique to each clinic?  As a developer, 
I would object to anyone forcing such a requirement.  If they insisted, then I 
would add a property that is calculated each time based on the count of 
patients in the clinic.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Joel Mathew
Sent: Wednesday, October 17, 2018 11:01 AM
To: django-users@googlegroups.com
Subject: Creating seperate unique ids within the same table

I have an application which is a clinic management software which allows login 
into different clinics, and needs to keep patient records of each clinic 
seperately. The patient records are filed in one common model, with a 
ForeignKey referring to the clinic to which a patient belongs.

Hitherto I had used the AutoField primary key of the customer model as a 
hospital identification number for the patient. This number is unique and used 
throughout the application to retrieve querysets related to the customer. My 
problem is this. I want each patient to have a unique automatically 
incrementing id which can be given to them. Obviously since all patient records 
(irrespective of which clinic the patient belongs to) are stored in one model, 
the ids are not seperated by clinic. cstid 1 may be of clinic 1, cstid 5 may 
again be of clinic 1, but cstid 6 may be of clinic 2.

I need patients  of one clinic to have continuous ids unique to each clinic. 
What can I do to achieve this, within my defined models?

class Clinic(models.Model):
clinicid = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=60, unique=True)
label = models.SlugField(max_length=25, unique=True)
email = models.EmailField(max_length=50, default='')
mobile = models.CharField(max_length=15, default='')
alternate = models.CharField(max_length=15, default='', blank=True)
about = models.CharField(max_length=250, blank=True)
state = models.CharField(max_length=25)
city = models.CharField(max_length=35)
locality = models.CharField(max_length=35)
pincode = models.IntegerField(default=0)
address = models.TextField(max_length=80, default='', blank=True)
website = models.URLField(blank=True)
logo = models.ForeignKey(ProfilePic, blank=True, null=True, 
on_delete=models.CASCADE)
latitude = models.FloatField(blank=True)
longitude = models.FloatField(blank=True)
placeurl = models.URLField(blank=True)
class Meta:
unique_together = ["name", "mobile", "email"]
def __str__(self):
return self.name

class customer(models.Model):
# Need autoincrement, unique and primary
cstid = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=35)
age=models.IntegerField()
gender_choices = (
('male', 'Male'),
('female', 'Female'),
('other', 'Something else'),
('decline', 'Decline to answer'))
gender = models.CharField(
choices=gender_choices, max_length=10, default='male')
maritalstatus_choices = (
('unmarried', 'Unmarried'),
('married', 'Married'))
maritalstatus = models.CharField(
choices=maritalstatus_choices, max_length=10, default='Unmarried')
mobile = models.CharField(max_length=15, default='')
alternate = models.CharField(max_length=15, default='', blank=True)
email = models.CharField(max_length=50, default='', blank=True)
address = models.CharField(max_length=80, default='', blank=True)
city = models.CharField(max_length=25, default='', blank=True)
occupation = models.CharField(max_length=25, default='', blank=True)
bloodgroup_choices = (('apos', 'A+'),
('aneg', 'A-'),
('bpos', 'B+'),
('bneg', 'B-'),
('opos', 'O+'),
('oneg', 'O-'),
('abpos', 'AB+'),
('abneg', 'AB-')
)
bloodgroup = models.CharField(choices=bloodgroup_choices, max_length=5, 
default='-', blank=True)
linkedclinic = models.ForeignKey(Clinic, on_delete=models.CASCADE)
class Meta:
unique_together = ["name", "mobile", "age", "linkedclinic"]
def __str__(self):
return self.name

My thoughts are on counting the number of customer objects with specific 
ForeignKey of a clinic, and then updating hospital id field in the same model. 
But probably there's a more logical less tedious way of doing this? Or should I 
be creating seperate tables for each clinic?
--
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 

RE: Need help for sql stored proc

2018-10-17 Thread Matthew Pava
https://docs.djangoproject.com/en/2.1/topics/db/sql/#calling-stored-procedures


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Gurmeet Kaur
Sent: Wednesday, October 17, 2018 11:06 AM
To: django-users@googlegroups.com
Subject: Need help for sql stored proc

Hi all,

I have a ms sql stored proc and want to use it. How can I do that? Do I need to 
write the class just like a view in models.py?

Please suggest.

Thanks,
Gurmeet Kaur
--
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/CAEbKJVg%3DRfXuokWh9SPakJLUq3qCVrmk-DBaFSXi3xu651fZ-g%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/5e22807f4c0e49fd80f4ea2a7273c965%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: FormModel not validating the fields

2018-10-16 Thread Matthew Pava
It’s difficult to tell with your spacing in the email.  The function needs to 
be inside the class, not outside.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of faizan.fa...@gslab.com
Sent: Tuesday, October 16, 2018 4:34 AM
To: Django users
Subject: FormModel not validating the fields

I have created a form using form Model and added the def_clean method but the 
clean method is not being called . Here are my files

models.py

class EmployeeData(models.Model):
 Yes = "Yes"
 No = "No"
 Onboard='Onboard'
 Left='Left'
 Is_GUEST_CHOICES = (
 (Yes, 'Yes'),
 (No, 'No'),
 )

 STATUS_CHOICES = (
 (Onboard, 'Onboard'),
 (Left, 'Left'),
 )
 gslab_id = models.CharField(max_length=20)
 name = models.CharField(max_length=100)
 email = models.CharField(max_length=100)
 is_guest = models.CharField(max_length=50,choices=Is_GUEST_CHOICES,default=No)
 status = models.CharField(max_length=50,choices=STATUS_CHOICES,default=Onboard)
 password = models.CharField(max_length=100,null=True)
 updated_at = models.DateTimeField(auto_now_add=True)
 created_at = models.DateTimeField(auto_now_add=True)

Forms.py


from django import forms
from .models import EmployeeData
from django.core.exceptions import ValidationError


class LoginForm(forms.ModelForm):
 class Meta:
 model = EmployeeData
 fields = ('gslab_id', 'password',)
 gslab_id= forms.CharField(widget=forms.TextInput(attrs = 
{'class':'form-control white-text'}))
 password= forms.CharField(widget=forms.PasswordInput(attrs = {'class': 
'form-control white-text'}))

def clean_gslab_id(self, *args, **kwargs):
 user_id = self.cleaned_data.get('gslab_id')
 if not "cfe" in user_id:
 raise forms.ValidationError('This is not valid title')
 return user_id









views.py



def getLogindata(request):
 if request.method == 'POST':
 login_form = LoginForm(request.POST or None)
 # return HttpResponse(login_form['gslab_id'])

 if login_form.is_valid():
 emp_model=EmployeeData()
 emp_model.gslab_id=login_form['gslab_id']
 emp_model.password=login_form['password']

 emp_model.save()
 return redirect("/home")


 else:
 context={
 'login_form':login_form
 }
 return render(request, 'login.html', context)







template




 {% csrf_token %}
 {# Heading #}
 
 Login
 
 {% if login_form.errors %}
 {% for field in form %}
 {% for error in field.errors %}

 {{ error}}

 {% endfor %}
 {% endfor %}
 {% endif %}
 
 
 
 {% if login_form %}
 {{ login_form.gslab_id }}
 {% endif %}
 Employee Id
 
 
 
 {% if login_form %}
 {{ login_form.password }}
 {% endif %}
 Password
 
 
 Login
 





--
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/6747a03f-a0d2-48e7-b5ce-52d0c1a2153e%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/e8b3943a67f94bfa87af793b967aaba8%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: psycopg2 Substr SQL generator bug?

2018-10-09 Thread Matthew Pava
Yeah, that makes sense now that I think about it.  You can combine the Cast in 
the first annotate method.
Conference.objects.annotate(year_string=Cast(ExtractYear('start_date'), 
CharField())).filter(website__contains=F('year_string')).values_list('website', 
flat=True)


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Jakob Karstens
Sent: Tuesday, October 9, 2018 11:58 AM
To: Django users
Subject: Re: psycopg2 Substr SQL generator bug?

Unfortunately, using the `output_field` keyword argument leads to the same 
error:
>>> Conference.objects.annotate(year=ExtractYear('start_date', 
>>> output_field=CharField())).filter(website__contains=F('year'))
Traceback (most recent call last):
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/backends/utils.py",
 line 85, in _execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: function replace(double precision, unknown, unknown) 
does not exist
LINE 1: ...nces"."website"::text LIKE '%' || REPLACE(REPLACE(REPLACE((E...
 ^
HINT:  No function matches the given name and argument types. You might need to 
add explicit type casts.
I wonder if that is part of the same issue?

One way I got it working was using an explicit cast in another annotation:
Conference.objects.annotate(year=ExtractYear('start_date')).annotate(year_string=Cast('year',
 
CharField())).filter(website__contains=F('year_string')).values_list('website', 
flat=True)
I wonder why this works and the other method don't work? It seems I don't 
really understand the inner workings of casting and filtering between Django 
and Postgres.

Thanks again for your help

On Tuesday, October 9, 2018 at 9:48:22 AM UTC-7, Matthew Pava wrote:
Oh, I see.
Then just use Cast, or the output_field argument .
Conference.objects.annotate(year=ExtractYear('start_date', 
output_field=CharField())).filter(website__contains=F('year'))

From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of Jakob Karstens
Sent: Tuesday, October 9, 2018 11:43 AM
To: Django users
Subject: Re: psycopg2 Substr SQL generator bug?

Thanks Matthew, I'll submit a ticket.

Unfortunately, ExtractYear does not return a string, so it seems like I would 
still need to explicitly cast the year annotation to a string:
>>> Conference.objects.annotate(year=ExtractYear('start_date')).filter(website__contains=F('year'))
Traceback (most recent call last):
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/backends/utils.py",
 line 85, in _execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: function replace(double precision, unknown, unknown) 
does not exist
LINE 1: ...nces"."website"::text LIKE '%' || REPLACE(REPLACE(REPLACE((E...
 ^
HINT:  No function matches the given name and argument types. You might need to 
add explicit type casts.


On Tuesday, October 9, 2018 at 6:45:32 AM UTC-7, Matthew Pava wrote:
I would submit a ticket for that issue.
Also, instead of using string functions to  solve your problem, I would use the 
ExtractYear function.

Conference.objects.annotate(year=ExtractYear('start_date')).filter(website__contains=F('year'))


From: django...@googlegroups.com<mailto:django...@googlegroups.com> 
[mailto:django...@googlegroups.com] On Behalf Of Jakob Karstens
Sent: Tuesday, October 9, 2018 1:47 AM
To: Django users
Subject: psycopg2 Substr SQL generator bug?

I have a model named `Conference` which has two fields: a DateField 
`start_date` and a URLField `website`.
I want to filter the rows to return all Conference's c such that: c.website 
contains c.start_date__year. I want to perform this query db-side, not Python 
side (for memory reasons), and I don't want to use a raw query (for portability 
reasons). I believe that Django does not support using field lookups on the 
right side of the equals sign in a filter clause, so my idea was to create an 
annotation to pull out the year (e.g. '2018') from the `start_date` field and 
check if the `website` field contains this annotation.

To verify that I could get the year strings correctly as an annotation, I ran 
this statement:

Conference.objects.annotate(year_string=Substr(Cast('start_date', CharField()), 
1, length=4)).values_list('year_string', flat=True)

It successfully returned:


However, when I tried to filter by website containing year (replacing the 
`values_list` call with the `filter` call):
Conference.objects.annotate(year_string=Substr(Cast('start_date', CharField()), 
1, length=4)).filter(website__contains=F('year_string'))

a strange exception occurred, complaining about %1% in the generated SQL (I am 
using Postgres and the psycopg2 Python library for my Django project)
>>> Conference.ob

RE: psycopg2 Substr SQL generator bug?

2018-10-09 Thread Matthew Pava
Oh, I see.
Then just use Cast, or the output_field argument .
Conference.objects.annotate(year=ExtractYear('start_date', 
output_field=CharField())).filter(website__contains=F('year'))

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Jakob Karstens
Sent: Tuesday, October 9, 2018 11:43 AM
To: Django users
Subject: Re: psycopg2 Substr SQL generator bug?

Thanks Matthew, I'll submit a ticket.

Unfortunately, ExtractYear does not return a string, so it seems like I would 
still need to explicitly cast the year annotation to a string:
>>> Conference.objects.annotate(year=ExtractYear('start_date')).filter(website__contains=F('year'))
Traceback (most recent call last):
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/backends/utils.py",
 line 85, in _execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: function replace(double precision, unknown, unknown) 
does not exist
LINE 1: ...nces"."website"::text LIKE '%' || REPLACE(REPLACE(REPLACE((E...
 ^
HINT:  No function matches the given name and argument types. You might need to 
add explicit type casts.


On Tuesday, October 9, 2018 at 6:45:32 AM UTC-7, Matthew Pava wrote:
I would submit a ticket for that issue.
Also, instead of using string functions to  solve your problem, I would use the 
ExtractYear function.

Conference.objects.annotate(year=ExtractYear('start_date')).filter(website__contains=F('year'))


From: django...@googlegroups.com 
[mailto:django...@googlegroups.com] On Behalf Of Jakob Karstens
Sent: Tuesday, October 9, 2018 1:47 AM
To: Django users
Subject: psycopg2 Substr SQL generator bug?

I have a model named `Conference` which has two fields: a DateField 
`start_date` and a URLField `website`.
I want to filter the rows to return all Conference's c such that: c.website 
contains c.start_date__year. I want to perform this query db-side, not Python 
side (for memory reasons), and I don't want to use a raw query (for portability 
reasons). I believe that Django does not support using field lookups on the 
right side of the equals sign in a filter clause, so my idea was to create an 
annotation to pull out the year (e.g. '2018') from the `start_date` field and 
check if the `website` field contains this annotation.

To verify that I could get the year strings correctly as an annotation, I ran 
this statement:

Conference.objects.annotate(year_string=Substr(Cast('start_date', CharField()), 
1, length=4)).values_list('year_string', flat=True)

It successfully returned:


However, when I tried to filter by website containing year (replacing the 
`values_list` call with the `filter` call):
Conference.objects.annotate(year_string=Substr(Cast('start_date', CharField()), 
1, length=4)).filter(website__contains=F('year_string'))

a strange exception occurred, complaining about %1% in the generated SQL (I am 
using Postgres and the psycopg2 Python library for my Django project)
>>> Conference.objects.annotate(year_string=Substr(Cast('start_date', 
>>> CharField()), 1, length=4)).filter(website__contains=F('year_string'))
Traceback (most recent call last):
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/backends/utils.py",
 line 85, in _execute
return self.cursor.execute(sql, params)
psycopg2.DataError: invalid input syntax for integer: "%1%"
LINE 1: ...E((SUBSTRING("conferences"."start_date"::varchar, '%1%', 4))...
 ^




The above exception was the direct cause of the following exception:


Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/polymorphic/query.py",
 line 456, in __repr__
return super(PolymorphicQuerySet, self).__repr__(*args, **kwargs)
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/models/query.py",
 line 248, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/models/query.py",
 line 272, in __iter__
self._fetch_all()
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/models/query.py",
 line 1179, in _fetch_all
self._result_cache = list(self._iterable_class(self))
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/polymorphic/query.py",
 line 56, in _polymorphic_iterator
o = next(base_iter)
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/models/query.py",
 line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, 
chunk_size=self.chunk_size)
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/dja

RE: Alternatives to using __contains?

2018-10-09 Thread Matthew Pava
No.
Usually, you would try to keep all of your filtering in the managers module, 
and then you would be able to limit your refactoring of filters in that file.
You could try using *args and **kwargs syntax, but that would make it difficult 
to maintain.
I suppose you could functions in SQLAlchemy, and if you really wanted functions 
in Django, you could make them yourself.

I actually like the Django syntax.  It's very easy to follow.  You can also use 
the __ for related fields.
Questions.objects.filter(something__related_something__related_something_else__lower__contains="what")


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of megaman
Sent: Tuesday, October 9, 2018 10:03 AM
To: Django users
Subject: Alternatives to using __contains?

I’m pretty new to Django. I have just learnt that could filter a query set this 
way: 

Questions.objects.filter(question_text__contains=‘what’)

This kind of scares me a little because the filter “contains” is actually part 
of the field name. And I guess there are other operators appended to a field 
with the same __operation pattern.

Wouldn’t this make refactoring tricky? Even renaming the field name has to be 
done carefully. In my mind, this feels messy. 

Is there an alternative to doing this? Something like:
Questions.objects.filter(question_text.contains=‘what’)
Or using “contains” as a function?

Basically, can I do the same thing without adding “magic strings” to field 
names?

-- 
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/3f7194e9-b600-4a14-be1e-83f0cb35dac6%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/d461d8c15ebb4644a9e909e6295687ff%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: psycopg2 Substr SQL generator bug?

2018-10-09 Thread Matthew Pava
I would submit a ticket for that issue.
Also, instead of using string functions to  solve your problem, I would use the 
ExtractYear function.

Conference.objects.annotate(year=ExtractYear('start_date')).filter(website__contains=F('year'))


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Jakob Karstens
Sent: Tuesday, October 9, 2018 1:47 AM
To: Django users
Subject: psycopg2 Substr SQL generator bug?

I have a model named `Conference` which has two fields: a DateField 
`start_date` and a URLField `website`.
I want to filter the rows to return all Conference's c such that: c.website 
contains c.start_date__year. I want to perform this query db-side, not Python 
side (for memory reasons), and I don't want to use a raw query (for portability 
reasons). I believe that Django does not support using field lookups on the 
right side of the equals sign in a filter clause, so my idea was to create an 
annotation to pull out the year (e.g. '2018') from the `start_date` field and 
check if the `website` field contains this annotation.

To verify that I could get the year strings correctly as an annotation, I ran 
this statement:

Conference.objects.annotate(year_string=Substr(Cast('start_date', CharField()), 
1, length=4)).values_list('year_string', flat=True)

It successfully returned:


However, when I tried to filter by website containing year (replacing the 
`values_list` call with the `filter` call):
Conference.objects.annotate(year_string=Substr(Cast('start_date', CharField()), 
1, length=4)).filter(website__contains=F('year_string'))

a strange exception occurred, complaining about %1% in the generated SQL (I am 
using Postgres and the psycopg2 Python library for my Django project)
>>> Conference.objects.annotate(year_string=Substr(Cast('start_date', 
>>> CharField()), 1, length=4)).filter(website__contains=F('year_string'))
Traceback (most recent call last):
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/backends/utils.py",
 line 85, in _execute
return self.cursor.execute(sql, params)
psycopg2.DataError: invalid input syntax for integer: "%1%"
LINE 1: ...E((SUBSTRING("conferences"."start_date"::varchar, '%1%', 4))...
 ^




The above exception was the direct cause of the following exception:


Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/polymorphic/query.py",
 line 456, in __repr__
return super(PolymorphicQuerySet, self).__repr__(*args, **kwargs)
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/models/query.py",
 line 248, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/models/query.py",
 line 272, in __iter__
self._fetch_all()
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/models/query.py",
 line 1179, in _fetch_all
self._result_cache = list(self._iterable_class(self))
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/polymorphic/query.py",
 line 56, in _polymorphic_iterator
o = next(base_iter)
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/models/query.py",
 line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, 
chunk_size=self.chunk_size)
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/models/sql/compiler.py",
 line 1064, in execute_sql
cursor.execute(sql, params)
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/backends/utils.py",
 line 100, in execute
return super().execute(sql, params)
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/backends/utils.py",
 line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, 
executor=self._execute)
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/backends/utils.py",
 line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/backends/utils.py",
 line 85, in _execute
return self.cursor.execute(sql, params)
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/utils.py",
 line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
  File 
"/Users/jakobkarstens/confir/virt/lib/python3.6/site-packages/django/db/backends/utils.py",
 line 85, in _execute
return self.cursor.execute(sql, params)
django.db.utils.DataError: invalid input syntax for integer: "%1%"
LINE 1: ...E((SUBSTRING("conferences"."start_date"::varchar, '%1%', 4))...

What is going on? Why is the generated SQL "%1%" and not "1"? Is this a 
psycopg2 bug? Am I missing something?
Thanks in advance
--
You received this 

RE: "No such table" error, with different tablename as in query

2018-10-08 Thread Matthew Pava
It almost seems like your database is corrupt.  Did you run migrations before 
running the server?

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Michel Lavoie
Sent: Monday, October 8, 2018 1:15 PM
To: django-users@googlegroups.com
Subject: Re: "No such table" error, with different tablename as in query

Hi,

@Matthew: I've just tried with a blank database, and everything appeared to 
work perfectly. I couldn't reproduce the bug I'm seeing now. The database 
structure looks identical though; in both cases the table name is 
"finance_transaction", not "main.finance_transactions".

@Michal: I'm pretty sure the settings.py is ok, but here it is just in case. I 
wouldn't be here if I didn't think there was something wrong :) 
https://pastebin.com/yKzAjBcX (p.s.: Yes my secret is safe)

Thank you for your help, Matthew's suggestion gave me a possible solution (i.e. 
manually transfer my data to a new database), but I would like to avoid that if 
possible.

Michel Lavoie
lavoie.mic...@gmail.com

On Mon, Oct 8, 2018 at 11:22 AM Michal Petrucha 
mailto:michal.petru...@konk.org>> wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On Mon, Oct 08, 2018 at 10:29:30AM -0400, Michel Lavoie wrote:
> Hi Matthew,
>
> Thank you for the suggestion, but as I mentioned the error is not limited
> to my views.py; it's also present in the auto generated admin page.
> Basically in the example I gave, I call the delete() method from my
> transaction object, by id.
>
> There's also the "main."prefix in the error that bothers me, in addition to
> the "s" at the end of the table name. But I'm sure that it doesn't come
> from my views.py, this error appeared after upgrading to 2.1. My app's code
> is on GitHub: https://github.com/miek770/huitcent/tree/master/finance
>
> Thanks,
>
> Michel

Hi Michel,

I also took a glance, and didn't find anything suspicious. Is there a
chance that you have multiple databases defined in your settings, and
a router that directs write queries for the Transaction model to the
wrong one?

Michal
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQIcBAEBCgAGBQJbu3YYAAoJEHA7T/IPM/klrZ8P/1FAI/sm5UEMOUSnxjLM6fI+
/9Lu7/7ZhFvKFVXOSa6GT2pxEjOkdLmtmMwQv1ghvxgvCmVMEohOKoNDPDwhdEGA
VvYuBD7rNhmBqPTwGYdn2ci4fFIK3EaaMuv5pBkdW/ztWcyFgZaJFA1T8KEYR+nR
/8ZBcZOhcZAGpdqppCIZoJTPsHcRggAt2CGWvNzFC9BxFh3w+BqTfTkBLfa2ZQpg
MmBEpqu5VGsOIG3nlULnvnzBMhJEy8IkGf8TTmp0MUeRUycnRQnsCfIVjqDfQuGo
aetk6Jdb9C9760STJnPp7FAdtQqIYj8vdy0NU2KoM9hhxZk80YOuC1PCqDkteuRH
SmkwH5kI5FZKiKAeDUPBn4h2hvkMm/5B1kqtk+BzzAZPCY5CRkmJno+BjCWb0nFE
zSOA/i01a4hlEbhBNDjeYyxvuVVigGGXYBfLuuagIGz/61axu/pWn18sGElRqr+r
0T0c63QxuOtj6ZCJ5HrtMDRfzfnAjrRImqxmviQJo10XRKSsLavRYqIuKC1AgKFq
K+2c6cel4wb+n698FEAK24ic7gYR+ZH5kX0qOEXUMB2ND5DMKBKaqdkr7S3EqgIm
7KiuM/oL8SCxAdKKzJvvZyLwSgoDQxcAWng6YccWIZk5C5gcJHwI0wljjfPP0U3v
pUFCfu/sRN9umoHyryiF
=8Eai
-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/20181008152200.GD18928%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/CAK%3D8-RG3qHad5rcWTZ0kvduyypcFyWfM67%3D8V7JA2FJ3OOyVRQ%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/7e8033c4250946239f16d3affc3256fc%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: "No such table" error, with different tablename as in query

2018-10-08 Thread Matthew Pava
Hi Michel,
I’ve reviewed your code and everything looks like it should be working fine.  
Have you tried using a fresh, blank database?  Could it be an issue with your 
settings?
I can’t imagine what else it could be at the moment.
Thanks,
Matthew


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Michel Lavoie
Sent: Monday, October 8, 2018 9:30 AM
To: django-users@googlegroups.com
Subject: Re: "No such table" error, with different tablename as in query

Hi Matthew,

Thank you for the suggestion, but as I mentioned the error is not limited to my 
views.py; it's also present in the auto generated admin page. Basically in the 
example I gave, I call the delete() method from my transaction object, by id.

There's also the "main."prefix in the error that bothers me, in addition to the 
"s" at the end of the table name. But I'm sure that it doesn't come from my 
views.py, this error appeared after upgrading to 2.1. My app's code is on 
GitHub: https://github.com/miek770/huitcent/tree/master/finance

Thanks,

Michel

On Mon, Oct 8, 2018, 09:46 Matthew Pava, 
mailto:matthew.p...@iss.com>> wrote:
Hi Michel,
The error states that there is no such table finance_transactions  with an s on 
the end.  Maybe you could show us your view code, but that would be the place 
that I would start at.

From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
[mailto:django-users@googlegroups.com<mailto:django-users@googlegroups.com>] On 
Behalf Of Michel Lavoie
Sent: Sunday, October 7, 2018 6:17 AM
To: Django users
Subject: "No such table" error, with different tablename as in query

Hi,

I've just upgrade my Django installation from 1.11 to 2.0, and then to 2.1, and 
am now getting a weird bug with one of my applications. Whenever I try to 
execute a view that either deletes or saves a transation in my "finance" app, I 
get the following error:

OperationalError at /finance/2/1776/delete_transaction/
no such table: main.finance_transactions

The SQL query is fine though, looking at the traceback. It shows the correct 
table name which is: finance_transaction

/srv/http/myserver/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py
 in execute

def execute(self, query, params=None):
if params is None:
return Database.Cursor.execute(self, query)
query = self.convert_query(query)
return Database.Cursor.execute(self, query, params)

▼ Local vars
Variable Value
params
(1776,)
query
'DELETE FROM "finance_transaction" WHERE "finance_transaction"."id" IN (?)'
self



I checked the database and table finance_transaction is present. All views that 
just show data work fine, only the ones that modify data generate this error. 
The other apps from this instance all work 100% fine, only this one has this 
bug. I also didn't modify anything from the code for the Django upgrade, except 
a few changes to views.py and urls.py to turn of warnings.

Any idea what could be causing this? I looked at all lines from the traceback 
and can't see what could be changing the table name after the SQL string get 
created.

BTW, I get the same error from the auto-generated admin page when trying to 
delete a transaction, as well as a custom management script. Thus, it shouldn't 
be related to my views.py.

Thanks,

Michel
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/dbdeafaf-1d6c-434e-8ac6-97a57a555e9f%40googlegroups.com<https://groups.google.com/d/msgid/django-users/dbdeafaf-1d6c-434e-8ac6-97a57a555e9f%40googlegroups.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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/8195eef3c605409a8a5d7711ad234ba9%40ISS1.ISS.LOCAL<https://groups.google.com/d/msgid/django-users/8195eef3c605409a8a5d7711ad234ba9%40ISS1.ISS.LOCAL?utm_medium=email_source=foo

RE: "No such table" error, with different tablename as in query

2018-10-08 Thread Matthew Pava
Hi Michel,
The error states that there is no such table finance_transactions  with an s on 
the end.  Maybe you could show us your view code, but that would be the place 
that I would start at.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Michel Lavoie
Sent: Sunday, October 7, 2018 6:17 AM
To: Django users
Subject: "No such table" error, with different tablename as in query

Hi,

I've just upgrade my Django installation from 1.11 to 2.0, and then to 2.1, and 
am now getting a weird bug with one of my applications. Whenever I try to 
execute a view that either deletes or saves a transation in my "finance" app, I 
get the following error:

OperationalError at /finance/2/1776/delete_transaction/
no such table: main.finance_transactions

The SQL query is fine though, looking at the traceback. It shows the correct 
table name which is: finance_transaction

/srv/http/myserver/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py
 in execute

def execute(self, query, params=None):
if params is None:
return Database.Cursor.execute(self, query)
query = self.convert_query(query)
return Database.Cursor.execute(self, query, params)

▼ Local vars
Variable Value
params
(1776,)
query
'DELETE FROM "finance_transaction" WHERE "finance_transaction"."id" IN (?)'
self



I checked the database and table finance_transaction is present. All views that 
just show data work fine, only the ones that modify data generate this error. 
The other apps from this instance all work 100% fine, only this one has this 
bug. I also didn't modify anything from the code for the Django upgrade, except 
a few changes to views.py and urls.py to turn of warnings.

Any idea what could be causing this? I looked at all lines from the traceback 
and can't see what could be changing the table name after the SQL string get 
created.

BTW, I get the same error from the auto-generated admin page when trying to 
delete a transaction, as well as a custom management script. Thus, it shouldn't 
be related to my views.py.

Thanks,

Michel
--
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/dbdeafaf-1d6c-434e-8ac6-97a57a555e9f%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/8195eef3c605409a8a5d7711ad234ba9%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: db_index=True not creating indexes

2018-10-05 Thread Matthew Pava
Hi,
I’m using Django 2.0 and PostgreSQL 9.something, but my tables do have indexes. 
 Did you run the makemigrations command before running the migrate command?

Also, you can modify the database that Django uses however you want with some 
caveats.  Anyway, you can add views and modify columns and add constraints in 
the database.  I do have a suggestion that if you do that, you create your own 
migration files with the RunSQL command so that you can be able to recreate the 
database structure and keep track of your modifications.

So, in your case, if you really want to add an index manually, create a blank 
migration file, and add this operation:
migrations.RunSQL(“CREATE INDEX my_cool_looking_index USING BTREE ON 
appname_modelname (my_cool_looking_field)”)

https://docs.djangoproject.com/en/1.11/ref/django-admin/#django-admin-makemigrations

https://docs.djangoproject.com/en/1.11/ref/migration-operations/#runsql

Good luck!

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Web Architect
Sent: Friday, October 5, 2018 7:14 AM
To: Django users
Subject: db_index=True not creating indexes

Hi,

We are using django for our ecommerce website.

I am facing a strange issue. I was trying to index a field in a table and 
hence, set db_index=True in the field declaration. I ran migrations but when I 
checked the indexes for the table, the index for the field wasn't there. There 
were also few foreign key fields but no indexes for them as well. The migration 
didn't throw any error. Hence, I am a bit perplexed.

Would appreciate if anyone could help me with the above.

Also, can I create indexes directly in the database (not via django)? Will that 
have any issue in Django.

I am using Django 1.11. MySQL is 5.6.

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/2b5b6f3d-a704-46f6-9506-c0a47cdead26%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/bb23ce00c45142e1b55bfd8d104f0497%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Running Signal when Related Field is Updated

2018-09-26 Thread Matthew Pava
I have a similar set up to this (simplified):

class Transaction(models.Model):
sns = models.ManyToManyField(SN, related_name="transactions", blank=True)
qty = models.FloatField()
part = models.ForeignKey(Part, on_delete=models.CASCADE)


class InventoryTransaction(models.Model):
transaction = models.OneToOneField(Transaction, primary_key=True, 
on_delete=models.CASCADE)
parent_sn = models.ForeignKey(SN, blank=True, null=True, 
on_delete=models.CASCADE)



class Calculations(models.Model):
part = models.OneToOneField(Part, blank=False, null=False, 
on_delete=models.CASCADE, primary_key=True)
i_qty = models.FloatField(blank=True, null=True)


Whenever the user creates a new inventory transaction or updates the qty in a 
transaction that has an inventory transaction, I want to be able to change 
Calculations.i_qty.  I've been using pre_save signals on the 
InventoryTransaction as the sender, but I've come to an obstacle.

When the user creates or deletes an inventory transaction, the calculation is 
perfect.  The problem comes when the user changes an inventory transaction 
because the sender should actually be Transaction, and not 
InventoryTransaction, since qty is on the Transaction field.  Sometimes I may 
update the Transaction instance without making any changes to the 
InventoryTransaction instance, so the signal is never called to update 
Calculations.i_qty.

However, if I modify the signal to change the sender to the Transaction model, 
I get problems when creating an InventoryTransaction because the relation 
hasn't been established yet so we don't know that it's actually an 
InventoryTransaction that is being created.  If I make a signal to handle both 
Transaction and InventoryTransaction, the calculation is performed multiple 
times, which provides bad results.

I've considered using transaction atomicity.  Maybe I'm just missing something 
in my signals.  How do you typically handle this type of situation?
Thank you 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/698328c67a3f4e7f90321b95303b488f%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: django raw sql query does not return data

2018-09-26 Thread Matthew Pava
Listen to the error message.  Include the primary key in the queryset.  You can 
use any field and alias it as “id” if you need to trick the system.
Although, couldn’t that raw query use the ORM in a better way?
Post.objects.annotate(uno=Count(‘title’), 
published_date_date=Cast(‘published_date’, DateField())).values(‘uno’, 
‘published_date_date’)

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of soumyajit banerjee
Sent: Wednesday, September 26, 2018 7:17 AM
To: django-users@googlegroups.com
Subject: django raw sql query does not return data

Hi everyone,


class Post(models.Model):

author = models.ForeignKey('auth.User',on_delete=models.CASCADE,)

title = models.CharField(max_length=200)

text = RichTextField()

created_date = models.DateTimeField(default=timezone.now)

published_date = models.DateTimeField(blank=True, null=True)



def __str__(self):

return self.title

this is my sample model

and this is my view

def index(request):

fetch_post_data = 
Post.objects.filter(published_date__lte=timezone.now()).order_by('-created_date')[:5]

fetch_pgraph_data = Post.objects.raw("select count(title) as 
uno,published_date from blog_post group by DATE(published_date)")

#fetch_pgraph_data = Post.objects.raw("select * from blog_post")

template_var = {'postodj':fetch_post_data,'userdataobj':fetch_pgraph_data}

return render(request,'home.html',context=template_var)

when I am trying to fetch the data using fetch_pgraph_data, it's showing Raw 
query must include the primary key


--
Soumyajit Banerjee

[http://cdn2.hubspot.net/hubfs/184235/dev_images/signature_app/facebook_sig.png]
  
[http://cdn2.hubspot.net/hubfs/184235/dev_images/signature_app/linkedin_sig.png]
 



--
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/CAG8c6EFsFt_1UwgSch_1mY92x%2BboSrwow7H5umj4-WeYs0f2hg%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/fa8b3342e418433c9768db663266ebef%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Multiple annotations in one query

2018-09-24 Thread Matthew Pava
Hi David,
Performing multiple annotations on a queryset is not the same as combining 
multiple aggregations.
Saying that, if you truly are getting wrong results, you could try using the 
Window functions or the Subquery object.
https://docs.djangoproject.com/en/2.1/ref/models/database-functions/#window-functions
https://docs.djangoproject.com/en/2.1/ref/models/expressions/#subquery-expressions


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of David
Sent: Monday, September 24, 2018 9:36 AM
To: Django users
Subject: Multiple annotations in one query

Hi

I understand that performing multiple annotations on a queryset will produce 
incorrect results, I was wondering how anyone else gets around this?

"Combining multiple aggregations with annotate() will yield the wrong 
results because joins are used 
instead of subqueries"

My query for example:

data = Client.objects.filter(
case=self.kwargs['case_pk']
).select_related(
'case', 'inheritance',
).prefetch_related(
'children_set', 'stepchildren_set',
'grandchildren_set', 'property_set',
'investment_set', 'insurance_set',
'liability_set', 'lumpsumdeathinservice_set',
).annotate(
property_sum=Sum('property__value',),
investment_sum=Sum('investment__value'),
insurance_sum=Sum('insurance__value'),
liability_sum=Sum('liability__value'),
lumpsumdeathinservice_sum=Sum('lumpsumdeathinservice__value'),
).order_by(
'last_name', 'first_name'
)


I need to get the sum'd values.

Will I have to query each model individually and annotate it? and then somehow 
merge the querysets?

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/963bba41-6bcb-43b5-bd34-9ae4b9f709d5%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/db4521c795cb429fa03c439c13b5bc33%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: Error at OneToOneField in models while creating new models class

2018-09-22 Thread Matthew Pava
Did you try running your migrations?

Get Outlook for Android




On Sat, Sep 22, 2018 at 5:07 AM -0500, "Srinivas Gadi" 
mailto:srini@gmail.com>> wrote:

Adding more and complete details:
I am facing below error while creating a new model class.
the error pops up only at this line "user = models.OneToOneField(User)"
"E1120:No value for argument 'on_delete' in constructor call"


section/models.py

from django.db import models
from django.contrib.auth.models import User

class userProfile(models.Model):
user = models.OneToOneField(User)

admin.py

from django.contrib import admin
from section.models import userProfile

admin.site.register(userProfile)

If I add below entry with "on_delete=models.CASCADE"

user = models.OneToOneField(User,on_delete=models.CASCADE)

the error got subsided but the new class "userProfile" is not appearing in 
admin page, under Users tab.

Also, run migrations:

C:\Users\srini\djangoProjects\college>python manage.py makemigrations
No changes detected

C:\Users\srini\djangoProjects\college>python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
No migrations to apply.

Could someone please guide me how to fix this?

On Sat, Sep 22, 2018 at 2:40 PM Srinivas Gadi 
mailto:srini@gmail.com>> wrote:
HI All,

I am facing below error while creating a new model class.
the error pop up only at this line "user = models.OneToOneField(User)"
"E1120:No value for argument 'on_delete' in constructor call"

from django.db import models
from django.contrib.auth.models import User

class userProfile(models.Model):
user = models.OneToOneField(User)

If I add "user = models.OneToOneField(User,on_delete=models.CASCADE)" the error 
got subsided but the new class "userProfile" is not appearing in admin page, 
under Users tab.

Could some one please guide me how to fix this ?

--
Srinivas .G
  9966559383


--
Srinivas .G
  9966559383

--
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/CAPC7spgQAR0e28KtZG4Ljt%3Dk4Su39qipvZJaRy4%3DCJbD6CTMCA%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/D9BEB906A6B607A4.5302fd9d-847e-4878-88de-82caf2f9c69b%40mail.outlook.com.
For more options, visit https://groups.google.com/d/optout.


RE: Chaining Q objects

2018-09-19 Thread Matthew Pava
I’m not entirely sure if the error is from your Q chain, but something I would 
try is to replace “[:1].get()” with “.first()”.
wm = Boat.objects.filter(name=x).filter( f ).first()


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of MikeKJ
Sent: Wednesday, September 19, 2018 9:29 AM
To: Django users
Subject: Chaining Q objects

Using this as an example from Dan Herrar
enter code here

from django.db.models import Q
user_pk = 1
category_pk = 1  #some times None
f = Q( user__pk = user_pk, date=now() )
if category_pk is not None:
f &= Q( category__pk = category_pk )
todays_items = Item.objects.filter( f  )

I am constructing a massive filter chain (I'd rather not) so I have...
enter code here

from django.db.models import Q
f = Q(availability_text=this)
if 'cabins' in request.POST:
cabins = request.POST['cabins']
if cabins != "0" and cabins != "":
c = cabins
c = int(c)
f &= Q(cabins=c)
if 'thruster' in request.POST:
thruster = request.POST['thruster']
if thruster != 0:
t = 1
f &= Q(thruster=t)

etc etc

this is the result of an f trial

(AND: ('availability_text', ''), ('bow_thruster', 1))

but I get

"Too many values to unpack" at

wm = Boat.objects.filter(name=x).filter( f )[:1].get()

which is confusing as I am handling 4 lists and this is the 3rd iteration and 
it didn't error on iteration 1 or 2

Any insight would be gratefully received
--
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/80b8d218-f948-4985-a825-f5d13af1f4ca%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/766474725af642169c5d6cf8b056bab9%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


RE: Kerberos authent implementation

2018-09-13 Thread Matthew Pava
Hi Benjamin,
If it’s any help to you, we use LDAP through Active Directory for our 
authentication system.  We use the django-auth-ldap package.  It’s been a 
little tricky with the upgrade to Python 3/Django 2, but it’s quite manageable.
Unfortunately, I can’t help you much with Kerberos authentication.

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Benjamin SOULAS
Sent: Thursday, September 13, 2018 9:37 AM
To: Django users
Subject: Re: Kerberos authent implementation

No problem. I have to develop an app for customers assuming they can have 
different authentication system (just for information: I am discovering LDAP, 
RADIUS, Kerberos and others for a few days, I don't have skills in that).

The aim of our app is to adapt itself depending if the customer has an OpenLDAP 
authentication system, an Active Directory authentication system, Kerberos, 
Kerberos + LDAP (I don't really understand that one ...as I understood, 
Kerberos is just a communication protocol based on tickets), RADIUS 
authentication system.

So for now, I successfully authenticate OpenLDAP users (Active Directory is 
coming), but I need to investigate every possibilities, which django packages 
are available or not (if they exists, do they suits our needs, if not, how to 
write our own backends)

Kind regards,

Benjamin.
--
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/eff01ad3-6969-481c-9fd5-90ac4ef79692%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/cde1d9b8d0134a56a27bb6d470a5ec17%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   >