macks posteets tagged querys  [ Profile ]

Sort by: Date / Title /

  1. 4 years ago
    1. from django.db import connection
    2. q = connection.queries # todos los querys y los tiempos de respuesta
    3.  
    4. savelog(obj.query,'query')  # query de una consulta
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2084"></script>
  2. 4 years ago
    1. SELECT id,title INTO OUTFILE "c:/result.text"
    2. FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    3. LINES TERMINATED BY "n"
    4. FROM property;
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2074"></script>
  3. 4 years ago
    1. #obtener la media de tipo image que pertenezca a una noticia  (newsmodel es la tabla intermedia)
    2. image =MediaModel.objects.filter(newsmodel__id=id, type='image')
    3.  
    4. #obtener un campo especifico de una relacion
    5. news = get_object_or_404(NewsModel, id=id)
    6. media = news.media.all()
    7. filename =media.get().filename
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1932"></script>
  4. sponsorised links
  5. 4 years ago
    1. #apps/comments/models.py
    2. class Comment(models.Model):
    3.     id = models.AutoField(primary_key= True)
    4.     post = models.ForeignKey(Post)
    5.     author = models.CharField(max_length=80)
    6.  
    7. #
    8. class Post(models.Model):
    9. id = models.AutoField(primary_key=True)
    10. title = models.CharField(max_length=220)
    11.  
    12. # obteniendo las cantidad de comentarios relacionados al post
    13. from comments.models import Comments
    14. comment_count = Comments.objects.filter(post__pk = self.id).count()
    15.  
    16. #obteniendo un item por un id (equivale a un retrieveByPk($id) en symfony)
    17.  
    18. from django.shortcuts import render_to_response, get_object_or_404
    19. from blog.models import Blog
    20.  
    21. def executeEdit(request, id):
    22.     blog = get_object_or_404(Blog, id=id)
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1906"></script>
  6. 4 years ago
    1. # obtener en un objeto todos los usuario en orden descendente
    2. user = User.objects.all().order_by('-id')
    3.  
    4. #obtener los posts por el slug de la tabla relacionada blogs y el stado publicado
    5. objPost = PostsModel.objects.filter(blogs__slug = blogSlug, status='published').order_by('-published_at')
    6.  
    7. # funcion que realiza una consulta mysql (puede ser insert, update etc.)
    8. def getSelectGroup():
    9.     row = []
    10.     cursor = connection.cursor()
    11.     row = cursor.execute("SELECT auth_permission.id as id,  auth_permission.name as name
    12.                                       FROM auth_permission INNER     
    13.                                       JOIN django_content_type ON (auth_permission.content_type_id = django_content_type.id)     
    14.                                        WHERE django_content_type.model = 'usermodel' AND codename not
    15.                                        in('add_usermodel','change_usermodel','delete_usermodel')")
    16.     row = cursor.fetchall()
    17.     return row
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1905"></script>

First / Previous / Next / Last / Page 1 of 1 (5 posteets)