Yahoo Search Búsqueda en la Web

Resultado de búsqueda

  1. 22 de feb. de 2017 · I believe this will do the trick: results = Model.objects.filter (x=5).exclude (a=True) To answer your specific question, there is no "not equal to" field lookup but that's probably because Django has both filter and exclude methods available so you can always just switch the logic around to get the desired result.

  2. 12 de jun. de 2018 · Con frecuencia me pasa que necesito saber qué versión de Django estoy utilizando pero no consigo verlo de manera "rápida". Como trabajo con un virtualenv, tiendo a utilizar pip freeze | grep Django. Sin embargo, hay veces en que dicho virtualenv no existe, por lo que sigo con la duda. ¿Cómo sé qué versión de Django está corriendo?

  3. 24 de jun. de 2011 · It is possible that you have two different versions of Django, one for each version of python. In from a Unix/Mac terminal, you can check your Python version as follows: $ python --version. If you want to know the source: $ which python. And to check the version of Django: $ python -m django --version.

  4. The question is specifically about building a query in Django to get records with field1 = 'value1' OR field2 == 'value2'. Your answer doesn't answer the question. – Yacc

  5. 18 de mar. de 2010 · When you specify field names, you must provide an order_by () in the QuerySet, and the fields in order_by () must start with the fields in distinct (), in the same order. For example, SELECT DISTINCT ON (a) gives you the first row for each value in column a. If you don’t specify an order, you’ll get some arbitrary row.

  6. 10 de jun. de 2016 · Adding the - will order it in descending order. You can also set this by adding a default ordering to the meta of your model. This will mean that when you do a query you just do MyModel.objects.all() and it will come out in the correct order. class MyModel(models.Model): check_in = models.DateField() class Meta:

  7. 14 de jul. de 2012 · I have the following for loop in my django template displaying days. I wonder, whether it's possible to iterate a number (in the below case i) in a loop. Or do I have to store it in the database an...

  8. from django.core import serializers from django.http import HttpResponse def your_view(request): data = serializers.serialize('json', YourModel.objects.all()) return HttpResponse(data, content_type='application/json') Bonus for Vue Users. If you want to bring your Django Queryset into Vue, you can do the following. template.html

  9. 23 de may. de 2009 · STATIC_URL = '/static/'. This tells Django where to find all the static files. MEDIA_URL = '/media/'. This points Django to the folder where your images are, after it loads static. In this case it is /media/ because our images are in /static/media. next, you should put this in the individual template where you need the image (I thought putting ...

  10. 1 de dic. de 2010 · For every field that has choices set, the object will have a get_FOO_display () method, where FOO is the name of the field. This method returns the “human-readable” value of the field. In Views. person = Person.objects.filter(to_be_listed=True) context['gender'] = person.get_gender_display() In Template.

  1. Otras búsquedas realizadas