These are chat archives for django/django

20th
Nov 2018
RAHUL KOUNDAL
@rahulkoundal
Nov 20 2018 07:04
ModuleNotFoundError: No module named 'compat' error in window 10 python 3.7
please help me error is not resolve
kpagcha
@kpagcha
Nov 20 2018 08:28
@ajostergaard yes
AJ
@ajostergaard
Nov 20 2018 08:38
Then you need to 'old school' it - remove parts of the template until you can see what is cauing the slowness... There's no magic solution - sorry.
kpagcha
@kpagcha
Nov 20 2018 08:49
I'm just confused why query time information doesn't seem to be properly included in the debug toolbar report when it is run in a template
Luke-VideoLibre
@LukeVideo
Nov 20 2018 11:27
How to slugify first + lastName ?
I found this
    def save(self, *args, **kwargs):
        self.slug = slugify(self.myfield)
        super(Mymodel, self).save(*args, **kwargs)
I would like to concatenate in the model firstNmae and LastName.
Luke-VideoLibre
@LukeVideo
Nov 20 2018 11:44
Ok so
    def save(self, *args, **kwargs):
        self.slug = slugify('%s %s' % (self.first_name, self.last_name))
        super(MyModel, self).save(*args, **kwargs)
Luke-VideoLibre
@LukeVideo
Nov 20 2018 11:49

also

    slug = models.SlugField(blank=True, null=True)

Is needed else you can't save your Model without adding by hand a slug that would be ovewriten anyways...

Anoop Sharma
@anoopshrma
Nov 20 2018 13:15
I have Created two models one contains one object that is "name" and other contains 4 . I have used ForeignKey in my second model. I save my first model data using form and when i want to fill my second form i want the name from my first model to be autofilled in my second form . As i have connected them with FOREIGNKEY
kpagcha
@kpagcha
Nov 20 2018 13:37
I am trying to do this: {{ some_collection|default_if_none:run_query_for_collection }}. The idea is that if the collection is passed from the view it will use that, otherwise it will query the database to fetch it. The problem is that default_if_none is not lazy, so run_query_for_collection will be executed anyway and the query will be run, which has a performance hit. How can I do this both elegantly and efficiently?
Luke-VideoLibre
@LukeVideo
Nov 20 2018 13:59
@anoopshrma so your first model is a key for the second. Like for a label or a tag that different "second" object could have in common?
I guess it's second.thenameofyourexternalkeyfield
AJ
@ajostergaard
Nov 20 2018 16:23
@kpagcha not sure what you mean - perhaps you're not talking about DB queries?
Luke-VideoLibre
@LukeVideo
Nov 20 2018 21:49
@ajostergaard @kpagcha Is it something like passing a object from one view to another unless it doesn't exist yet in witch case you fetch it ?