Re: Error at OneToOneField in models while creating new models class

2018-09-23 Thread Adolfo Cueto
First you have to change your model name Class names starts with 
uppercase...

My friend.. you are not making migrations... look at you have to do this:


1. Delete your migration folder
2. Delete you app table manually (DROP table)
3. python manage.py makemigrations app_name
4. migrate

that's all

El sábado, 22 de septiembre de 2018, 4:10:45 (UTC-5), Srinivas Gadi 
escribió:
>
> HI All,
>
> I am facing below error while creating a new model class.
> the error pop up only at this line "user = models.OneToOneField(User)"
> *"E1120:No value for argument 'on_delete' in constructor call"*
>
> from django.db import models
> from django.contrib.auth.models import User
>
> class userProfile(models.Model):
> user = models.OneToOneField(User)
>
> If I add "user = models.OneToOneField(User,*on_delete=models.CASCADE*)" 
> the error got subsided but the new class "userProfile" is not appearing 
> in admin page, under Users tab.
>
> Could some one please guide me how to fix this ?
>
> -- 
> Srinivas .G
>   9966559383
>

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


Re: Django 1.9.8 with mysql 'Commands out of sync; you can't run this command now' exception

2018-09-23 Thread Adolfo Cueto
Hey man try to change you code line like this

latest_message = Message.objects.filter(example_field=1).order_by("-id").first()


El dom., 23 sept. 2018 a las 22:55,  escribió:

> I am a python developer and I am using Django 1.9.8 for my project.
> I am having a problem with MySQL like below:
>
> I have a model named 'Message' and sometimes when running this code, I got
> the exception 'Commands out of sync; you can't run this command now'
>
> latest_message = 
> Message.objects.order_by("-id").filter(example_field=1).first()
>
> can you point out to me why does it happen and how to fix it?
> thanks,
> Thanh Tran
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/740fac2d-3399-45d3-bd96-54a76e7f2335%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/CA%2Bb6%2BDB4twJgnubgZL1NOnf2X85yCEp3czUhmwkiq-E8oUApcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.9.8 with mysql 'Commands out of sync; you can't run this command now' exception

2018-09-23 Thread Adolfo Cueto
i know it, that problem ocurred when mysql is being used by other
process... so you can add  CONN_MAX_AGE: 0 in your conection string... and
also try to use a diferent database and avoid to use multi threading
processes

El dom., 23 sept. 2018 a las 23:41,  escribió:

> Thank you so much Adolfo. I know your code is the best practice but are
> you sure your code will solve the problem?
>
> On Monday, September 24, 2018 at 11:13:14 AM UTC+7, Adolfo Cueto wrote:
>>
>> Hey man try to change you code line like this
>>
>> latest_message = 
>> Message.objects.filter(example_field=1).order_by("-id").first()
>>
>>
>> El dom., 23 sept. 2018 a las 22:55,  escribió:
>>
>>> I am a python developer and I am using Django 1.9.8 for my project.
>>> I am having a problem with MySQL like below:
>>>
>>> I have a model named 'Message' and sometimes when running this code, I
>>> got the exception 'Commands out of sync; you can't run this command now'
>>>
>>> latest_message = 
>>> Message.objects.order_by("-id").filter(example_field=1).first()
>>>
>>> can you point out to me why does it happen and how to fix it?
>>> thanks,
>>> Thanh Tran
>>>
>>> --
>>> You received this message because you are subscribed 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/740fac2d-3399-45d3-bd96-54a76e7f2335%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/740fac2d-3399-45d3-bd96-54a76e7f2335%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/eea6b14a-e6d7-4777-a214-a51b86b89431%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/eea6b14a-e6d7-4777-a214-a51b86b89431%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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