self.assertTemplateUsed bug?

2018-03-28 Thread Mateusz Kurowski
Ive created a sample repository to demonstrate what i think is a bug.
 https://github.com/seospace/djangorendertostringtest < its fully usable 
django project,

 I encountered that bug again in my new project... its pretty 
frustrating... and this time without "render_to_string" i cant verify used 
templated.

I think this must be checked by someone who knows this stuff, beacuse i 
suck.


Heres line that makes the "bug?" happen:
https://github.com/seospace/djangorendertostringtest/blob/master/djangorenderbug/renderbug/views.py#L11

Here is simple test that will print used templates:
https://github.com/seospace/djangorendertostringtest/blob/master/djangorenderbug/renderbug/tests.py


And results are:

{'name': 'renderbug/email/body.txt', 'origin': , 'engine': , 'source': '', 'nodelist': []}
{'name': 'renderbug/theview.html', 'origin': , 'engine': , 'source': '\n\n

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


Populate a select dropdown based on queryset

2018-03-28 Thread James Farris
Hi,

I'm trying to populate a 'vaccine' dropdown based on a 'species' of a pet.  
For example, if a pet is a 'dog' I want to display vaccines for a dog 
only.  If a pet is a cat, I want to display a list of vaccines for cats 
only.

How do I do this?  I googled, but didn't come up with anything solid.

*Here is my models.py*

class Pet(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
name = models.CharField(max_length=100, null=True, db_index=True)
species = models.CharField(choices=SPECIES_CHOICES, null=True, 
max_length=20)

def __str__(self):
return self.name


class Vaccine(models.Model):
vacc_name = models.CharField(max_length=100)
species = models.CharField(choices=SPECIES_CHOICES, null=True, 
max_length=20)
pet = models.ManyToManyField(Pet, through='PetHasVaccine')

def __str__(self):
return self.vacc_name


class PetHasVaccine(models.Model):
pet = models.ForeignKey(Pet, on_delete=models.DO_NOTHING)
vaccine = models.ForeignKey(Vaccine, on_delete=models.DO_NOTHING)

def __str__(self):
return str(self.pet.name) + ' - ' + str(self.vaccine.vacc_name)



*Here is my views.py*


def add_vaccine(request, pet_pk):
pet = Pet.objects.get(pk=pet_pk)
if pet.user == request.user:
form = VaccineForm(request.POST or None)
if request.POST:
if form.is_valid():
return HttpResponse(form)
else:
return render(request, 'pet/vaccine_add.html', {'vacc_form': 
VaccineForm(request.POST), 'pet': pet})
else:
return render(request, 'pet/vaccine_add.html', {'vacc_form': form, 
'pet': pet})



*Here is my forms.py*


class VaccineForm(ModelForm):

class Meta:
model = PetHasVaccine
fields = '__all__'
exclude = ('pet',)
widgets = {
'date_given': DateInput(),
'date_due': DateInput(),
}

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


I am trying to create a django project with a custom model that has two diffrent user profiles.it seems to have set a default profile i want to be able to choose one profile from a user

2018-03-28 Thread Andrew Korir
from django.db import models
from django.contrib.auth.models import AbstractUser,UserManager
from django.db.models.signals import post_save
from django.dispatch import receiver

# Create your models here.

class CustomUserManager(UserManager):
pass 

class CustomUser(AbstractUser):
pass

class LecProfile(models.Model):
LECTURER = 1
MANAGEMENT = 2
ROLE_CHOICES = (
(LECTURER, 'lecturer'),
(MANAGEMENT, 'management'),
)
role= models.PositiveSmallIntegerField(choices=ROLE_CHOICES,null=True,blank=
True)
user = models.OneToOneField(CustomUser,on_delete=models.CASCADE,null=True, 
related_name='lec_profile')
Employee_no = models.CharField(max_length=100)
Department = models.CharField(max_length=100)
Unit = models.CharField(max_length=100) 
lec_image = models.FileField(upload_to='profile_image',blank=True)

def __str__(self):
return self.user.username

@receiver(post_save, sender=CustomUser)
def create_or_update_lec_profile(sender, instance, created, **kwargs):
if created:
LecProfile.objects.create(user=instance)
instance.lec_profile.save()

class UserProfile(models.Model):
STUDENT = 1
STUDENT_REP = 2
ROLE_CHOICES = (
(STUDENT, 'student'),
(STUDENT_REP, 'student_rep'),
)
role= models.PositiveSmallIntegerField(choices=ROLE_CHOICES,null=True,blank=
True)
user = models.OneToOneField(CustomUser,on_delete=models.CASCADE,null=True, 
related_name='user_profile')
reg_no = models.CharField(max_length=100)
year = models.CharField(max_length=100)
course = models.CharField(max_length=100)
your_image = models.FileField(upload_to='profile_image1',blank=True)

def __str__(self):
return self.user.username

@receiver(post_save, sender=CustomUser)
def create_or_update_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.create(user=instance)
instance.user_profile.save()

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


Re: Django tutorial 2.0 problem on admin site

2018-03-28 Thread Zhizhong Kang
Thank you. You are right there are problems in both my mysite/urls.py and 
polls/urls.py. I fixed it by following the tutorial.

On Wednesday, March 28, 2018 at 10:35:01 AM UTC-7, Daniel Hepper wrote:
>
> My guess is that there is a problem with your URL definition.
>
> Double-check your mysite/urls.py and polls/urls.py
>
> When in doubt, post the source of both files (preferably as text, 
> not screenshot).
>
> Hope that helps,
> Daniel
>
> On Wednesday, March 28, 2018 at 6:25:12 PM UTC+2, Zhizhong Kang wrote:
>>
>> Hey guys what's up. I've got problem on the poll app in the admin site. 
>> For now I can enter the admin site and poll app is displayed.
>>
>> 
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> However, when I clicked the 'Question', I didn't get the change lists 
>> page for Question. My admin.py is the same as the tutorial admin.py.
>>
>>
>> 
>>  
>> 
>>
>>
>> The env is python3 + django 2.0.3 + macOS 10.12.6.
>>
>>
>>
>>
>>
>>
>>

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


Re: Django tutorial 2.0 problem on admin site

2018-03-28 Thread Daniel Hepper
My guess is that there is a problem with your URL definition.

Double-check your mysite/urls.py and polls/urls.py

When in doubt, post the source of both files (preferably as text, 
not screenshot).

Hope that helps,
Daniel

On Wednesday, March 28, 2018 at 6:25:12 PM UTC+2, Zhizhong Kang wrote:
>
> Hey guys what's up. I've got problem on the poll app in the admin site. 
> For now I can enter the admin site and poll app is displayed.
>
> 
>
>
>
>
>
>
>
>
>
>
>
>
>
> However, when I clicked the 'Question', I didn't get the change lists page 
> for Question. My admin.py is the same as the tutorial admin.py.
>
>
> 
>  
> 
>
>
> The env is python3 + django 2.0.3 + macOS 10.12.6.
>
>
>
>
>
>
>

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


Django tutorial 2.0 problem on admin site

2018-03-28 Thread Zhizhong Kang
Hey guys what's up. I've got problem on the poll app in the admin site. For 
now I can enter the admin site and poll app is displayed.














However, when I clicked the 'Question', I didn't get the change lists page 
for Question. My admin.py is the same as the tutorial admin.py.

   

 



The env is python3 + django 2.0.3 + macOS 10.12.6.






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


Re: Having ERROR running Django project !!!

2018-03-28 Thread Jamaldin Pro
https://github.com/XJoma/mk-center1

django version 1.11.5
now you have my project. So fix my problem plz !!!
It is my first time uploading so I don't know how to not show my password

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


Re: A django bug on Queryset.delete

2018-03-28 Thread Simon Charette
Hello Yue,

You probably have a model with a ForeignKey where you set on_delete=True.

Best,
Simon

Le mercredi 28 mars 2018 07:11:04 UTC-4, yue lan a écrit :
>
> Hi,
> I think I found a bug of django. My python version is 3.6.3 and Django is 
> 2.0.3.   And the bug is showed below:
>
> File "E:\programfile\python\lib\site-packages\django\db\models\query.py", 
> line 661, in delete
> collector.collect(del_query)
>   File 
> "E:\programfile\python\lib\site-packages\django\db\models\deletion.py", 
> line 222, in collect
> field.remote_field.on_delete(self, field, sub_objs, self.using)
> TypeError: 'bool' object is not callable
>
>
> As you can see, field.remote_field.on_delete is a boolean type object but 
> it is trying to call it.
>
>
> 
>
>

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


Re: Having ERROR running Django project !!!

2018-03-28 Thread Jani Tiainen
Hi.

Preferably whole project for example put it in github. If you upload your
project remember to remove sensitive data like your database passwords.


28.3.2018 5.35 ip. "Jamaldin Pro"  kirjoitti:

It is unknown and When I try to open it, it shows programs to open with I'm
> choosing chrome and my site opens without css/static/js I think that is
> html file
>

DEBUG = True

Can you tell me what files you need because I have a lot of files.setting.py?
/ wsgi.py? / urls.py? / template HTMLs?

-- 
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/464be6ef-d95b-4b69-95f8-043c5d772751%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/CAHn91oeeHNrHFHbq6FeWwNpm11BbrPn3gFd-gOLArqoi%3DeOi6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Having ERROR running Django project !!!

2018-03-28 Thread Jamaldin Pro

>
> It is unknown and When I try to open it, it shows programs to open with 
> I'm choosing chrome and my site opens without css/static/js I think that is 
> html file 
>

DEBUG = True

Can you tell me what files you need because I have a lot of 
files.setting.py? / wsgi.py? / urls.py? / template HTMLs?

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


Re: Having ERROR running Django project !!!

2018-03-28 Thread Jani Tiainen
Hi.

Unfortunately you really don't provide anything helpful, and yelling here
doesn't get you very far.

Have tried to check out what that "unknown file" contains? Also have you
used your browser debugger tools to verify that you don't get errors that
for some reason is shadowed by your browser?

Do you have DEBUG=True on? In that case if something breaks your code you
will get Django techincal 500 page that contains quite a lot of information
about your issue.

Finally, can you share your code repository so people could even guess
what's wrong with your code?


On Wed, Mar 28, 2018 at 4:45 PM, Jamaldin Pro 
wrote:

> I see no logs error and When I run it from chrome this error happens but
> when I try to use it from Internet e.version~9 it works normally, I can
> deal with it but also when I deploy to pythonanywhere there is error too.
> Yes I run it "python manage.py runserver"
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/9f87ff07-373b-4f8b-9ef5-3aa85710a563%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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


Re: Having ERROR running Django project !!!

2018-03-28 Thread Jamaldin Pro
I see no logs error and When I run it from chrome this error happens but 
when I try to use it from Internet e.version~9 it works normally, I can 
deal with it but also when I deploy to pythonanywhere there is error too. 
Yes I run it "python manage.py runserver"

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


Re: Django Channels 2 poor performance and high CPU usage

2018-03-28 Thread 'James Foley' via Django users
Here is a quick and dirty example which is basically the core of what I'm 
trying to achieve.

https://github.com/jamesfoley/django-channels-test/

Only other requirements other than those in the requirements.txt is redis 
server. Clone repo, install python 3 requirements using pip, runserver, 
open two browser windows pointing to the server. You should be presented 
with a magenta cube which you can rotate, and the view will sync with the 
other open window.

For some reason it starts to bog down and either turn into a slideshow, or 
just be extremely delayed. It also occasionally just stops working and none 
of the websockets work anymore. Restarting the server does not bring back 
the websockets either, which I guess points to the redis layer.

Here is an example: https://imgur.com/a/qRJv8

It does run a hell of a lot smoother when on its own clean Ubuntu VM which 
is how I tested it, but I can also run it pretty well on the same Vagrant 
VM my main project is being developed on.

It seems like there is something project specific that is causing it to be 
unusable but I'm basically out of ideas on what to try next. The code in my 
project is almost identical to that in the example.

On Wednesday, 28 March 2018 09:27:01 UTC+1, James Foley wrote:
>
> The project I'm working on is a little sensitive. 
>
> I'll put together a test project and try and reproduce my issues in the 
> same environment, then push it to a repo for you to take a look at.
>
> On Tuesday, 27 March 2018 17:49:19 UTC+1, Andrew Godwin wrote:
>>
>> Not getting past HANDSHAKING with the in-memory layer is a bit weird, and 
>> scope is just a normal Python dictionary. Is it possible to put your code 
>> up somewhere in a simple form so I can look over it?
>>
>> Andrew
>>
>> On Tue, Mar 27, 2018 at 4:11 AM, 'James Foley' via Django users <
>> django...@googlegroups.com> wrote:
>>
>>> It looks like accessing scope for url kwargs is a big hit on 
>>> performance. In fact hitting scope for anything seems to introduce some 
>>> form of delay.
>>>
>>> I'm getting very mixed results so I'm unsure if this is now an issue 
>>> with redis. It is definitely the python process using 100% of the CPU 
>>> though.
>>>
>>>
>>> On Tuesday, 27 March 2018 09:51:44 UTC+1, James Foley wrote:

 Apologies for the double post, I've removed the other one.

 PYTHONASYNCIODEBUG doesn't appear to give me any warnings.

 This test I am running is only between two users, each user belonging 
 to the same group. All messages received are pushed back out to all users 
 and filtered clientside.

 Assuming I use 'channels.layers.InMemoryChannelLayer' as my backend for 
 the memory layer, none of my websocket connections get past HANDSHAKING so 
 I'm not exactly sure whats up there.

 On Monday, 26 March 2018 17:35:34 UTC+1, Andrew Godwin wrote:
>
> (You double-posted this so I'm just going to reply to this one)
>
> I need to know a bit more information about what the slowdown is - in 
> particular:
>
> * Have you run with PYTHONASYNCIODEBUG=1 set as an environment 
> variable to check for non-yielding coroutines?
> * What sort of messages per second are we talking about? You say every 
> 20ms, but how many listening on the group (so what does it multiply out 
> to?)
> * Do you get the same CPU usage issues if you try using the in-memory 
> channel layer rather than the Redis one?
>
> The last point would be especially interesting to check, as the node 
> relay server you built does not, I imagine, use Redis as a cross-server 
> transport in the middle and so that would be the major difference. 200 
> requests a second should still be fine, though, so the others are worth 
> knowing about as well.
>
> One further thing you could do is build a simple echo server with no 
> use of groups or the channel layer at all and see how that performs, to 
> narrow down where the performance issue lies.
>
> Andrew
>
> On Mon, Mar 26, 2018 at 6:15 AM, James  wrote:
>
>> I'm using Channels 2 to build a shared 3D model viewing tool, but I'm 
>> running into performance issues where Channels can't keep up and uses 
>> 100% 
>> of a single core. This results in clients just receiving a slow trickle 
>> of 
>> messages rather than the fast stream I was expecting.
>>
>> I ended up stripping my consumer all the way back to basically a 
>> relay server, so a client sends a message, server broadcasts the exact 
>> data 
>> received to a group. I am sending a lot of data though (a message every 
>> 20ms or so) so not sure if that is causing my issues.
>>
>> Using node I built the same relay server and I have zero issues with 
>> speed or server performance.
>>
>> Is this down to how many workers I have running vs the data I'm 
>> 

Django Channel 2 - how to get the consumer of user in viewset?

2018-03-28 Thread CHEN POLO
I am upgrading the channel 1 to channel 2, 

I have some application wanna effect the consumer of user in viewset, 

are there any ways I could make it? 

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


A django bug on Queryset.delete

2018-03-28 Thread yue lan


Hi,
I think I found a bug of django. My python version is 3.6.3 and Django is 
2.0.3.   And the bug is showed below:

File "E:\programfile\python\lib\site-packages\django\db\models\query.py", 
line 661, in delete
collector.collect(del_query)
  File 
"E:\programfile\python\lib\site-packages\django\db\models\deletion.py", 
line 222, in collect
field.remote_field.on_delete(self, field, sub_objs, self.using)
TypeError: 'bool' object is not callable


As you can see, field.remote_field.on_delete is a boolean type object but 
it is trying to call it.



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


how to hide filed use empty_value_display

2018-03-28 Thread shawnmhy
Hi Everyone!

Is there any method to do not display the blank field use 
'empty_value_display'?

I mean, only appear those fields with values but not show those fields 
without 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/67b5c7a4-e929-472e-8ff3-53f24710f13e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


data manipulation code in custom migrations

2018-03-28 Thread PASCUAL Eric
Hello,


I recently ran into a problem with a custom migration containing code 
manipulating the data.


The simplified scenario is:

  *   a given model has been defined with its set of fields. So far so good.
  *   later on, a new field has been added, intended to contain a required 
read-only value which is automatically generated when creating new instances
  *   to fulfill the required constraint for existing instances, a custom 
migration has been added (let's call it M1 for reference) to generate the 
missing values. No problem, all (migrations, application,...) is working fine.

Later on, a new field has been added to the model (let's call it F). The 
associated automatic migration (let's call it M2) and the application still run 
fine.


A problem now occurs when running unit tests. At the time the temporary test 
database creation process runs, in hangs on migration M1. The reason is that 
when it runs, it loads the current model class definition which includes the 
field F. But this field does not exist yet in the database (since created later 
by the migration M2). Shortly said, the problem comes from the model and the 
database not being in sync when running M1.


Since I imagine that this situation is not uncommon, there should be an 
appropriate method to be applied in this case. Could anybody give some hints 
about the right way to proceed please ? Thanks in advance.


Best regards


Eric

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


Re: Django-hotsauce 0.9.2 roadmap

2018-03-28 Thread Etienne Robillard

Sorry, I meant uWSGI 2.0.17 in my initial post.

Etienne


Le 2018-03-27 à 07:45, Etienne Robillard a écrit :

Hi,

I'm planning to release a new version of Django-hotsauce (0.9.2) but 
i'm short in ideas about extending the toolkit in new ways.


Here's what I got so far:

1. PyPy 5.10.0 support

2. uWSGI 0.2.16 support

I would like to know if supporting Django 2.0 is really a must. I was 
considering the possibility of sticking with Django 1.11 in the LTS 
(stable) branch and probably include experimental Django 2.0 support 
in the 0.9.2 release.


What do you think?

Etienne




--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

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


Re: Setting Django

2018-03-28 Thread Jani Tiainen
Hi,

Yes, Django is a web framework, written in Python (it doesn't "interpret"
anything,). So everything you write in Django (well almost everything,
templating language has it's own syntax) is practically just ordinary
Python code.

As others pointed out doing official tutorial from the docs will get you
hang of basic concepts of Django (ORM, forms, templates, generic views,
admin site etc.)

On Wed, Mar 28, 2018 at 4:37 AM, Benoit EVRARD 
wrote:

> Hello, I'm new to this Django Framework. By the way, is it a Framework? I
> have no time to read all of the posts and tutos. Django seems to interpret
> python's coding am I right? I need to adapt a Zend Framework. Am I in the
> wrong path here? Best, Be
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/2af2cabf-f28f-46a5-a958-55500d17655d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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


Re: Django Channels 2 poor performance and high CPU usage

2018-03-28 Thread 'James Foley' via Django users
The project I'm working on is a little sensitive. 

I'll put together a test project and try and reproduce my issues in the 
same environment, then push it to a repo for you to take a look at.

On Tuesday, 27 March 2018 17:49:19 UTC+1, Andrew Godwin wrote:
>
> Not getting past HANDSHAKING with the in-memory layer is a bit weird, and 
> scope is just a normal Python dictionary. Is it possible to put your code 
> up somewhere in a simple form so I can look over it?
>
> Andrew
>
> On Tue, Mar 27, 2018 at 4:11 AM, 'James Foley' via Django users <
> django...@googlegroups.com > wrote:
>
>> It looks like accessing scope for url kwargs is a big hit on performance. 
>> In fact hitting scope for anything seems to introduce some form of delay.
>>
>> I'm getting very mixed results so I'm unsure if this is now an issue with 
>> redis. It is definitely the python process using 100% of the CPU though.
>>
>>
>> On Tuesday, 27 March 2018 09:51:44 UTC+1, James Foley wrote:
>>>
>>> Apologies for the double post, I've removed the other one.
>>>
>>> PYTHONASYNCIODEBUG doesn't appear to give me any warnings.
>>>
>>> This test I am running is only between two users, each user belonging to 
>>> the same group. All messages received are pushed back out to all users and 
>>> filtered clientside.
>>>
>>> Assuming I use 'channels.layers.InMemoryChannelLayer' as my backend for 
>>> the memory layer, none of my websocket connections get past HANDSHAKING so 
>>> I'm not exactly sure whats up there.
>>>
>>> On Monday, 26 March 2018 17:35:34 UTC+1, Andrew Godwin wrote:

 (You double-posted this so I'm just going to reply to this one)

 I need to know a bit more information about what the slowdown is - in 
 particular:

 * Have you run with PYTHONASYNCIODEBUG=1 set as an environment variable 
 to check for non-yielding coroutines?
 * What sort of messages per second are we talking about? You say every 
 20ms, but how many listening on the group (so what does it multiply out 
 to?)
 * Do you get the same CPU usage issues if you try using the in-memory 
 channel layer rather than the Redis one?

 The last point would be especially interesting to check, as the node 
 relay server you built does not, I imagine, use Redis as a cross-server 
 transport in the middle and so that would be the major difference. 200 
 requests a second should still be fine, though, so the others are worth 
 knowing about as well.

 One further thing you could do is build a simple echo server with no 
 use of groups or the channel layer at all and see how that performs, to 
 narrow down where the performance issue lies.

 Andrew

 On Mon, Mar 26, 2018 at 6:15 AM, James  wrote:

> I'm using Channels 2 to build a shared 3D model viewing tool, but I'm 
> running into performance issues where Channels can't keep up and uses 
> 100% 
> of a single core. This results in clients just receiving a slow trickle 
> of 
> messages rather than the fast stream I was expecting.
>
> I ended up stripping my consumer all the way back to basically a relay 
> server, so a client sends a message, server broadcasts the exact data 
> received to a group. I am sending a lot of data though (a message every 
> 20ms or so) so not sure if that is causing my issues.
>
> Using node I built the same relay server and I have zero issues with 
> speed or server performance.
>
> Is this down to how many workers I have running vs the data I'm 
> sending, or perhaps the overhead of 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...@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/fecbabcc-2692-4d7f-ac6f-6de7c3631354%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

 -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/a18867f0-23b2-49fc-a2f3-becc88971052%40googlegroups.com
>>  
>> 

Re: Setting Django

2018-03-28 Thread Andréas Kühne
Hi,

As Larry already was on to - just go through the tutorial - it will save
you a lot of time, and takes only about a half day if you do it in one
sweep. Otherwise you will probably be fighting django instead of using its
strengths.

Med vänliga hälsningar,

Andréas

2018-03-28 3:41 GMT+02:00 Larry Martell :

> On Tue, Mar 27, 2018 at 9:37 PM, Benoit EVRARD 
> wrote:
> > Hello, I'm new to this Django Framework. By the way, is it a Framework? I
> > have no time to read all of the posts and tutos. Django seems to
> interpret
> > python's coding am I right?
>
> You have no time to read the tutorials, but we are supposed to find
> time to help 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/CACwCsY7Rg1crOr7eYfofOmMyxt4ar
> KOJBXq7Cik88ds34KR6EQ%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/CAK4qSCfGMthsVfSGbKvS95TUEm7_%3DHpQh3_GFdynbqLkZ78E2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.