Re: unique_together does not work in django 2.0

2018-01-19 Thread FernandoJMM

Hello, Problem solved. 
For it to work I have to put the META class between the silo class and the 
method. Thank you

El viernes, 19 de enero de 2018, 12:53:28 (UTC+1), Jason escribió:
>
> To be clear, you started with an empty database and the duplicate values 
> exist after adding data?
>

-- 
You received this message because you are subscribed 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/d385d85a-c87f-4742-8c75-f430048f7554%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


unique_together does not work in django 2.0

2018-01-18 Thread FernandoJMM
Hello,
I have the following class:

==
class Silo(models.Model):
nave = models.ForeignKey(Nave, on_delete=models.CASCADE)
codSil = models.CharField(
'Código Silo', db_index=True, max_length=2, default='01')
notas = models.TextField(null=True, blank=True)

def __str__(self):
return "%s %s" % (self.nave, self.codSil)

class Meta:
order_with_respect_to = 'nave'
unique_together = ('nave', 'codSil')


But the option unique_together does not work because duplicate values 
​​exist in the SQLite database for nave and codSil.

To solve it, I have to create the index nave + codSil by hand in the SQLite 
database ???

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/555b1903-b6f5-4af1-b7a2-a7921d1fdbac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Using the ModelAdmin.inlines class, there is no DELETE button

2018-01-13 Thread FernandoJMM
Good Morning,

I'm customizing the ModelAdmin class inlines attribute. The code is this.

class NaveInline(admin.TabularInline):
model = Nave
fields = ['codigoNave', 'nave', 'tipoPuesta']
ordering = ['codigoNave']
extra = 1


class GranjaAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': [('codigoGranja', 'granja'), ('empresa', 
'tipoGranja'), ('regimen')]}),
('Datos adicionales', {'fields': [('direccion', 'localidad', 
'codigoPostal', 
'provincia', 'region', 'pais', 'telefonoPrincipal', 
'telefonoMovil', 
'fax', 'email', 'ceence','cea', 'maquina', 
'clasificacionZootecnica', 
'formaDeCria', 'notas')], 'classes': ['collapse']}),
]

inlines = [NaveInline]

 

. . . . . .  



Everything works perfectly, I can add granjas / naves, edit granjas / 
naves, and clear granjas. . but I can not do it is to delete naves that in 
this case are the lines (inlines).

I do not get any errors, I can see the line selection check but the line 
deletion button DOES NOT APPEAR.

Thanks for your help,
Fernando

-- 
You received this message because you are subscribed 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/c21e2ff0-a1d0-4f83-b6c9-bc91a8d1e7e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error following django's documentation 2.0

2018-01-09 Thread FernandoJMM
Good morning,

I think the error comes from making modifications to django's settings.
I started the project again and now the django shell works.

Thanks for your interest !!!
Fernando

El sábado, 6 de enero de 2018, 7:51:01 (UTC+1), Matemática A3K escribió:
>
>
>
> On Fri, Jan 5, 2018 at 8:32 PM, FernandoJMM <fern...@lagunadeduero.com 
> > wrote:
>
>> Hello everyone,
>>
>> I'm learning django. I am in the official documentation of django link:
>>
>> *https://docs.djangoproject.com/en/2.0/intro/overview/ 
>> <https://docs.djangoproject.com/en/2.0/intro/overview/>*
>>
>> After creating the model and doing the migrate I go to the section called 
>> *Enjoy 
>> the free API* to test in the python terminal 
>>
>
> Did you get to that python terminal by "python manage.py shell" on the 
> base directory of your project?
>  
>
>> and I get an error when executing the *import*, it says that it can not 
>> find the module.
>>
>> *The only difference with the documentation* is that I am executing it 
>> from a *virtualenv*.
>>
>> it can be fixed ?
>>
>
> I think so :) 
>  
>
>>
>> Thank you all
>>
>> -- 
>> You received this message because you are subscribed 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/c9941c85-2a42-439f-8999-856507f5f74d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/c9941c85-2a42-439f-8999-856507f5f74d%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Error following django's documentation 2.0

2018-01-05 Thread FernandoJMM
Hello everyone,

I'm learning django. I am in the official documentation of django link:

*https://docs.djangoproject.com/en/2.0/intro/overview/*

After creating the model and doing the migrate I go to the section called 
*Enjoy 
the free API* to test in the python terminal and I get an error when 
executing the *import*, it says that it can not find the module.

*The only difference with the documentation* is that I am executing it from 
a *virtualenv*.

it can be fixed ?

Thank you all

-- 
You received this message because you are subscribed 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/c9941c85-2a42-439f-8999-856507f5f74d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.