These are chat archives for django/django

23rd
May 2017
John
@flyboy1565
May 23 2017 04:10
Whats the design,
John
@flyboy1565
May 23 2017 04:36

lol, I meant to write whats the best design

class Store(models.Model):
    store_number = models.PositiveIntegerField(primary_key=True)
    district = models.ForeignKey('District')
    dma = models.ForeignKey('DMA')
    host_name = models.CharField(max_length=100)
    open_date = models.DateField(null=True, blank=True)
    closed_date = models.DateField(null=True, blank=True)


class District(models.Model):
    district_number = models.PositiveIntegerField(primary_key=True)
    region = models.ForeignKey('Region')
    manager_name = models.CharField(max_length=100)
    active = models.BooleanField(default=True)


class Region(models.Model):
    region_number = models.PositiveIntegerField(primary_key=True)
    manager_name = models.CharField(max_length=100)
    active = models.BooleanField(default=True)


class DMA(models.Model):
    dma_number = models.PositiveIntegerField(primary_key=True)

I plan on using Django-RestFramework... I'm going to be using mysql and postgresql databases.. (one by choice)

Palash Bauri
@bauripalash
May 23 2017 05:19
Can I use Django for commercial purpose?
John
@flyboy1565
May 23 2017 05:26
yes
Palash Bauri
@bauripalash
May 23 2017 05:33
Is there any Commercial project written with Django?
John
@flyboy1565
May 23 2017 05:53
@bauripalash http://bfy.tw/Bwlp
Roel
@roelzkie15
May 23 2017 06:51
@mulka it works perfectly for mysql :)
Kaushal Kumar
@kaushal087
May 23 2017 07:53
Django production (gunicorn, nginx , mysql ) running slower than runserver. There is no traffic on production still runs very slow. I am using EC2 t2.micro instance to host the server and S3 to host static and media files.
How can I optimise it?
Voxmundi
@Voxmundi
May 23 2017 07:55
why dony you give a try to postgres?
Its not a easy task to optimize someones server without any knowledge of its code and configuration :)
Kaushal Kumar
@kaushal087
May 23 2017 08:53
I have no idea about postgresql that's why I used MySql. If I change it to postgresql; will it become faster?
Roel
@roelzkie15
May 23 2017 09:08

@kaushal087

I have no idea about postgresql that's why I used MySql. If I change it to postgresql; will it become faster?

Probably depend on your refactoring, but django mainly uses postresql for database

nsomaru
@nsomaru
May 23 2017 13:53
@kaushal087 its not that django uses postgres, it's that the community generally recommends postgres over mysql...
Cristian Samaniego
@chrisRubiano
May 23 2017 19:36
@mulka thanks! the docs helped a lot
anyone here uses disqus with django?
Paul A. Aranguren
@Paulguren
May 23 2017 19:43
I have a bit of an issue, I am trying to display each individual post of a blog in a separate “div” of the html. Think, the home page of a magazine, that has many separate divs explaining each post so to speak. And those posts, obviously live on the database of said magazine. Now, i’m trying to replicate that, but when I call my posts, the thing that happens is that every single post is displayed in the same div. So imagine we have div1, div2 and div3 in an html document. Well, Test Post 1, Test Post 2 and, Test Post 3 are being displayed in the same div. So I basically show 9 repeated posts in 3 divs
I know that that is a cluster to understand, sorry
But I need to know how to call each post from the DB, INDIVIDUALLY, using jinja templating
because I call every single post
can someone at least point in me in the right direction?
Cristian Samaniego
@chrisRubiano
May 23 2017 19:44
can i see the loop you're using to show the posts in your template?
Paul A. Aranguren
@Paulguren
May 23 2017 19:44
sure

```# def index(request):

latest_posts = Post.objects.all().order_by('-id')

c = {'latest_posts': latest_posts, }

t = loader.get_template('home.html')

return HttpResponse(t.render(c))

```

sorry

`

def index(request):

latest_posts = Post.objects.all().order_by('-id')

c = {'latest_posts': latest_posts, }

t = loader.get_template('home.html')

return HttpResponse(t.render(c))

`

not working for some reason
the code display
Cher Scarlett
@cherscarlett
May 23 2017 19:46
you have to do the three ticks then a line break, then your code, then a line break, then three ticks
like this:
Paul A. Aranguren
@Paulguren
May 23 2017 19:47
# def index(request):
#     latest_posts = Post.objects.all().order_by('-id')
#     c = {'latest_posts': latest_posts, }
#     t = loader.get_template('home.html')
#     return HttpResponse(t.render(c))
there we go
thanks @cherstewart
Cher Scarlett
@cherscarlett
May 23 2017 19:47
np
John
@flyboy1565
May 23 2017 21:34
@Paulguren what does your template look like?