Re: Unexpected behavior on delete of model

2018-11-27 Thread Joel Mathew
Yes, thank you, Todor.
Yesterday night, I ended up doing exactly this.
Sincerely yours,

 Joel G Mathew



On Wed, 28 Nov 2018 at 12:46, Todor Velichkov 
wrote:

> Right now, your doctor will be deleted if its ProfilePicture gets deleted.
> I'm pretty sure you don't want to do that.
> I believe this is what you are looking for:
>
> class Doctor(models.Model):
> # When the profile picture gets delete, clear doctors profile
> picture (set to NULL)
> profilepic = models.ForeignKey(DoctorProfilePic, blank=True, null=
> True, on_delete=models.SET_NULL)
>
>
> class DoctorProfilePic (models.Model):
> # When the doctor gets deleted, delete its picture too (CASCADE)
> # PS. Do not allow orphan ProfilePics (w/o a doctor), i.e.
> blank=False, null=False
> doc = models.ForeignKey('appointments.Doctor', on_delete=models.
> CASCADE)
>
>
>
> On Wednesday, November 28, 2018 at 8:06:11 AM UTC+2, Joel wrote:
>>
>> Ignore the last post. Formatting blues in my main editor.
>>
>> On Wed, 28 Nov, 2018, 11:34 AM Joel >
>>> I think you made a typo in the code. doctor can't be a Foreign key for
>>> class Doctor. Anyway I get your point, and this is the same way I solved it
>>> yesterday.
>>>
>>> On Wed, 28 Nov, 2018, 11:07 AM Saurabh Agrawal >> wrote:
>>>

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

 Setting on_delete to SET_NULL doesn't make much sense here, I think.
 This implies that if a doctor is deleted, the profile pic will be
 preserved, with the FK to doc being set to NULL in db (which doesn't seem
 desirable). I think here CASCADE should work good and will not have the
 issue that the OP is facing.






>
>
> …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...@googlegroups.com [mailto:django...@googlegroups.com]
> *On Behalf Of *Joel Mathew
> *Sent:* Tuesday, November 27, 2018 12:24 PM
> *To:* django...@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:
>
>
>

Re: Unexpected behavior on delete of model

2018-11-27 Thread Todor Velichkov
Right now, your doctor will be deleted if its ProfilePicture gets deleted. 
I'm pretty sure you don't want to do that.
I believe this is what you are looking for:

class Doctor(models.Model):
# When the profile picture gets delete, clear doctors profile 
picture (set to NULL)
profilepic = models.ForeignKey(DoctorProfilePic, blank=True, null=
True, on_delete=models.SET_NULL)


class DoctorProfilePic (models.Model):
# When the doctor gets deleted, delete its picture too (CASCADE)
# PS. Do not allow orphan ProfilePics (w/o a doctor), i.e. 
blank=False, null=False
doc = models.ForeignKey('appointments.Doctor', on_delete=models.
CASCADE)



On Wednesday, November 28, 2018 at 8:06:11 AM UTC+2, Joel wrote:
>
> Ignore the last post. Formatting blues in my main editor.
>
> On Wed, 28 Nov, 2018, 11:34 AM Joel  wrote:
>
>> I think you made a typo in the code. doctor can't be a Foreign key for 
>> class Doctor. Anyway I get your point, and this is the same way I solved it 
>> yesterday.
>>
>> On Wed, 28 Nov, 2018, 11:07 AM Saurabh Agrawal >  wrote:
>>
>>>
  

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

  

>>>
>>> Setting on_delete to SET_NULL doesn't make much sense here, I think. 
>>> This implies that if a doctor is deleted, the profile pic will be 
>>> preserved, with the FK to doc being set to NULL in db (which doesn't seem 
>>> desirable). I think here CASCADE should work good and will not have the 
>>> issue that the OP is facing.
>>>
>>>
>>>
>>>
>>>  
>>>
  

 …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...@googlegroups.com  [mailto:
 django...@googlegroups.com ] *On Behalf Of *Joel Mathew
 *Sent:* Tuesday, November 27, 2018 12:24 PM
 *To:* django...@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 

why created_at is greater than updated_at while inserting data in table

2018-11-27 Thread Ankit Khandewal
hello, i am using this code to update created_at and updated_at in models:
created_at = models.DateTimeField(auto_now_add=True)
updated_at= models.DateTimeField(auto_now=True,null=True)

but however there is created _at is greater than updated_at when data is 
inserted: 

   created_at  -> 2018-11-26 11:11:30.020989
   updated_at -> 2018-11-26 11:11:30.019762

please help, 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/9b41f94a-63d9-4e6b-b0e0-f4056eb73fa6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


forms.FORM in django

2018-11-27 Thread shiva kumar
I am new to django and i am learning it slowly. I worked on forms but i
have one doubt,
what  forms.FORM   indicate.

i know we are inheriting forms in to our class but i dont understand
specifically what it is. how FORM will be used

could anyone please explain what it is

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


Re: Unexpected behavior on delete of model

2018-11-27 Thread Joel
Ignore the last post. Formatting blues in my main editor.

On Wed, 28 Nov, 2018, 11:34 AM Joel  I think you made a typo in the code. doctor can't be a Foreign key for
> class Doctor. Anyway I get your point, and this is the same way I solved it
> yesterday.
>
> On Wed, 28 Nov, 2018, 11:07 AM Saurabh Agrawal  wrote:
>
>>
>>>
>>>
>>> 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")
>>>
>>>
>>>
>>
>> Setting on_delete to SET_NULL doesn't make much sense here, I think. This
>> implies that if a doctor is deleted, the profile pic will be preserved,
>> with the FK to doc being set to NULL in db (which doesn't seem desirable).
>> I think here CASCADE should work good and will not have the issue that the
>> OP is facing.
>>
>>
>>
>>
>>
>>
>>>
>>>
>>> …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 

Re: Unexpected behavior on delete of model

2018-11-27 Thread Joel
I think you made a typo in the code. doctor can't be a Foreign key for
class Doctor. Anyway I get your point, and this is the same way I solved it
yesterday.

On Wed, 28 Nov, 2018, 11:07 AM Saurabh Agrawal 
>>
>>
>> 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")
>>
>>
>>
>
> Setting on_delete to SET_NULL doesn't make much sense here, I think. This
> implies that if a doctor is deleted, the profile pic will be preserved,
> with the FK to doc being set to NULL in db (which doesn't seem desirable).
> I think here CASCADE should work good and will not have the issue that the
> OP is facing.
>
>
>
>
>
>
>>
>>
>> …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 

Re: Easiest front end JavaScript framework to integrate with a Djangobackend?

2018-11-27 Thread Andréas Kühne
I think this is more of a preference for yourself.

I am using Angular with our Django Rest Framework backend. Which is a nice
choice for our current purpose.

Vue.js is also a good choice if you only want a simple frontend with only
certain functionality. Of course another choice could be React.

The only one I wouldn't use in new development would be AngularJS, the
reason for that is that it's a legacy framework nowadays, without active
development by the developer.

A final way to do it would be to use jquery of course - as long as it's
only minor parts that need to be updated?

Regards,

Andréas


Den ons 28 nov. 2018 kl 03:03 skrev Sir Robert James Patterson <
thepattersonth...@gmail.com>:

> What Alfred said . . . . .and than some 
>
> https://django-angular.readthedocs.io/en/latest/
>
>
>
>
> Sent from Mail  for
> Windows 10
>
>
>
> *From: *Alfredo Sumague 
> *Sent: *Tuesday, November 27, 2018 8:13 PM
> *To: *django-users@googlegroups.com
> *Subject: *Re: Easiest front end JavaScript framework to integrate with a
> Djangobackend?
>
>
>
> you can use AngularJS framework with Django.
>
>
>
> goodluck,
>
> Alfred
>
>
>
> On Tue, Nov 27, 2018 at 12:21 PM Simon Connah 
> wrote:
>
> I'm in the process of building a website in Django and need to make a
> specific part of my application dynamic. Because of that I'd like to use
> a JavaScript frontend framework to build this portion of the site.
>
> I was wondering if anyone had any recommendations for which JavaScript
> framework I should use that integrates well with a Django backend?
>
> If anyone is curious I am working on an auction style website.
>
> Thank you for any 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/ee666748-f8c9-37c9-5c12-491ef61ab70d%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/CAGF6mrTW8GFXLeM4XaA%2BS7DBv5vjOoDXL%3DvjOSaZmoEBYgUuHw%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/5bfdf35d.1c69fb81.fb1cc.28a6%40mx.google.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/CAK4qSCcLzQOinQ9v6AOJ%3DXGjMFX0c163knneuoMYPxFDLtDSCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unexpected behavior on delete of model

2018-11-27 Thread Saurabh Agrawal
>
>
>
>
> 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")
>
>
>

Setting on_delete to SET_NULL doesn't make much sense here, I think. This
implies that if a doctor is deleted, the profile pic will be preserved,
with the FK to doc being set to NULL in db (which doesn't seem desirable).
I think here CASCADE should work good and will not have the issue that the
OP is facing.






>
>
> …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
> https://groups.google.com/d/msgid/django-users/CAA%3Diw__vyDXxz6sfmcS_Bcy8M5cANmB7mwmTMwS4rfF96bJmbg%40mail.gmail.com
> 

RE: Easiest front end JavaScript framework to integrate with a Djangobackend?

2018-11-27 Thread Sir Robert James Patterson
What Alfred said . . . . .and than some 

https://django-angular.readthedocs.io/en/latest/ 



Sent from Mail for Windows 10

From: Alfredo Sumague
Sent: Tuesday, November 27, 2018 8:13 PM
To: django-users@googlegroups.com
Subject: Re: Easiest front end JavaScript framework to integrate with a 
Djangobackend?

you can use AngularJS framework with Django.

goodluck,
Alfred

On Tue, Nov 27, 2018 at 12:21 PM Simon Connah  wrote:
I'm in the process of building a website in Django and need to make a 
specific part of my application dynamic. Because of that I'd like to use 
a JavaScript frontend framework to build this portion of the site.

I was wondering if anyone had any recommendations for which JavaScript 
framework I should use that integrates well with a Django backend?

If anyone is curious I am working on an auction style website.

Thank you for any 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/ee666748-f8c9-37c9-5c12-491ef61ab70d%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/CAGF6mrTW8GFXLeM4XaA%2BS7DBv5vjOoDXL%3DvjOSaZmoEBYgUuHw%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/5bfdf35d.1c69fb81.fb1cc.28a6%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.


Re: Easiest front end JavaScript framework to integrate with a Django backend?

2018-11-27 Thread Alfredo Sumague
you can use AngularJS framework with Django.

goodluck,
Alfred

On Tue, Nov 27, 2018 at 12:21 PM Simon Connah 
wrote:

> I'm in the process of building a website in Django and need to make a
> specific part of my application dynamic. Because of that I'd like to use
> a JavaScript frontend framework to build this portion of the site.
>
> I was wondering if anyone had any recommendations for which JavaScript
> framework I should use that integrates well with a Django backend?
>
> If anyone is curious I am working on an auction style website.
>
> Thank you for any 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/ee666748-f8c9-37c9-5c12-491ef61ab70d%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/CAGF6mrTW8GFXLeM4XaA%2BS7DBv5vjOoDXL%3DvjOSaZmoEBYgUuHw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Retrieving Records from oauth2_provider_grant table in Django Oauth Toolkit

2018-11-27 Thread Asad Habib
How do I retrieve records from the oauth2_provider_grant table? Does Django 
Oauth Toolkit provide the functionality to do this? Thanks in advance.

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


Re: Channels: development issue with multiple daphne workers

2018-11-27 Thread Zhiyu/Drew Li
Thanks Andrew,

I tried removing "--fd 0" but it didnt work. I got 504 time out error no 
matter numprocs=1 or 4.
Do you know are there any open-source projects that use channel2?  I just 
want to take a look at their repos as my examples.

Thanks
Drew




On Tuesday, November 27, 2018 at 10:26:16 AM UTC-7, Andrew Godwin wrote:
>
> I'm not sure why you're getting the  _UnixSelectorEventLoop - that sounds 
> like a Twisted error you should search around for, and make sure you have 
> the right package versions.
>
> --fd 0 should not be needed in that command line, since you're already 
> passing the UNIX socket, I don't remember why it's there.
>
> I suggest you remove fd=0 and see if that then works with multiple 
> processes.
>
> Andrew
>
> On Mon, Nov 26, 2018 at 3:10 PM Zhiyu (Drew) Li  > wrote:
>
>> Hi there,
>>
>> I am trying to migrate a tornado project to django channel2. I have moved 
>> all essential parts and wired them up in channel. It runs OK in development 
>> mode, but in production it seems the multi-daphne worker configuration is 
>> causing strange errors.
>> AttributeError: '_UnixSelectorEventLoop' object has no attribute 
>> 'remove_timeout' 
>>  
>> I followed instructions on the official doc (
>> https://channels.readthedocs.io/en/latest/deploying.html) to set up 
>> supervisor and nginx. But I am still lack of understanding how it works. 
>> Cloud you please explain more on the following settings?
>>
>>
>> *# TCP socket used by Nginx backend upstream*
>> *socket=tcp://localhost:8000*
>>
>> *# Each process needs to have a separate socket file, so we use 
>> process_num*
>> *# Make sure to update "mysite.asgi" to match your project name*
>> *command=daphne -u /run/daphne/daphne%(process_num)d.sock --fd 0 
>> --access-log - --proxy-headers mysite.asgi:application*
>>
>> *# Number of processes to startup, roughly the number of CPUs you have*
>> *numprocs=4*
>>
>> *Questions:*
>> What is "--fd 0" here? Is "0" the file descriptor for socket  
>> "tcp://localhost:8000" that Nginx is proxying to?
>> What is "-u /run/daphne/daphne%(process_num)d.sock" then? Why do we need 
>> to set up separate socket for each daphne process? Are all the daphne 
>> processes already talking to "fd 0"?
>>
>> My website only works if I change either of the following
>> A) change to numprocs=1 ;
>> Or
>> B) remove "-u /run/daphne/daphne%(process_num)d.sock"
>>
>> Thanks
>> Drew
>>
>>
>> -- 
>> You received this message because you are subscribed 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/CAMmsbU%3D-oPX_yZ7Kx8PmVfjwKJNSSC0hKOEUXyRGztzHogKGzA%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/9657cf08-ced0-49d2-ab83-8338ebe1095a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Easiest front end JavaScript framework to integrate with a Django backend?

2018-11-27 Thread Simon Connah
I'm in the process of building a website in Django and need to make a 
specific part of my application dynamic. Because of that I'd like to use 
a JavaScript frontend framework to build this portion of the site.


I was wondering if anyone had any recommendations for which JavaScript 
framework I should use that integrates well with a Django backend?


If anyone is curious I am working on an auction style website.

Thank you for any 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/ee666748-f8c9-37c9-5c12-491ef61ab70d%40gmail.com.
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 

Unexpected behavior on delete of model

2018-11-27 Thread Joel Mathew
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 
https://groups.google.com/d/msgid/django-users/CAA%3Diw__vyDXxz6sfmcS_Bcy8M5cANmB7mwmTMwS4rfF96bJmbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels: development issue with multiple daphne workers

2018-11-27 Thread Andrew Godwin
I'm not sure why you're getting the  _UnixSelectorEventLoop - that sounds
like a Twisted error you should search around for, and make sure you have
the right package versions.

--fd 0 should not be needed in that command line, since you're already
passing the UNIX socket, I don't remember why it's there.

I suggest you remove fd=0 and see if that then works with multiple
processes.

Andrew

On Mon, Nov 26, 2018 at 3:10 PM Zhiyu (Drew) Li  wrote:

> Hi there,
>
> I am trying to migrate a tornado project to django channel2. I have moved
> all essential parts and wired them up in channel. It runs OK in development
> mode, but in production it seems the multi-daphne worker configuration is
> causing strange errors.
> AttributeError: '_UnixSelectorEventLoop' object has no attribute
> 'remove_timeout'
>
> I followed instructions on the official doc (
> https://channels.readthedocs.io/en/latest/deploying.html) to set up
> supervisor and nginx. But I am still lack of understanding how it works.
> Cloud you please explain more on the following settings?
>
>
> *# TCP socket used by Nginx backend upstream*
> *socket=tcp://localhost:8000*
>
> *# Each process needs to have a separate socket file, so we use
> process_num*
> *# Make sure to update "mysite.asgi" to match your project name*
> *command=daphne -u /run/daphne/daphne%(process_num)d.sock --fd 0
> --access-log - --proxy-headers mysite.asgi:application*
>
> *# Number of processes to startup, roughly the number of CPUs you have*
> *numprocs=4*
>
> *Questions:*
> What is "--fd 0" here? Is "0" the file descriptor for socket
> "tcp://localhost:8000" that Nginx is proxying to?
> What is "-u /run/daphne/daphne%(process_num)d.sock" then? Why do we need
> to set up separate socket for each daphne process? Are all the daphne
> processes already talking to "fd 0"?
>
> My website only works if I change either of the following
> A) change to numprocs=1 ;
> Or
> B) remove "-u /run/daphne/daphne%(process_num)d.sock"
>
> Thanks
> Drew
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMmsbU%3D-oPX_yZ7Kx8PmVfjwKJNSSC0hKOEUXyRGztzHogKGzA%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/CAFwN1uq88vgWuJDuyrc7o7tEdu1OT%2BU-i6yXZ2JuCEUD2%3DXeiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: runserver error rectification

2018-11-27 Thread shiva kumar
import polls in  mysite/mysite/urls.py
i think it will work


On Tue, Nov 27, 2018 at 3:00 PM Sanjay Malviya  wrote:

> What modification to codes required, pls in project
> mysite/mysite/polls(app)
> polls/views.py
> from django.http import httpresponse
> def index(request):
> return httpresponse('Hello, world, You're at the polls index')
> polls/urls.py
> from django.urls import path
> from . import views
> urlpatterns = [
> path('', views.index, name='index'),
> ]
> mysite/mysite/urls.py
>  from django.contrib import admin
> from django.urls import include, path
> urlpatterns = [
> path('polls/', include('polls.urls')),
> path('admin/', admin.site.urls),
> ]
>
>
> On Mon, Nov 26, 2018 at 10:57 AM Jason  wrote:
>
>> whatever you have as url patterns is not a list, tuple or other iterable.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/20504ff8-1711-4b9b-9b60-300083a8a60c%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/CAN%2BaYhcmUXjGgSeGazYB3c99t0XpgF_y4ykA64ePm%2B_uFApx3g%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/CAMsYeuFYvZkTvX67LkguVWAL_WjEBc2nZXfOcfmxJaTo5Oh4kQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Recommend Tutorials

2018-11-27 Thread Tim Johnson
* Phako Perez <13.phak...@gmail.com> [181126 19:29]:
> What I can recommend to you for this, is to use same versions for each module 
> on the tutorial so your code will works
> 
> You can create a virtual environment for each tutorial using viertualenv and 
> as a good practice you can list all module requirements on requirements.txt 
> file
  I am using a virtual environment, however I have not implemented a
  requirements.txt, will look into it.

  In the meantime, tutorials, tutorials ... my poor little brain has
  nothing to grab onto otherwise.

  thanks
> Regards
> 
> Sent from my iPhone
> 
> > On Nov 26, 2018, at 7:33 PM, Tim Johnson  wrote:
> > 
> > Using django 2.0 on ubuntu with python 3.5.2
> > 
> > Some tutorials that I have tried have deprecated code and I get
> > errors. 
> > 
> > I would appreciate recommendations for tutorials that are concurrent
> > with my version of django.
> > 
> > I presume that one at
> > https://docs.djangoproject.com/en/2.1/intro/tutorial01/ is about as
> > current as they come :).
> > 
> > It would be fun to experiment with others however.
> > thanks
> > -- 
> > Tim Johnson
> > http://www.tj49.com
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at https://groups.google.com/group/django-users.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/django-users/20181127013328.GA2345%40mail.akwebsoft.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/97DDF3D3-7320-4FB8-A81E-7A32F9273351%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
Tim Johnson
http://www.tj49.com

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


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: How can I start with django

2018-11-27 Thread Andréas Kühne
Hi,

Try the default tutorial:
https://docs.djangoproject.com/en/2.1/intro/tutorial01/

Another one that is good is this:
https://tutorial.djangogirls.org/en/

Also it could be good to think about a project that you want to implement -
could help with your development

Happy coding!

Regards,

Andréas


Den tis 27 nov. 2018 kl 15:44 skrev Khalid Adam :

> I like freamework
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4170d7e3-e8f5-4287-9571-a80795e8d93e%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/CAK4qSCeaPYYXjw2%2BSWtk7PrrzVS_pfumwjdt2LnRXOQeLEY0sA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How can I start with django

2018-11-27 Thread Khalid Adam
I like freamework

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


Re: Logging a button click

2018-11-27 Thread Nelson Varela
Look good but what is going wrong? Do you see an error or ...?

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


Re: Human Readable Values

2018-11-27 Thread Nelson Varela
show your code that renders the values

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


Re: help

2018-11-27 Thread Nelson Varela
where is your view and your template in which you show the form and handle 
the from

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


help

2018-11-27 Thread Tosin Ayoola
Good day guyz trying to create a radio button and checkbox and save it to
the database using my models, but it doesn't seems to be working the way i
want it, hoping anyone can help me out below is my code.


*models.py*

class Sports(models.Model):
  sport = models.CharField(max_length = 150)

class School(models.Model):
  SPORTS = models.ManyToManyField(Sports)

* forms.py*
class Data(ModelForm)
  SPORT = forms.MultipleChoiceField(
widget=forms.CheckboxSelectMultiple,
queryset=Sports.objects.all(),)



*will be glad if i can get any one to 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/CAHLKn71H%3DeFN4i_ccusvQFVD8yb-Jxib%3D3y8XH%2B6JgcYTF3oQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get_or_delete leading to duplicate creation

2018-11-27 Thread Joel Mathew
You're talking as if this is a bug. If your records are being duplicated,
the problem is your code. It's not unto django to gauge what you need to do
in the database. Be explicit and update the records if you want updation.
Sincerely yours,

 Joel G Mathew



On Tue, 27 Nov 2018 at 18:07, Ankit Khandewal 
wrote:

> 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/CAA%3Diw_9FC%3D%3DpsxcUTAZGaE%3DaNrRtpNa758VBjbtX3hN7J8HqZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: get_or_delete leading to duplicate creation

2018-11-27 Thread Andréas Kühne
Hi Ankit,

First - this is not the Django developers forum - it's a forum for getting
help from other users :-)
Second - I don't think this is an error in the underlying framework.
get_or_create is used by many people (I use it in several places -
especially in tests) - I would recommend that you check through your code
to see what is triggering the get_or_create calls twice first. The problem
is more likely to be something in the code that you have.

If you want help, feel free to post the problematic code here, and I am
sure that the community will help!

Regards,

Andréas


Den tis 27 nov. 2018 kl 13:37 skrev Ankit Khandewal <
ankitkhandelwal...@gmail.com>:

> 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/CAK4qSCf-T36KbLGg_1xMkD%2BWfmz0-U2NkDFM2SHmvQ8rf7ag3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django doesn't run manage.py: ModuleNotFoundError: No module named 'ProjectName' (clonded Django project))

2018-11-27 Thread Joel Mathew
What I've found helpful in these situations is:

As mentioned just above, always use virtual environment to run your project.
Include the name of the folder of the virtualenv in .gitignore
Use `pip freeze` > requirements.txt
Install modules from requirements.txt in each virtualenv

Sincerely yours,

 Joel G Mathew



On Tue, 27 Nov 2018 at 18:07, Marco Antonio Diaz Valdes <
marko19691...@gmail.com> wrote:

> Hello, my partners and I are working on a Django project using git, a
> partner begin the project and committed it on github, then the rest of us
> copy the project on their respective computers, but when we run the "python
> manage.py runserver" command (or any other command using manage.py) the
> ones who copied the project get the next error:
>
> Traceback (most recent call last): File "manage.py", line 15, in 
> execute_from_command_line(sys.argv) File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 381, in execute_from_command_line utility.execute() File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 375, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv) File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 224, in fetch_command klass = load_command_class(app_name, subcommand)
> File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 36, in load_command_class module =
> import_module('%s.management.commands.%s' % (app_name, name)) File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/importlib/__init__.py",
> line 127, in import_module return _bootstrap._gcd_import(name[level:],
> package, level) File "", line 1006, in
> _gcd_import File "", line 983, in
> _find_and_load File "", line 967, in
> _find_and_load_unlocked File "", line 677, in
> _load_unlocked File "", line 728, in
> exec_module File "", line 219, in
> _call_with_frames_removed File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/commands/migrate.py",
> line 14, in  from django.db.migrations.autodetector import
> MigrationAutodetector File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/autodetector.py",
> line 11, in  from django.db.migrations.questioner import
> MigrationQuestioner File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/questioner.py",
> line 9, in  from .loader import MigrationLoader File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/loader.py",
> line 8, in  from django.db.migrations.recorder import
> MigrationRecorder File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/recorder.py",
> line 9, in  class MigrationRecorder: File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/recorder.py",
> line 22, in MigrationRecorder class Migration(models.Model): File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/models/base.py",
> line 87, in __new__ app_config = apps.get_containing_app_config(module)
> File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/apps/registry.py",
> line 249, in get_containing_app_config self.check_apps_ready() File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/apps/registry.py",
> line 131, in check_apps_ready settings.INSTALLED_APPS File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/conf/__init__.py",
> line 57, in __getattr__ self._setup(name) File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/conf/__init__.py",
> line 44, in _setup self._wrapped = Settings(settings_module) File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/conf/__init__.py",
> line 107, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE)
> File
> "/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/importlib/__init__.py",
> line 127, in import_module return _bootstrap._gcd_import(name[level:],
> package, level) ModuleNotFoundError: No module 

Re: Django doesn't run manage.py: ModuleNotFoundError: No module named 'ProjectName' (clonded Django project))

2018-11-27 Thread Daniel M
Hello Marco..activate your virtual environment

On Nov 27, 2018 15:37, "Marco Antonio Diaz Valdes" 
wrote:

Hello, my partners and I are working on a Django project using git, a
partner begin the project and committed it on github, then the rest of us
copy the project on their respective computers, but when we run the "python
manage.py runserver" command (or any other command using manage.py) the
ones who copied the project get the next error:

Traceback (most recent call last): File "manage.py", line 15, in 
execute_from_command_line(sys.argv) File "/home/marcoadv/Documentos/
Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-
packages/django/core/management/__init__.py", line 381, in
execute_from_command_line utility.execute() File "/home/marcoadv/Documentos/
Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-
packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv) File
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_
ve/lib/python3.7/site-packages/django/core/management/__init__.py", line
224, in fetch_command klass = load_command_class(app_name, subcommand) File
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_
ve/lib/python3.7/site-packages/django/core/management/__init__.py", line
36, in load_command_class module = import_module('%s.management.commands.%s'
% (app_name, name)) File "/home/marcoadv/Documentos/Mat-programacion/
SoftwareDevelopment/classTime_ve/lib/python3.7/importlib/__init__.py", line
127, in import_module return _bootstrap._gcd_import(name[level:], package,
level) File "", line 1006, in _gcd_import File
"", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_
ve/lib/python3.7/site-packages/django/core/management/commands/migrate.py",
line 14, in  from django.db.migrations.autodetector import
MigrationAutodetector File "/home/marcoadv/Documentos/Mat-programacion/
SoftwareDevelopment/classTime_ve/lib/python3.7/site-
packages/django/db/migrations/autodetector.py", line 11, in  from
django.db.migrations.questioner import MigrationQuestioner File
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_
ve/lib/python3.7/site-packages/django/db/migrations/questioner.py", line 9,
in  from .loader import MigrationLoader File
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_
ve/lib/python3.7/site-packages/django/db/migrations/loader.py", line 8, in
 from django.db.migrations.recorder import MigrationRecorder File
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_
ve/lib/python3.7/site-packages/django/db/migrations/recorder.py", line 9,
in  class MigrationRecorder: File "/home/marcoadv/Documentos/
Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-
packages/django/db/migrations/recorder.py", line 22, in MigrationRecorder
class Migration(models.Model): File "/home/marcoadv/Documentos/
Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-
packages/django/db/models/base.py", line 87, in __new__ app_config =
apps.get_containing_app_config(module) File "/home/marcoadv/Documentos/
Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-
packages/django/apps/registry.py", line 249, in get_containing_app_config
self.check_apps_ready() File "/home/marcoadv/Documentos/Mat-programacion/
SoftwareDevelopment/classTime_ve/lib/python3.7/site-
packages/django/apps/registry.py", line 131, in check_apps_ready
settings.INSTALLED_APPS File "/home/marcoadv/Documentos/Mat-programacion/
SoftwareDevelopment/classTime_ve/lib/python3.7/site-
packages/django/conf/__init__.py", line 57, in __getattr__
self._setup(name) File "/home/marcoadv/Documentos/Mat-programacion/
SoftwareDevelopment/classTime_ve/lib/python3.7/site-
packages/django/conf/__init__.py", line 44, in _setup self._wrapped =
Settings(settings_module) File "/home/marcoadv/Documentos/Mat-programacion/
SoftwareDevelopment/classTime_ve/lib/python3.7/site-
packages/django/conf/__init__.py", line 107, in __init__ mod =
importlib.import_module(self.SETTINGS_MODULE) File
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_
ve/lib/python3.7/importlib/__init__.py", line 127, in import_module return
_bootstrap._gcd_import(name[level:], package, level) ModuleNotFoundError:
No module named 'classTime'
It basically says that manage.py can't find the module of the actually
project, I was searching on the browser finding an answer, saying that I
need to run it in a virtual envirioment, but I still getting the error,
Does somebody know how to solve it? I'll really appreciate your answers


If you need more details I will give them to you,

-- 
You received this message 

get_or_delete leading to duplicate creation

2018-11-27 Thread Ankit Khandewal
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.


Django doesn't run manage.py: ModuleNotFoundError: No module named 'ProjectName' (clonded Django project))

2018-11-27 Thread Marco Antonio Diaz Valdes


Hello, my partners and I are working on a Django project using git, a 
partner begin the project and committed it on github, then the rest of us 
copy the project on their respective computers, but when we run the "python 
manage.py runserver" command (or any other command using manage.py) the 
ones who copied the project get the next error:

Traceback (most recent call last): File "manage.py", line 15, in  
execute_from_command_line(sys.argv) File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
 
line 381, in execute_from_command_line utility.execute() File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
 
line 375, in execute 
self.fetch_command(subcommand).run_from_argv(self.argv) File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
 
line 224, in fetch_command klass = load_command_class(app_name, subcommand) 
File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/__init__.py",
 
line 36, in load_command_class module = 
import_module('%s.management.commands.%s' % (app_name, name)) File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/importlib/__init__.py",
 
line 127, in import_module return _bootstrap._gcd_import(name[level:], 
package, level) File "", line 1006, in 
_gcd_import File "", line 983, in 
_find_and_load File "", line 967, in 
_find_and_load_unlocked File "", line 677, in 
_load_unlocked File "", line 728, in 
exec_module File "", line 219, in 
_call_with_frames_removed File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/core/management/commands/migrate.py",
 
line 14, in  from django.db.migrations.autodetector import 
MigrationAutodetector File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/autodetector.py",
 
line 11, in  from django.db.migrations.questioner import 
MigrationQuestioner File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/questioner.py",
 
line 9, in  from .loader import MigrationLoader File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/loader.py",
 
line 8, in  from django.db.migrations.recorder import 
MigrationRecorder File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/recorder.py",
 
line 9, in  class MigrationRecorder: File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/migrations/recorder.py",
 
line 22, in MigrationRecorder class Migration(models.Model): File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/db/models/base.py",
 
line 87, in __new__ app_config = apps.get_containing_app_config(module) 
File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/apps/registry.py",
 
line 249, in get_containing_app_config self.check_apps_ready() File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/apps/registry.py",
 
line 131, in check_apps_ready settings.INSTALLED_APPS File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/conf/__init__.py",
 
line 57, in __getattr__ self._setup(name) File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/conf/__init__.py",
 
line 44, in _setup self._wrapped = Settings(settings_module) File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/site-packages/django/conf/__init__.py",
 
line 107, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) 
File 
"/home/marcoadv/Documentos/Mat-programacion/SoftwareDevelopment/classTime_ve/lib/python3.7/importlib/__init__.py",
 
line 127, in import_module return _bootstrap._gcd_import(name[level:], 
package, level) ModuleNotFoundError: No module named 'classTime'
It basically says that manage.py can't find the module of the actually 
project, I was searching on the browser finding an answer, saying that I 
need to run it in a virtual envirioment, but I still getting the error, 
Does somebody know how to solve it? I'll really appreciate your answers


If you need more details I will give them to you,

-- 
You received this message because you are subscribed to the Google Groups 
"Django 

Re: runserver error rectification

2018-11-27 Thread Sanjay Malviya
What modification to codes required, pls in project mysite/mysite/polls(app)
polls/views.py
from django.http import httpresponse
def index(request):
return httpresponse('Hello, world, You're at the polls index')
polls/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
mysite/mysite/urls.py
 from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),
]


On Mon, Nov 26, 2018 at 10:57 AM Jason  wrote:

> whatever you have as url patterns is not a list, tuple or other iterable.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/20504ff8-1711-4b9b-9b60-300083a8a60c%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/CAN%2BaYhcmUXjGgSeGazYB3c99t0XpgF_y4ykA64ePm%2B_uFApx3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Max function and grouping with Oracle

2018-11-27 Thread Simon Charette
Dan,

The root of the issue here is that you query is asking to retrieve all 
fields from
the Parent table and perform an aggregation on the JOIN'ed child table.

That results in the following query

SELECT parent.*, MAX(child.updated_timestamp)
FROM parent
JOIN child ON (child.parent_id = parent.id)
...

Since you SELECT all parent columns Django has no choice but to GROUP BY
parent.* as well because on Oracle GROUP BY must contain all non-aggregate
SELECT clauses. That is not the case on MySQL and PostgreSQL for example.

If you use .values('id') as you described you'll only SELECT parent.id 
which will
solve your issue as you've come to discover.

FWIW .only('id') would have worked as well and returned Parent objects 
instead
of a dict but all fields accesses would have been deferred.

Also there's a ticket tracking support for aggregation through subquery 
that would
have worked for your case[0]

Parent.objects.annotate(
child_updated_timestamp=Child.objects.filter(
parent=OuterRef('pk'),
).aggregate(Max('updated_timestamp'))
)

Cheers,
Simon

[0] https://code.djangoproject.com/ticket/28296


Le lundi 26 novembre 2018 12:32:09 UTC-5, Dan Davis a écrit :
>
> I have a parent model that has a relationship to some data that is 
> changing:
>
>
> class Parent(models.Model):
>  name = models.CharField(...)
>  created_timestamp = models.DateTimeField(auto_now_add=True, null=True)
>  updated_timestamp = models.DateTimeField(auto_now=True, null=True)
>
>
> class Child(models.Model):
>  parent = models.ForeignKey(Parent, on_delete=models.CASCADE)
>  created_timestamp = models.DateTimeField(auto_now_add=True, null=True)
>  updated_timestamp = models.DateTimeField(auto_now=True, null=True)
>
>
>
> I am trying to annotate a query with a Max updated_timestamp for the 
> children:
>
> Parent.objects.annotate(child_updated_timestamp=models.Max('child__updated_timestamp',
>  
> output_field=models.DateTimeField()))
>
>
> It seems like Oracle backend is attempting to GROUP BY every field in the 
> child model.
>
> Can anyone tell me whether they've seen anything like this and how to 
> constrain the GROUP BY?
>
> Thanks,
>
> -Dan
>
>
>  
> 
>
>

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