Re: Multiple models and a primary key

2018-02-16 Thread Michael MacIntosh
I'm not sure what you are trying to achieve, but you probably don't want all of the models to use the same primary key. You can access the primary key though via the pk or id attributes. For instance: Grade.objects.all().values("subjt_id", "subjt__pk", "subjt__profile_id", "subjt__profile__pk")

Re: Search by entering to value in JSONField PostgreSQL

2018-03-23 Thread Michael MacIntosh
Hi, Did you try SomeModel.objects.filter(data__name__contains="ar") If you want to union the results from both fields you can use a Q object: https://docs.djangoproject.com/en/2.0/topics/db/queries/#complex-lookups-with-q-objects And that would look something like: complex_query = Q(data__na

Re: Syntax error

2018-05-30 Thread Michael MacIntosh
Hi Caleb, I think there should be a comma here basic.html' {'content' so it should be basic.html', {'content' Hope that helps! On 5/30/2018 5:45 PM, Caleb Bryson wrote: I can not seem to figure out what the syntax error is in line 7 of this code, can anyone help from django.shortcuts impo

Re: Cumulative Sum per month

2020-03-11 Thread Michael Macintosh
You might want to use window functions https://docs.djangoproject.com/en/3.0/ref/models/expressions/#window-functions to calculate the sum per month.  Haven't personally used them yet though. On 3/11/2020 8:27 AM, Mario Bisiani wrote: Yes. I am using Chart.js. Any help? Il giorno giovedì 5 ma

Re: How to automatically fill out an auto increment number in form field?

2018-07-23 Thread Michael MacIntosh
Hi, Aren't you looking for the AutoField? https://docs.djangoproject.com/en/2.0/ref/models/fields/#autofield It will automatically increment based on each record added to the table. As an aside, the problem you are having is that in python, the first argument to a class is a reference to the

Re: Doubts on One-To-One Field

2018-08-30 Thread Michael MacIntosh
Hello, You are correct, creating a one-to-one relationship can potentially create more queries and hurt performance if you are not careful.  However it can also speed up certain queries if you don't need that information all of the time. If you are worried about the performance, I would sugg

Re: Renaming sequences

2019-12-18 Thread Michael MacIntosh
Hey Mike, I'm not sure about your specific setup, but I assume you are using the django.contrib.auth user model and are moving it over to your own app, and you have your own userprofile model that links to it.  The user model in django.contrib.auth is a swappable model.  Basically meaning as