Re: Questions about MySQL notes in Django docs

2019-01-26 Thread Carsten Fuchs
Hi Jason,

Am 24.01.19 um 14:47 schrieb Jason:
> It doesn't look like the fixes were backported to 1.11, after looking in the 
> django 1.11 release notes.
> As Tim said, 
>> Based on the commits there, it looks like Django 2.0.7 and above 
>> received the fixes

Yes, that's part of my problem.

My project is already at Python 3.6 and normally I would now work through 
Django versions 2.0, 2.1 and soon 2.2, upgrading and testing at each iteration.

Unfortunately, Django 2.0 does no longer support Oracle 11 while Django 1.11 
doesn't have the MySQL fixes referenced by Tim.

That means that I'd be forced to switch from Django 1.11 to Django 2.0 and from 
Oracle 11 to MySQL 8 simultaneously – and that is more risk that I can bear. 
(Being able to follow Django's point releases at a reasonable pace is my main 
personal motivation for switching the database. Being stuck is really 
frustrating.)

Thus, the first step that I have to take is to switch the database to MySQL 8 
at Django 1.11.
Thus my question: ticket #29451 doesn't seem to affect my use case, but is 
there anything else that I should be aware of when using MySQL 8 at Django 1.11?

For example, web search leads to 
https://stackoverflow.com/questions/49949480/test-django-with-mysql-8-0-datetime-incompatible
However, I'm not experienced enough with MySQL 8 to draw the proper 
conclusions: Will Django 1.11 work anyways with the latest connector? 
https://bugs.mysql.com/bug.php?id=90541 suggests a work-around (for Django 
2.0), but does the datetime problem affect the recommended "mysqlclient" 
connector as well?

Which brings me back to my other questions:

b) Why is the "mysqlclient" client the recommended choice? --- quite the 
opposite is suggested at https://dev.mysql.com/doc/connector-python/en/

c) Regarding utf8, utf8mb3 and utf8mb4 there is conflicting information as well 
(https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-sets.html), but I can 
figure that out on my own.

Best regards,
Carsten

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


Re: Queryset - exclude one data over two

2019-01-26 Thread Stéphane Manguette
Thanks ! It works perfectly !

Le vendredi 25 janvier 2019 17:07:05 UTC+1, C. Kirby a écrit :
>
> You can use islice from itertools in this way 
>
> islice('ABCDEFG', 0, None, 2) --> A C E G
>
> In your case you would replace 
> chart = temp_db.objects.filter(date__gte=beg_range)
>
> with
> chart = [x for x in islice(temp_db.objects.filter(date__gte=beg_range), 0, 
> None, 2)]
>
>
> That will give you every other instance from your query set starting with the 
> first
>
>
> On Friday, January 25, 2019 at 9:02:33 AM UTC-5, Stéphane Manguette wrote:
>>
>> Hello;
>>
>> I've a DBB with a lot of values which are recorded every 2 minutes (this 
>> cannot be changed).
>>
>> I'm trying to get all values recorded over the last 24h
>>
>> def dashboard(request):
>> version = version_global
>> end_range = datetime.now()
>> beg_range = end_range - timedelta(days=1)
>> chart = temp_db.objects.filter(date__gte=beg_range)
>> last_entry = chart.latest('date')
>> return render(request, 'index.html', locals())
>>
>> The following code works perfectly. The goal is to populate a Chart.js in 
>> index.html. Unfortunately, there is a lot to transmit making it long to 
>> charge. Since my chart is not mainly meant to show trends; I could skip one 
>> data over two. Is there a function do do so? 
>>
>> Thanks a lot,
>>
>> Stéphane
>>
>>

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


forms with get_or_create and inlineformset_factory

2019-01-26 Thread Elias Coutinho
Good morning my friends.

I have two forms that I use to insert data into the same models in 
different situations:

class SearchFormCompleto(forms.ModelForm):

class Meta:
model = Search
fields = (
'search_key',
'person',
'researched',
)


class SearchForm(forms.ModelForm):

class Meta:
model = Search
fields = '__all__'
exclude = ()

layout = Layout(
Fieldset("Responda com Calma.", Row('person', 'search_key'), 
Row('researched',),))


SearchItemFormSet = inlineformset_factory(Search, SearchItem,
  exclude=('id',),
  can_delete=True,
  fields=('question', 'response'), 
extra=1)


These forms refer to the models below:

class Search(models.Model):
search_key = models.CharField(
'Período', max_length=200, db_index=False)
person = models.ForeignKey(
'core.client', related_name='Cliente', on_delete=models.CASCADE)
researched = models.CharField('Entrevistado', max_length=200)
participation_on = models.DateField(
'Período da pesquisa',
auto_now_add=True,
auto_now=False
)
created_on = models.DateTimeField(
'Solicitado em',
auto_now_add=True,
auto_now=False
)

class Meta:
verbose_name = 'Pesquisa'
verbose_name_plural = 'Pesquisas'
unique_together = (('search_key', 'person'),)
ordering = ('-participation_on',)

def get_absolute_url(self):
return reverse('person_client_detail', args=[str(self.pk)])

def __str__(self):
return self.search_key


Which has a signals described below:

def post_save_search(sender, instance, created,  **kwargs):
if created:
questions = Question.objects.all()
# search = Search.objects.filter(pk=instance.pk)

lista = []

# print(worksheet.nrows)
for question in questions:
print('search_id=', instance.pk, 'question_id=', question.pk)
lista.append(
SearchItem(search_id=instance.pk,
   question_id=question.pk,
   response=False,
   )
)

SearchItem.objects.bulk_create(lista)


models.signals.post_save.connect(
post_save_search, sender=Search, dispatch_uid='post_save_search'
)


and the SeachItem model that has a Seach FK above:

class SearchItem(models.Model):
RESPONSE_CHOICES = (
('V', 'Verdadeiro'),
('F', 'Falso'),
('I', 'Indefinido'),
)

search = models.ForeignKey(
'core.search', related_name='Periodo', on_delete=models.CASCADE, 
verbose_name="Período da Pesquisa")
question = models.ForeignKey(
'core.question', related_name='Pergunta', on_delete=models.CASCADE, 
verbose_name="Pergunta")
response = models.BooleanField('Resposta')

class Meta:
verbose_name = 'Pesquisa Detalhe'
verbose_name_plural = 'Pesquisas Detalhe'
unique_together = (('search', 'question'),)
ordering = ('-question',)

def __str__(self):
return self.question.question


SeachItem also has an FK of Question:

class Question(models.Model):
LEVEL_CHOICES = (
('0', 'Dependencia'),
('1', 'Confianca'),
('2', 'Comprometimento'),
('3', 'Preditiva'),
)
question = models.CharField('Pergunta', max_length=200)
level = models.CharField('Nível', max_length=15,
 choices=LEVEL_CHOICES, default='0')

class Meta:
verbose_name = 'Questão'
verbose_name_plural = 'Questões'
ordering = ('-level',)

def __str__(self):
return self.question


My problem starts here:

When I use the view seach_create it registers the data in the Seach model 
and in turn the signals launches the questions in the SeachItem model (This 
is beautiful! At least for me because the situation requires it to be), see 
how the view is:

def seach_create(request):
if request.method == 'POST':
form = SearchForm(request.POST)

if form.is_valid():
print(' FORM VALIDO ')
new = form.save(commit=False)
new.save()
#form.save_m2m()

return HttpResponseRedirect('/pesquisa/listar')
else:
print(' AVISO DE FORMULARIO INVALIDO ')
print(form)
return render(request, 'seach_create.html', {'form':form})
else:
context = {'form': SearchForm()}
return render(request, 'seach_create.html', context)


When I use the search_create view it does the same thing and then tries to 
register the formset fields, and that's where it returns the key duplicity 
error See how the view is:

def pesquisa_create(request):
success_message = 'The Search was edited correctly.'
  

Re: Setting up Django on GoDaddy Deluxe Shared Hosting

2019-01-26 Thread chandrashekhar Damahe
hii, i am follow these steps but i got error " The requested URL 
/dispatch.py/ was not found on this server. " will you help me to solve 
these error


On Saturday, December 29, 2007 at 3:50:38 AM UTC+5:30, Donald H wrote:
>
> Has anyone had success in setting up Django on GoDaddy's Deluxe shared 
> hosting plan?  It supports Python CGI, but has no shell access. I read 
> a previous post from October 2006, where I read of another user who 
> did the same things I did (guided by the django documentation for 
> shared hosts), but now I'm stuck. I'm hoping someone has managed more 
> success than this since October 2006. 
>
> I created a "myaite.fcgi" script, but I was confused by some of the 
> items.  For example, adding the custom Python path with 
> "sys.path.insert(0,"/home/user/python")" - what is that?  If python is 
> already installed at "/usr/bin/python", what would this do? 
>
> And I don't even know if fastcgi is accessible for python.  I come 
> from a .Net/Java background and everything apache- and cgi-based is 
> quite foreign to me. 
>
> And I know I could switch to a different host, but I already have 
> several other domains hosted at godaddy and would prefer not to have 
> to change hosts to use Django. 
>
> Thanks for any direction you guys can offer (even if it's to tell me 
> it's not possible). 
>
> Donald H.

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


Re: ValueError at /news/ Value: None must be instance of Model:

2019-01-26 Thread team . alphav3
This usually happens when you have added and EmbeddedModel and not passing 
any value to that field while creation.
Hope this helps.

On Sunday, 19 August 2018 19:32:49 UTC+5:30, Sagar wrote:
>
> Hi,
> I'm trying to create embedded documents in mongodb using django. I'm 
> facing this error when I tried to insert a post in database.
> "ValueError at /post/Value: None must be instance of Model:  'django.db.models.base.Model'>"
> Here is my code.
> models.py
> from djongo import models
>
>
> # Schema for comments collection which include in belonging post
> class Comments(models.Model):
> username = models.CharField(max_length=25, blank=False)
> comment = models.TextField()
> time_stamp = models.DateTimeField(auto_now_add=True)
>
>
> # Schema for post collection
> class Post(models.Model):
> username = models.CharField(max_length=25, blank=False)
> title = models.CharField(max_length=100, blank=False)
> post = models.TextField()
> time_stamp = models.DateTimeField(auto_now_add=True)
> comments = models.EmbeddedModelField('Comments')
>
> # allows to use all functionality of django orm
> objects = models.DjongoManager()
>
> def __str__(self):
> return self.post
>
> serializers.py
>
> from rest_framework import serializers
> from models import Post, Comments
>
>
> class PostSerializer(serializers.ModelSerializer):
> class Meta:
> model = Post
> fields = ('id', 'username', 'title', 'post', 'time_stamp')
>
>
> class CommentsSerializer(serializers.ModelSerializer):
> class Meta:
> model = Comments
> fields = '__all__'
>
> views.py
> from rest_framework_mongoengine import generics
> from serializers import PostSerializer, CommentsSerializer
> from models import Post, Comments
>
>
> class PostAPIView(generics.CreateAPIView):
> lookup_field = 'id'
> serializer_class = PostSerializer
>
> def get_queryset(self):
> return Post.__objects.all()
>
>
> class CommentsAPIView(generics.CreateAPIView):
> lookup_field = 'id'
> serializer_class = CommentsSerializer
>
> def get_queryset(self):
> return Comments.__objects.all()
>
> what is the problem with the code? Is this right method to create embedded 
> documents in mongodb?
> I used python3.6.4, django2.1, djongo1.2.29 and other libraries like 
> pymongo and mongoengine
>

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


Re: Access to the last object of model inside model itself

2019-01-26 Thread Mohammad Etemaddar
Im not agree. Managers are created for custom query. But here the query is last.
I think I got the philosophy. The default value should not be a manager, 
because the database does not understand it.
Maybe I am wrong!

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


Re: Access to the last object of model inside model itself

2019-01-26 Thread Mohammad Etemaddar
I commented out the default value and then ran the makemigrations again, and 
then uncommented again and worked. Of course by lambda.

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


forms with get_or_create and inlineformset_factory

2019-01-26 Thread Mohammad Etemaddar
I think the answer is in your signal-connected function in your question query 
which you choosed all() questions.
I did not understand the project, but you should choose questions in signal and 
not all questions I think.

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


Re: forms with get_or_create and inlineformset_factory

2019-01-26 Thread Elias Coutinho
could be but in the context of my client's need this would be inversely to
what the project proposes. When he needs to choose the questions he must
choose a form and when he wishes all he chooses another. so there are two
way and two Views.

Em sáb, 26 de jan de 2019 14:31, Mohammad Etemaddar <
mohammad.etemad...@gmail.com escreveu:

> I think the answer is in your signal-connected function in your question
> query which you choosed all() questions.
> I did not understand the project, but you should choose questions in
> signal and not all questions I think.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/T46hX618pjA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/500bbf6f-9b4d-47eb-9766-aa61b6d266a8%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/CALgom8pbAVeDkDaKgkKFOed7UwjGrty8WZqBH0uaJqkj8NPsOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: regarding django hosting

2019-01-26 Thread Ousseynou Diop
Try DigitalOcean with ubuntu it's well documented.
https://gist.github.com/bradtraversy/cfa565b879ff1458dba08f423cb01d71



Le sam. 26 janv. 2019 à 07:56, tribhuvan kishor <
tribhuvankishor...@gmail.com> a écrit :

> can you please help me with some elaboration because i am completely
> beginner in hosting i am completely unaware with nginx and gunicor
> n
>
> On Sat, Jan 26, 2019 at 1:09 PM Anirudh Jain 
> wrote:
>
>> AWS EC2 is good with nginx and gunicorn
>>
>> On Sat, 26 Jan 2019, 13:04 tribhuvan kishor > wrote:
>>
>>>
>>> can you guys please help which is best hosting solution for django
>>> --
>>> regards
>>> Tribhuvan Kishor Bhaskar
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CACiphSWHbayZp1sFM3i%3DayNV9nqB4v0UuO6ZojQvxDa-9eQa4A%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/CAC3mK7ffrtjH_eGFepRev5fE5hq7f631R1ieOyWrm%3DJyQ8UdXA%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> regards
> Tribhuvan Kishor Bhaskar
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACiphSXRrsaB%3D7NC33Eq9yzZaKramfEFvPhzx5-0WOFm0Vucdg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 


*Ousseynou Diop*
Full stack developer

TEL (+221) 77 992 99 52
Whatsapp(+221) 76 377 22 60
E-mail   mstspr1...@gmail.com

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