These are chat archives for django/django

Sep 2017
Sep 18 2017 06:55

I have a question on the doc.
What does ... means in this context?
Suppose I want to use postgis, and postgis_topology extensions.

from django.contrib.postgres.operations import CreateExtension
from django.db import migrations

class Migration(migrations.Migration):

    operations = [

And put it as a one of the migration file. At any place?

Miracle Ayodele
Sep 18 2017 09:17
Hi guys, i am having issues on which pattern of views to follow
function based view or class based views and i will like some tips on why
Sep 18 2017 12:03
Are you able to connect in every select you have in your application? I am looking for systemwide solution - to replace the default.
Oğuzhan Yılmaz
Sep 18 2017 12:50
@elcolie hey, if you are using postgresql, just open up your pgAdmin and add extension there
first you should download the extension from stackbuilder
Sep 18 2017 13:13
Hey guys
class Message(models.Model):
A private directmessage
content = models.TextField(_('Content'))
sender = models.ForeignKey(AUTH_USER_MODEL, related_name='sent_dm', verbosename=("Sender"))
recipient = models.ForeignKey(AUTH_USER_MODEL, related_name='received_dm', verbosename=("Recipient"))
sentat = models.DateTimeField(("sent at"), null=True, blank=True)
readat = models.DateTimeField(("read at"), null=True, blank=True)
def unread(self):
    """returns whether the message was read or not"""
    if self.read_at is not None:
        return False
    return True

def __str__(self):
    return self.content

def save(self, **kwargs):
    if self.sender == self.recipient:
        raise ValidationError("You can't send messages to yourself")

    if not
        self.sent_at =
    super(Message, self).save(**kwargs)
<a href="{% url 'message_details' usr=contact %}">{{contact}}</a>
url(r'^messages/(?P<pk>\d+)/$', views.message_details, name='message_details')
def message_details(request, pk, usr):
conversation = Inbox.get_conversation(request.user, usr.User)
return render(request, 'blog/messages.html', {'conversation' : conversation})
def get_conversations(self, user):
    Lists all conversation-partners for a specific user
    :param user: User
    :return: Conversation list
    all_conversations = Message.objects.all().filter(Q(sender=user) | Q(recipient=user))

    contacts = []
    for conversation in all_conversations:
        if conversation.sender != user:
        elif conversation.recipient != user:

    # To abolish duplicates
    return list(set(contacts))
<a href="{% url 'message_details' usr=contact %}">{{contact}}</a>
I want to pass sender details to my from my html file
how can i do it ?
Anish Shrestha
Sep 18 2017 13:38
@flyboy1565 I absolutely got busy. Really sorry. Finally came here to ask a question.

This question pretty much sums up my problem.
The method filter does not get called.

Anyone knows the fix...