I need help

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

I need help

Fadi Haddad
Hi, 

I have created a table called dataset

I put the age as integer e.g. 34, 23, 10, 47 

I need to create Age range for the age column. I need the age to be displayed as [1-10], [11,20], [21-30] ... etc. Can this happen by replacing values or do I have to create another column for this? The goal is to anonymize my dataset therefore if it is possible to replace values (age) rather than creating new column would be excellent.   

Can anyone help me how to code this in SQL? Would be appreciated if code is included in the response 

Regards

Fadi

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/79b8a25a-ce6b-4a73-9be2-d67c7d78e2ff%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

I need help

Become a Physicist
You can create a drop down menu for this.

AGE_CHOICES = (
    ('11-20','11-20'),
    ('21-30', '21-30'),
)

class MyModel(models.Model):
  color = models.CharField(max_length=6, choices=AGE_CHOICES, blank=True, null=True)

Hope this helps... 😊
With regards,
Shubham Gupta

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/dbb7403f-37d8-4f34-aa86-9f0861382964%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: I need help

Pavlos Georgiadis-2
In reply to this post by Fadi Haddad
Hi Fadi,

This is the developers mailing list dedicated to development of django itself. Questions like this should be addressed to the users mailing list.


P.S: Do a search for "django model property decorator" (there is also a cached_property decorator). It will help you find a solution.

--
Pavlos Georgiadis


On 14/08/2019 05:22, 'Fadi Haddad' via Django developers (Contributions to Django itself) wrote:
Hi, 

I have created a table called dataset

I put the age as integer e.g. 34, 23, 10, 47 

I need to create Age range for the age column. I need the age to be displayed as [1-10], [11,20], [21-30] ... etc. Can this happen by replacing values or do I have to create another column for this? The goal is to anonymize my dataset therefore if it is possible to replace values (age) rather than creating new column would be excellent.   

Can anyone help me how to code this in SQL? Would be appreciated if code is included in the response 

Regards

Fadi
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/79b8a25a-ce6b-4a73-9be2-d67c7d78e2ff%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/bc6be538-ae87-3ada-800f-a37020cc12ba%40georgiadis.eu.
Reply | Threaded
Open this post in threaded view
|

Re: I need help

Adam Johnson-2
In reply to this post by Fadi Haddad
Hi!

I think you've found the wrong mailing list for this post. This mailing list is for the development of Django itself, not for support using Django. This means the discussions of bugs and features in Django itself, rather than in your code using it. People on this list are unlikely to answer your support query with their limited time and energy. Read more on the mailing lists at https://www.djangoproject.com/community/

For support, please use the django-users mailing list, or IRC #django on Freenode, or a site like Stack Overflow. There are people out there willing to help on those channels, but they might not respond if you don't ask your question well. Stack Overflow's question guide can help you frame it well: https://stackoverflow.com/help/how-to-ask .

Also if you haven't read it, please take a look at Django's Code of Conduct: https://www.djangoproject.com/conduct/ . These are our "ground rules" for working well as a community, and will help you get the most out of Django and our fantastic community.

On your question - I think you want the SQL CASE and WHEN which are mapped in the Django ORM as the Case and When functions: https://docs.djangoproject.com/en/2.2/ref/models/conditional-expressions/

Thanks for your understanding,

Adam

On Wed, 14 Aug 2019 at 03:22, 'Fadi Haddad' via Django developers (Contributions to Django itself) <[hidden email]> wrote:
Hi, 

I have created a table called dataset

I put the age as integer e.g. 34, 23, 10, 47 

I need to create Age range for the age column. I need the age to be displayed as [1-10], [11,20], [21-30] ... etc. Can this happen by replacing values or do I have to create another column for this? The goal is to anonymize my dataset therefore if it is possible to replace values (age) rather than creating new column would be excellent.   

Can anyone help me how to code this in SQL? Would be appreciated if code is included in the response 

Regards

Fadi

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/79b8a25a-ce6b-4a73-9be2-d67c7d78e2ff%40googlegroups.com.


--
Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM10uV0Lfx2rAzFN3K95F-KwUC3TC5dsQvcehNpTtXYTwA%40mail.gmail.com.