Tuesday, December 7, 2021

Re: Display api in particular format

Can you make the image an attachment ? Cant see anything on your image.

On Saturday, 27 November 2021 at 23:00:41 UTC+5:30 Sapna Agrahari wrote:
Can anyone please help me with this? As I want to display the api data in this format.
image.png
------------------------
Thanks and Regards ,
Sapna Agrahari

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d56792fe-3636-4dd6-bf8f-92dac0a17783n%40googlegroups.com.

Re: How to update part of a JSONField with a computed value?

Use the inbuilt json library in python. Use json.dumps and json.loads
to convert the dictionary to json and vice versa.
On Thursday, 5 August 2021 at 04:17:38 UTC+5:30 shahee...@gmail.com wrote:
Hi,

I'm using Django 3.2 on Postgres12, and I have a model with a JSONField which contains a simple dict (actually, a Django formset :-)). I would like to update just one value in the dict. I can get this to work when the new value is a hardcoded numeric 333 (quoted, as seems to be needed) like this:
    pay_items.update(inputs=JSONBSet('inputs', ['inputs-0-value'], Value("333"), True))
where JSONBSet is a Func, as indicated below. However, I'd like to actually compute the value. I've tried a variety of things, without success. Here is one attempt:

    pay_items.update(inputs=JSONBSet('inputs', ['inputs-0-value'],
Cast(F('inputs__inputs-0-value'), FloatField()) + Value("3"),
True))

This fails like this:

ERROR:  function jsonb_set(jsonb, unknown, double precision, boolean) does not exist at character 42
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
STATEMENT:  UPDATE "paiyroll_payitem" SET "inputs" = JSONB_SET("paiyroll_payitem"."inputs", '{inputs-0-value}', (CAST(("paiyroll_payitem"."inputs" -> 'inputs-0-value') AS double precision) + '3'), true) WHERE "paiyroll_payitem"."id" IN (...))


I've tried all sorts of variants with Cast, ExpressionWrapper and so on to no avail, so I'd be grateful for any shove in the right direction!

Thanks, Shaheed

Encls: implementation of JSONBSet derived from https://code.djangoproject.com/ticket/32519 and related threads:
class JSONBSet(Func):
function = 'JSONB_SET'
arity = 4
output_field = CharField()

def __init__(self, field, path, value, create: bool = True):
path = Value('{{{0}}}'.format(','.join(path)))
create = Value(create)
super().__init__(field, path, value, create)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3f2eb04c-3a7f-4bf8-bdf7-7fa787b2fe18n%40googlegroups.com.

Monday, December 6, 2021

Re: Student Management System kin Django

Eugene,

Your question is very broad. The combination of the business logic for the student management system plus database normalization best practices will result in the right database schema for this platform.
Example business logic :
- User must have a B or higher to be eligible to move to the next grade or auto upgraded to the next grade
- User can be upgraded to the next grade but will not be eligible to enroll if the account balance for the prior year is not zero

Some of the business rules will guide your database design/model creation.

You need to be able to do the above resulting in an ERD which you can then share and someone can then offer additional feedback.


On Monday, December 6, 2021 at 3:35:53 AM UTC-7 eugenet...@gmail.com wrote:
Dear Gilwell,

That is where I want an idea. I do not understand how I do the diagram.

Thanks 

On Mon, 6 Dec 2021 at 12:30, Gilwell Muhati <gilw...@gmail.com> wrote:
Hello @Eugene
What does your ERD diagram look like? - Please share the diagram 

Regards,

Gilwell Muhati | +254 710 739 116 |

~~"The mind is its own place and in itself can make a heaven of hell, a hell of heaven…"~~John Milton


On Mon, Dec 6, 2021 at 1:14 PM Eugene TUYIZERE <eugenet...@gmail.com> wrote:
Dear Team,

I am developing a student management system and I am stuck at the point below which I need your idea.

I need to record school fees every semester and promote a student from one level (year) to the next level every year. Like 1st Year to second year.

How can I achieve this to avoid data duplication in the database.

Regards, 

--
Eugene

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABxpZHubDPpuLt5bfpD10FWinnBSjZLT6sJs717NXzqhiThFWg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.


--
TUYIZERE Eugene

Msc Degree in Mathematical Science

African Institute for Mathematical Sciences (AIMS Cameroon)
Crystal Garden-Lime, Cameroon


Bsc in Computer Science

UR-Nyagatare Campus

Email: eugene....@aims-cameroon.org
           eugenet...@gmail.com

Tel: (+250) 7 88 26 33 38, (+250) 7 22 26 33 38

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c07ec2bf-4012-4fde-9577-cca8fa35db5dn%40googlegroups.com.

Student Management System kin Django

Dear Team,

I am developing a student management system and I am stuck at the point below which I need your idea.

I need to record school fees every semester and promote a student from one level (year) to the next level every year. Like 1st Year to second year.

How can I achieve this to avoid data duplication in the database.

Regards, 

--
Eugene

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABxpZHubDPpuLt5bfpD10FWinnBSjZLT6sJs717NXzqhiThFWg%40mail.gmail.com.

Sunday, December 5, 2021

Re: could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?

hey,
i am facing the same problem
can you please guide me on how to solve that issue ???

On Thursday, 16 May, 2019 at 6:38:01 pm UTC+5:30 randmw...@gmail.com wrote:
First, you should not share your password to your server to anyone….thats very dangerous.  Now anyone can log in to your server with nefarious intentions.  
Be more careful.

But it sounds like something on the server is blocking your connection.  

On May 16, 2019, at 8:57 AM, omar ahmed <omark...@gmail.com> wrote:

hii ..
i try to publish my first project on python anywhere but it still not working and this is my error :

could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

and this is my db settings  :

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'arena',
        'USER': 'arenadbuser',
        'PASSWORD': 'mlo9**@la',
        'HOST': 'localhost',
        'PORT': '',
    }
}

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/93204eb8-f5e3-43bf-98ff-b79478bce544%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7b66cbaf-e069-48db-ae46-8fea37c3644an%40googlegroups.com.

Friday, December 3, 2021

Re: for loop + transaction.on_commit + celery = Unexpected Behaviour

This is an older topic, but for everyone who found this discusion and had the same issue: The problem is most likely using "lambda" inside a for-loop. If you switch out "lambda" for "functools.partial" it should work as expected.
Jani Tiainen schrieb am Donnerstag, 27. April 2017 um 08:27:11 UTC+2:

Hi,

I think your problem is to use POST['_models_changed']. Django uses specialized version of dictionary there which return _last_ value from list. You need to use special "get_list()" method to get whole list of objects.

Your code should start working if you do data['_models_changed'].get_list()  in a for-loop.

Also, why you modify request.POST instead of adding class attribute?


On 24.04.2017 14:37, Emilio Jimenez Canalejo wrote:
Hi, I've been looking for some time around the internet a problem I have, maybe I'm just dull from all the searching and the answer is pretty obvious, but I can't find it.

For example, I have code like this:
@app.task
def foo(idx):
   
print("This is iteration {}".format(idx))

def save_model(self, request, obj, form, change):
    data = request.POST
    result = super(Model, self).save_model(request, obj, form, change)

   
for pk in data['_models_changed']:
        transaction
.on_commit(lambda: foo(pk))

To my astonishment, I thought I would get:
"This is iteration 1"
"This is iteration 2"
"This is iteration 3"
"This is iteration 4"

But I got:
"This is iteration 4"
"This is iteration 4"
"This is iteration 4"
"This is iteration 4"

I'm using python 2.7, Django 1.10.5 and Celery 4.0.2.

'models_changed' is a field in the post added by a custom clean method.

Anyone knows a way to do this?

Thanks for all!
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/91e87fb4-69e2-4b4e-bd6b-704eb7567026%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--   Jani Tiainen

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2cfba61c-e78a-45c5-87b7-e0cbbdc09165n%40googlegroups.com.

Wednesday, December 1, 2021

Re: return or not from super().method(*args, **kwargs)

Hi Carles,

return super(...) is better. Because if the base class decides to return a value sometime in the future, you are all set.

Uri.


On Wed, Dec 1, 2021 at 12:14 AM Carles Pina i Estany <carles@pina.cat> wrote:

Hi django-users,

I have a a question that I don't know where to send. Since it happened
programming in Django and I usually read this list I thought of sending
it here.  I would like to ask if someone has strong feelings or if I
have missed some styling documentation.

This could be a generic Python styling question when re-implementing a
method of a base class. The example below is for models.Model.

Let's say that you had a model such as:

class Person(models.Model):
    name = models.CharField(max_length=100)

    def save(self, *args, **kwargs):
        # some things...

        # Question: do you do:
        super().save(*args, **kwargs)

        # or do you:
        return super().save(*args, **kwargs)

Currently Model.save() returns None.

My thoughts:
-"return super().save(*args, **kwargs)":
 -Good: if some day the base class changes and starts returning
 something: the sub-class is forward-compatible :-)
 -Good: less thinking when implementing the derived method: just do the
 return always instead of having to check the base class method
 -Bad: a reader might assume that Person.save() returns a value (instead of None)
 -?: I haven't looked yet if I could add type hints for the return value of the the sub-class method saying "same as the base class".

-"super().save(*args, **kwargs)":
 -Good: it's clear for the reader that nothing is returned
 -Easy to do the type hints "-> None" if used in the project

Any thoughts? What would you prefer to see?

Currently I tend to go for the "super().save(*args, **kwargs)" (no
unnecessary return) as done in the Django documentation and to be
explicit in the present (it doesn't return anything)... but I have my
own doubts :-)

Part of this happened when I was reading some code and I thought that I
was in a "save()" for a form but I was in the model. For the form I need
to not forget the "return".

Thanks for any thoughts / comments :-)

Cheers,

--
Carles Pina i Estany
https://carles.pina.cat

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20211130221344.GA15295%40pina.cat.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABD5YeHG0jb6JyF%3D3det5-LQAZAgxC2ivqAScx1USVS8G8nfdg%40mail.gmail.com.