Tuesday, September 26, 2023

Re: FieldError at /ajouter_centre Cannot resolve keyword 'name' into field. Choices are: categorie, centredeformation, date_de_crea, id

J'ai finalement résolu le problème. Merci bien!! 

Le lundi 25 septembre 2023 à 20:35:25 UTC, Muhammed Lawal a écrit :
Have you confirmed there is a 'name' field in your CentreCategorie and Region models? 

On Mon, 25 Sep 2023, 5:44 p.m. Baye SALIOU DIAW, <bayesalio...@gmail.com> wrote:
def ajouterCentre(request):
    form = FormCentre()
    regions = Region.objects.all()
    centrecategories = CentreCategorie.objects.all()
    if request.method == 'POST':

       
        categorie_name = request.POST.get('categorie')
        categorie, created = CentreCategorie.objects.get_or_create(name=categorie_name)

        region_name = request.POST.get('region')
        region, created = Region.objects.get_or_create(name=region_name)
       
        CentreDeFormation.objects.create(
            categorie=request.categorie,
            region = region,
            nom = request.POST.get('nom'),
            description = request.POST.get('description'),
            adresse = request.POST.get('adresse'),
            telephone = request.POST.get('telephone'),
        )

        return redirect('home')


    context = {
        'form': form,
        'regions': regions,
        'centrecategories': centrecategories,
    }
    return render(request, 'blog/ajoutercentre.html', context)

--
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/8a202205-cf75-4445-9642-e995fec56833n%40googlegroups.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/84da2aca-062f-4c10-9f7f-4bdf3e48c0ffn%40googlegroups.com.

Monday, September 25, 2023

Re: Unit test to make sure correct template is returned from a specific URL?

-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wnUEARYKACcFgmURjiwJkFrvKC74ta6lFiEEXOYF9uqFRn4815bYWu8oLvi1
rqUAAGK6AQC5voAdz4FN0N0nyyTLxrh8g1Mmrwvn4UsyA9iLHAMUKwD/SG//
jDXxnVK7ioGbUadJsjV4sk15EsZvh5kdVBuJ6Ak=
=n1eD
-----END PGP SIGNATURE-----

Thank you very much!

------- Original Message -------
On Monday, September 25th, 2023 at 14:07, Muhammad Juwaini Abdul Rahman <juwaini@gmail.com> wrote:


On Sun, 24 Sept 2023 at 22:37, 'Simon Connah' via Django users <django-users@googlegroups.com> wrote:
I can write a unit test which checks say the title on a page and compares it to a string but that is really prone to breakage. What I want to do instead is to check that the template that is returned by the URL is the same one that is expected in the unit test. Is there an easy way to do this?

--
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/MnCVU2YvJzLiFdMPPAVBwMY7SMosqS5wvqopbySnD05i7BTc375v_Bo5GB4VlUQSd5K2OwsiblAbxsfsz7in96L4_Ou4RTRm0jwVN3aMp54%3D%40protonmail.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFKhtoRiz4mr69ZLu7_wCxVFXgjnvmAW3JCoYdcDrx%2Bwu94vrw%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/O_3E4w3kT2FE_XgQrWGfQFM_DcKq_syuWJ0eEuZ0zJfIPnZ6rzbF80z28SORLG9r7rik-evYNQhGnchpIcEDOP9zqIX9n_xOntOTHDAbv4M%3D%40protonmail.com.

Sunday, September 24, 2023

Re: Mysql for Django

Download MySQL server at https://dev.mysql.com/downloads/mysql/
It will most likely come with mysqlclient but if not, you can download mysqlclient using homebrew, `brew install mysql-client`.

Best regards. 

On Mon, 25 Sep 2023, 1:46 a.m. DieHardMan 300, <keenusuwannabut@gmail.com> wrote:
Do you mean you can't use mysqlclient with Django? Do you already install homebrew in MAC? Do you already install mysql server using homebrew?
ในวันที่ วันจันทร์ที่ 25 กันยายน ค.ศ. 2023 เวลา 3 นาฬิกา 50 นาที 25 วินาที UTC+7 Lakhjeet Samra เขียนว่า:
Hi Guys, 
I am new to Django
I use Mac ,
 I am unable to down mysqlclient  for Django project any suggestions 
I have Mysql workbench installed  Is it right.

Thank You
Lakhjeet

--
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/051ed6a3-574f-4813-b976-0b82b0480019n%40googlegroups.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOzVPC8si2XByA_WMO08oJuvBXvtDSqyengsOidmTrdd6MpVBw%40mail.gmail.com.

Re: Mysql for Django

Yes absolutely you can use it , what kind of error have u faced?


On Mon, 25 Sept 2023 at 03:46, DieHardMan 300 <keenusuwannabut@gmail.com> wrote:
Do you mean you can't use mysqlclient with Django? Do you already install homebrew in MAC? Do you already install mysql server using homebrew?
ในวันที่ วันจันทร์ที่ 25 กันยายน ค.ศ. 2023 เวลา 3 นาฬิกา 50 นาที 25 วินาที UTC+7 Lakhjeet Samra เขียนว่า:
Hi Guys, 
I am new to Django
I use Mac ,
 I am unable to down mysqlclient  for Django project any suggestions 
I have Mysql workbench installed  Is it right.

Thank You
Lakhjeet

--
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/051ed6a3-574f-4813-b976-0b82b0480019n%40googlegroups.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAET2c5-Z3szAwgqyTq1uUegKUjRzfO02ucV%2BZ_BSMo6TMt6aWA%40mail.gmail.com.

Re: Mysql for Django

Do you mean you can't use mysqlclient with Django? Do you already install homebrew in MAC? Do you already install mysql server using homebrew?
ในวันที่ วันจันทร์ที่ 25 กันยายน ค.ศ. 2023 เวลา 3 นาฬิกา 50 นาที 25 วินาที UTC+7 Lakhjeet Samra เขียนว่า:
Hi Guys, 
I am new to Django
I use Mac ,
 I am unable to down mysqlclient  for Django project any suggestions 
I have Mysql workbench installed  Is it right.

Thank You
Lakhjeet

--
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/051ed6a3-574f-4813-b976-0b82b0480019n%40googlegroups.com.

Re: Mysql for Django

Hello,

in Linux and Mac you can use DBeaver https://dbeaver.io/download/

This is great app for administration of all DBMS.

Regards

Am So., 24. Sept. 2023 um 22:50 Uhr schrieb Lakhjeet Samra <lakh09@gmail.com>:
Hi Guys, 
I am new to Django
I use Mac ,
 I am unable to down mysqlclient  for Django project any suggestions 
I have Mysql workbench installed  Is it right.

Thank You
Lakhjeet

--
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/f49a52f5-2786-4695-b98d-c0fe1f091797n%40googlegroups.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKGT9myv%3D8i2-7dNihKvD2r%3DjK_WZnqBLw8JqyZ-zWd336uFyg%40mail.gmail.com.

Mysql for Django

Hi Guys, 
I am new to Django
I use Mac ,
 I am unable to down mysqlclient  for Django project any suggestions 
I have Mysql workbench installed  Is it right.

Thank You
Lakhjeet

--
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/f49a52f5-2786-4695-b98d-c0fe1f091797n%40googlegroups.com.

Saturday, September 23, 2023

Re: help me


On Sun, Sep 24, 2023 at 12:14 AM Akoo Rahimi <akoo.rahimi1371@gmail.com> wrote:
Hello friends

Can you introduce me some sites similar to Heroku?

I just started Django and I want to test my projects on the global server.

--
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/dccab8c0-8d51-4338-a085-300fdfc0eeadn%40googlegroups.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFB6YJrmzsa8ReiikRC2q3vs8VCkpNQZ0mrvqPLLvmrzaq8FiQ%40mail.gmail.com.

Monday, September 18, 2023

RE: Splitting views.py and urls.py into a directory rather than single files

I like the following method because it lets me start a project with a single file of views per app and then later when it grows, split it into named files in a 'views' directory - without needing to adjust other code which imports them.

1. Create a views directory in the app dir

2. Create __init__.py in the new directory

3. Move the monster views.py into ./views renaming it to original.py or something similar.

4. Split original.py into as many useful individual views files as desired - including separate utilities file(s) etc.

5. In __init__.py import each view used by your urls.py using lines like ...

   from .filename import ViewName

Obviously, multiple views can be grouped into the same file so long as they are imported into views.__init__.py

6. In urls.py you can then say ...

    import appname.views as appname_views

... if that's not what you do already!


--
(Unsigned mail from my phone)



-------- Original message --------
From: 'Simon Connah' via Django users <django-users@googlegroups.com>
Date: 18/9/23 22:27 (GMT+10:00)
To: django-users@googlegroups.com
Subject: Splitting views.py and urls.py into a directory rather than single files

Hi,

I have an app which has a lot of views and URLs and keeping them in just one file makes it really hard to manage because it is so long. I'd like to make a views and URLs folder which will allow me to break up views and URLs into different categories but I'm not sure what the best way to go about doing that is.

Can someone point me in the right direction please?

Thank you!

Simon.

--
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/4svI0xN0uu53BvHzhG9Aa1qvI61v1qPlQOhkOLpaJPRXX1Jysfu-BOmrFlBsDOfHfKRHwTaXJNmKFApZ1W13jQLdpVvXQDEPdWq87T-ILR8%3D%40protonmail.com.

Re: Splitting views.py and urls.py into a directory rather than single files

-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wnUEARYKACcFgmUISZkJkFrvKC74ta6lFiEEXOYF9uqFRn4815bYWu8oLvi1
rqUAAF+/AQC3jcooIkaXpSEwPx+sPEKUrkF+l54VH/nJjnOi6q75VgEAoZsl
SNqzTpBNH/n3JEVTKI3Soub3OoJDBKHivkYuIgo=
=UU2z
-----END PGP SIGNATURE-----

Thank you! That got it working!

------- Original Message -------
On Monday, September 18th, 2023 at 13:34, Asim Sulehria <de.asimhabib@gmail.com> wrote:

You can just directly declare an array of URL Patterns in a separate file and then import that file in the url files you want to make the main urls file

On Mon, Sep 18, 2023 at 5:28 PM 'Simon Connah' via Django users <django-users@googlegroups.com> wrote:
Hi,

I have an app which has a lot of views and URLs and keeping them in just one file makes it really hard to manage because it is so long. I'd like to make a views and URLs folder which will allow me to break up views and URLs into different categories but I'm not sure what the best way to go about doing that is.

Can someone point me in the right direction please?

Thank you!

Simon.

--
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/4svI0xN0uu53BvHzhG9Aa1qvI61v1qPlQOhkOLpaJPRXX1Jysfu-BOmrFlBsDOfHfKRHwTaXJNmKFApZ1W13jQLdpVvXQDEPdWq87T-ILR8%3D%40protonmail.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPz57eGK6EXPGObGH5-ej3OPGvEmox%2BkR34xW3Eg1weWQug%3Dcw%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d3_jwrhlaNWhn-_QfIOhopznbSi5o3e5tF5p-pF34iqaGFRRBVFScOg6PL95XWeJIBV6JpmQpXg0L0FcGNH9fjM5CItLGCZ8mIoJqNxEohU%3D%40protonmail.com.

Splitting views.py and urls.py into a directory rather than single files

-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wnUEARYKACcFgmUIQgIJkFrvKC74ta6lFiEEXOYF9uqFRn4815bYWu8oLvi1
rqUAAH1eAP0a5qqApOgpQRRQLrOY5ZkyBzKlgQRRiqbr/JpvzrTeIgD9GqH2
MvUmzUv7PlngGlqP/6pAhiW8j3zmOF0IMcJGGww=
=I1LF
-----END PGP SIGNATURE-----

Hi,

I have an app which has a lot of views and URLs and keeping them in just one file makes it really hard to manage because it is so long. I'd like to make a views and URLs folder which will allow me to break up views and URLs into different categories but I'm not sure what the best way to go about doing that is.

Can someone point me in the right direction please?

Thank you!

Simon.

--
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/4svI0xN0uu53BvHzhG9Aa1qvI61v1qPlQOhkOLpaJPRXX1Jysfu-BOmrFlBsDOfHfKRHwTaXJNmKFApZ1W13jQLdpVvXQDEPdWq87T-ILR8%3D%40protonmail.com.

Sunday, September 10, 2023

Re: What to learn after Django, Node.js or React?1

On 10/09/2023 4:40 pm, abu yahya Diab wrote:
Hi guys, 

I'm a django developer(junior), do you advice me to learn Node.js, or React to be full Stack developer.

Neither. At least not before you have looked at HTMX


Thanks.
Abdulrahman --
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/c11fd593-2a62-4501-998e-d247ed452b28n%40googlegroups.com.


--   Signed email is an absolute defence against phishing. This email has  been signed with my private key. If you import my public key you can  automatically decrypt my signature and be sure it came from me. Your  email software can handle signing.  

Thursday, September 7, 2023

Re: pytest, asgiref, Selenium and database access? How to make them work?

install pytest-django
use fixture @pytest.mark.db
profit

On 5 September 2023 at 08:15:10, Alfons Eberle (alfons.signup@gmail.com) wrote:

Hey, has anyone gotten pytest to work with django-channels (or asgiref + Daphne) and Selenium in general when database access is required?

My fixtures for users and other models import just fine, but my browser and Daphne process seem to be unaware of the test database and seem unable to create them. Frontend errors out with the classic pytest django.db.utils.OperationalError: connection to server at "127.0.0.1", port 5432 failed: FATAL: database "test2" does not exist

I am using a Daphne test server implementation I found on SO + GitHub here: https://github.com/pytest-dev/pytest-django/issues/1027

Here's some sample code I have for reference. channels_live_server is from the implementation above. Doing this simply shows the yellow Django error page with the error above.
I have tried explicitly creating the database, which gets rid of the error, trying to e.g. log in via the admin but it still does not cause the database to fill with any data. It's like they are in two different worlds (threads).

All my other pytests run fine.

Any ideas? Thanks


@pytest.fixture
def authenticated_browser_staff(channels_live_server, client):
    """Return a browser instance with logged-in user session."""
    options = webdriver.ChromeOptions()
    browser_ = webdriver.Chrome(options=options)
    user_staff = User.objects.create(
        email='test@foo.bar', 
        password=make_password('hunter42'),
        is_superuser=True
    ) # usually a fixture, but easier to share like this
    print('staff id', user_staff.id)  # works as expected

    client.force_login(user_staff)  # works and returns the session ID
    print('cookie', client.cookies[settings.SESSION_COOKIE_NAME].value)

    browser.get(channels_live_server.url + "/admin/")
    browser.add_cookie({
        'name': settings.SESSION_COOKIE_NAME,
        'value': client.cookies[settings.SESSION_COOKIE_NAME].value,
        #'expires': None,
        #'secure': False,
        #'path': '/'
    })
    # server responds with setting sessionid to empty
    browser.refresh()

    # trying to log in, since passing the cookie does not 
    # work, but errors out with user does not exist
    browser.find_element('name', 'username').send_keys(user_staff.email)
    browser.find_element('name', 'password').send_keys('hunter42')
    browser.find_element(By.CSS_SELECTOR, "input[type='submit']").click()

    assert any(c for c in browser.get_cookies() if c['name'] == settings.SESSION_COOKIE_NAME)
    return browser



--
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/7281f73c-dcbb-418f-acf1-dd4f5f065cc9n%40googlegroups.com.

Monday, September 4, 2023

Re: Django language support

On Mon, Sep 04, 2023 at 01:02:24AM -0700, SUNIL PATEL wrote:
> i want to build app for hindi marathi bengali udia tamil etc native
> languages of india.Does Django provide this?if not than how can i achieve
> this with django

Check out https://docs.djangoproject.com/en/4.2/topics/i18n/

--
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/20230904163327.GB16181%40fattuba.com.

Thursday, August 31, 2023

Re: ANYONE TO HELP ME ON HOW TO CREATE AN AUTOMATIC NOTIFICATION SYSTEM THAT SENDS A MESSAGE WHENEVER AN OBJECT IS CREATED OR MODIFIED

First of all - notification - what do you mean by notification?

If you mean that the user should be notified in the instance when someone creates / updates / deletes your models - you will need to have either server side events or websockets to communicate with the frontend. You could also poll the server (for example every 5 minutes) to check for new messages. These solutions would require that you have some javascript on the frontend.

To get this working on the backend - you would then need some sort of changes in the save method to send the notifications to the frontend. This could be as simple as creating a Notification model and then just creating a notification every time you update a model.

Regards,

Andréas


Den tis 22 aug. 2023 kl 16:02 skrev Byansi Samuel <samuelbyansi87@gmail.com>:

My views
from django.shortcuts import render def auto_notification(request): return render (request, "user/dashboard.html")

My models
from django.db import models from django.contrib.auth.models import User

#articles model

class Articles(models.Model):
title = models.CharField(max_length=300) date= models.DateField() author=models.ForeignKey(User, on_delete=models.CASCADE) body=models.TextField()

def __str__(self) -> str:
return self.title

#games model

GAME_TYPE=( ("action", "action"), ("adventure", "adventure"), ("racing", "racing"), ("puzzle", "puzzle"), )

MOV_TYPE=( ("action", "action"), ("adventure", "adventure"), ("sci-fi", "sci-fi"), ("horror", "horror"), ("drama", "drama"), )

GAME_OS=( ("Windows", "Windows"), ("Android", "Android"), )

class Games(models.Model): name=models.CharField(max_length=50) type=models.CharField(max_length=40, choices=GAME_TYPE) os=models.CharField(max_length=15, choices=GAME_OS) img=models.ImageField() developer=models.CharField(max_length=50) version=models.CharField(max_length=10) ratings=models.CharField(max_length=10) description=models.TextField()

def __str__(self) -> str:
return self.name class

Movies(models.Model): name=models.CharField(max_length=50) type=models.CharField(max_length=40, choices=MOV_TYPE) description=models.TextField() released=models.DateField()

def __str__(self) -> str:
return self.name

I have three models below, but l like to create a Notification System to send a message to a User whenever ;
1. An object is created in all those models
2. An object is modified in all those models

And l would like to add trick that it sends the Notification Message after 15 minutes of publiction or creation.

And I would like to pass the following data if available in the object ;
1. the Name of the Object,
2. the Image of the Object, and
3. the type of the Object.

Lastly I would like to add a :
1. Notification DELETE function, that gives User a way to delete that Message , not to appear in his or notification section again.

2. Mark as Read function, that changes the Massage Div Color

3. A notification Barge that displays the UNREAD Messages.

Am requesting anyone to help me Because Am stuck , I have no where to Start from. I will be on waiting your guidelines.

--
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/CAGQoQ3wRpg%2BcT69wqUbapHbK7KSEfwU%2BxfJ-EKRCcddY6KwtnA%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCdBb5kP_eF4_CK4F%2B3ibP_PvmgJetrGJs4a7PBZfxSYGg%40mail.gmail.com.

Re: Django Resolve Choices Class

If you want the string instead of the value, you just use:
entity.get_gender_display()

Django automatically adds these "magic methods" when you have fields that have choices.

You can see this in the documentation:

Regards,

Andréas


Den ons 30 aug. 2023 kl 22:11 skrev sebasti...@gmail.com <sebastian.jung2@gmail.com>:
I have in my 

model.py:

class GendersChoices(models.IntegerChoices):
    M = 0, _('Male')
    F = 1, _('Female')
    N = 2, _('Gender Neutral')

class Address(models.Model):
gender = models.PositiveSmallIntegerField(choices=GendersChoices.choices, blank=True, default=GendersChoices.F, null=True,verbose_name=_('Gender'))

Now i have a entity from Address and when i make entity.gender i get a number from database. But i want when in entity are insert 2 then i want to get _('Gender Neutral') instead of 2

How i can do that?

--
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/53c122e7-0448-4d67-9cd4-ce11ffa2ef5cn%40googlegroups.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCcCrg-VtCdJDFRicqY0WpvNw28SMRR3tAzvaUro69gurw%40mail.gmail.com.

Re: My first Django project

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsDNBGBJfrABDACxIFOMQIsP94wTkgf76JEHyTITmYnprsTeRmDet01G5etZ9ZHm
RmrqYVFzXu1aSBbaejm/ppbRrBB7YmFETbpnZepWJnuhridvjV37duRH3g/9ppiy
tNkhOOIYA/l8ppvyaRlrp/jPjAm27HVxi1Nu0syaWwTFKbUTtLKldIhuWvAXkgxp
xyBdB3jfmKo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Z
BHO6KilQ+QLzSektD8IpHM7tR6P+5PP6AQ==
=NePe
-----END PGP PUBLIC KEY BLOCK-----
-----BEGIN PGP SIGNATURE-----

wsD5BAABCAAjFiEEuaZZAb5bdA+ohQ4u5dnKxkqqVesFAmTwShAFAwAAAAAACgkQ5dnKxkqqVetx
Agv/bBy+2VdE4CRrHZiK/8cstuSpOJDPUfTIkRiVOXl//widScwEYVTU4o/xpyl4mmr32Hwm5wwz
hbEHf/qJCNxcUZKn6neHMXwHjzvmjxpo4kYNNPfZnR/UAxG1hMgUDAoJIxqoi+Iu4G4M5YXxyt9A
sn13r9JtC8eeN/G9y47SXB2+6DcG/G0TaIX7ie0/sUuqDezeINu/icu3/BASfS0z/BVaBf8sVqz5
C7Aiil9P6DZBCxYvIPlCjeK3cbTnj1gA3rJWGaRMqYejXQUdr/tEFzhhWcaUQd/2rJoVBUTqBlFf
BWWgpCoR7i7h4i96H7YELvKz7yK7lcesxZOIfJAhamDOVB27XtJ1M29BVzPtgmagwm06kjm3RXe7
RvD5gM0TbJNOIv10ATVz0DwxPm2VcQKK3HnCEnkX2zoUFdhnoLOcLOwoiBOnJgUzWpq0jvZDeOgS
BrhIwdYo3L3PVL332KeoFyLbuEcBgNqVnckDcf6vjwewftPbAvM5dgzZwZWQ
=lY+r
-----END PGP SIGNATURE-----
On 29/08/2023 10.52, Noah Dara wrote:
>
> hi I'm new in Django I need your help my project is retirning the
> following in theterminal PS C:\Users\user\projects> &
> C:/Users/user/.virtualenvs/projects-O4ZjmZLG/Scripts/Activate.ps1
> & : File
> C:\Users\user\.virtualenvs\projects-O4ZjmZLG\Scripts\Activate.ps1 cannot
> be loaded
> because running scripts is disabled on this system. For more
> information, see
> about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

This is not related to Django but related to Powershell on Windows. Have
you tried reading the information in the link above where it says "for
more information"? That would probably be a good start.

Also don't hijack other threads but start your own instead.

Thanks and kind regards,
Kasper Laudrup

--
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/f8f3b7bd-1dd9-4c91-9170-ff5283e1d60b%40stacktrace.dk.

Monday, August 28, 2023

Re: How to create an individual instagram message into threads?

I've not used that app but creating email of messaging chains is quite easy. How I normally do it is to generate a unique identifier by using a uuid4 plus some custom values when a new thread/conversation is created and then this is passed and maintained during replies.  There's probably something similar in that app. Emails tend to call it a Conversation ID

On Sunday, 27 August 2023 at 22:19:46 UTC+1 Ram wrote:
Hi,

We are using Instagram clone messaging in our ecommerce application where users contact each other about market place item (sell/buy items). Once the messaging started between two users on an item
1. we want to keep the further messaging regarding that item to be continued like an email thread so that all the messaging about that item will be in one thread.
2. New messaging on new market place item will be again new thread.
3. It would be nice each thread has a title of the market place item so that same users can go back to previous history of messages on that particular item whenever they want.

I'm wondering whether anyone has implemented the above features using instagram clone in your Django application?

Best regards,
~Ram

--
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/099349c1-bfc4-42e8-8178-50141c7640d0n%40googlegroups.com.

Sunday, August 27, 2023

Re: How to access gmail

-----BEGIN PGP PUBLIC KEY BLOCK-----

xsDNBGBJfrABDACxIFOMQIsP94wTkgf76JEHyTITmYnprsTeRmDet01G5etZ9ZHm
RmrqYVFzXu1aSBbaejm/ppbRrBB7YmFETbpnZepWJnuhridvjV37duRH3g/9ppiy
tNkhOOIYA/l8ppvyaRlrp/jPjAm27HVxi1Nu0syaWwTFKbUTtLKldIhuWvAXkgxp
xyBdB3jfmKoJ4rvTzZU+saKgaFExRmdd5TptwRP9cPRWIoR5fcRA8RQ1X66NkIpl
VBbH7NeLuTtICAa0dnyTh50x+Wapu1kDEWmr8ssUzf6c8yBJAHKBohQowZmQ8sYt
w2h4gX0zT4V3TY9y8TvTFGhPlM7l5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AACgkQ5dnKxkqqVeta
4wv/RNPmr/xfshyMNO/iSwYyzhFnIZhhQVm3KqF8Zr3A+/+uHRqtsktp3R050e+3mWu43snPrx8L
EE8gUi/AIZXrmFBWCiyUIkvK8PmO4uJpNeAHmV7bL+dmGX7O/6F2rYcqsq+KVt0AMjKT/gIwuskL
PD7s75d98dZ86q15d/DxWwvcGFcNZdCjxO9zKKRhFwZiUgM/XiLx+nEfbjrynJEBqE+4uK84jXck
PhkNeEqEnspuNhWQreioSPUp2M59ji0FrIXpG4IWujG67o3XVbF2JszJ2nnPd/Q6nSZlbZSH0ipb
NEFe+6b6JmrgCijTABxBulBKjOHvmn+IjNUbIm2Uf015/TG+jnK1vAVR2vQuXKVw70Ot9sY93EQI
3L76yt2OzrGif/1EfIemecFyKuCR0yTiRIvVbmeLNHdEdRFixU1Xh43nUjYqzO/0Pk2LnINq1xIq
z2Oh7VrrsPmjpUCm+lmP8dMsGZcVWjML0k828Kx7BzVloUEvQ2PKh0yLuoL4
=eta8
-----END PGP SIGNATURE-----
On 26/08/2023 13.59, TASLIMA S wrote:
>
> Dear friends,
> I am developing an email signature web application.
> How to access gmail mails to my application.
>

https://developers.google.com/gmail/api/guides

Kind regards,
Kasper Laudrup

--
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/2e0feaab-2b9d-4901-9546-299a81e5ac3e%40stacktrace.dk.

Re: UpdateView and DeleteView

-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wnUEARYKACcFgmTrCnoJkFrvKC74ta6lFiEEXOYF9uqFRn4815bYWu8oLvi1
rqUAAHD6AP4wuIwRXTjN3RwKZrkmbmkchDYKNj8QggwXfNhI1bke1AEAgqum
bKbtyz2gKRDV51XqZqVoKgAv3kAa1mAPTX2xBAI=
=C5BF
-----END PGP SIGNATURE-----

Will do! Thank you for your help.

------- Original Message -------
On Saturday, August 26th, 2023 at 19:30, Ruby <dev.rubyshell@gmail.com> wrote:

I'm glad it worked out,
Consider using LoginRequiredMixin to ensure that current user is authenticated before accessing the view.


On Sat, Aug 26, 2023, 16:23 'Simon Connah' via Django users <django-users@googlegroups.com> wrote:
Thank you! That is very helpful.

------- Original Message -------
On Saturday, August 26th, 2023 at 14:07, Ruby <dev.rubyshell@gmail.com> wrote:

You can simply set a test case using the built-in user passes test (https://docs.djangoproject.com/en/4.2/topics/auth/default/#django.contrib.auth.decorators.user_passes_test)

On Sat, Aug 26, 2023, 11:20 'Simon Connah' via Django users <django-users@googlegroups.com> wrote:
I want to make sure that the only people who can update and delete an object are either superusers or the person that originally created them but I'm not sure how to go about doing it. Can someone point me in the right direction?

I'm not sure which method(s) to override.

Thank you.


--
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/iT1fh6Btk96LInLjgvQNNIOeqZTL6TMcV5IbsAmfVdnR1ujaNPCbV_zhJeXr5o7emCHzK_BHnYDtyxQ1ZJVu7oDGqyDRkJirWsaGto-5bbA%3D%40protonmail.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUD46vM6PEJK4btLa-DCF8-VvExdnJ2OpzB0-Z6h03CVWvzOg%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/nMbslf1DnsTi42UmcaQZjvuHxoVVxPQapPAABp-aN5zswI1iBp61YS-J9IwUsRPyTb_87IJsY5rMktNRS9h6rY57zUjT_4fJzdSU8Dxuiec%3D%40protonmail.com.

Saturday, August 26, 2023

Re: Unable to display records in form

Share your your templates as well


On August 21, 2023 12:23:35 AM CDT, GLOBAL ENGINEERING ACADEMY <geakylm@gmail.com> wrote:
Hai, 
I am trying to learn django on my own. I have created a small project of a shop. I am able to insert items but when i try to fetch items for updating / deleting, the form is not populated . only the primary key is shown.
 def updatedeleteitem(request):
    item=None
    updatedeleteform=None
    if request.method=='POST':
        keysearchform=KeysearchForm(request.POST)
        if keysearchform.is_valid():
            itemcode=keysearchform.cleaned_data['itemcode']
            try:
                item=Item.objects.get(itemcode=itemcode)
                updatedeleteform=UpdatedeleteForm(request.POST, instance=item)
                           
                if updatedeleteform.is_valid():
                    updatedeleteform.save()
                    transaction.commit()
                    return redirect('itemlist')
            except Item.DoesNotExist:
                pass
    else:
        keysearchform=KeysearchForm()
       
    return render(request,'updatedeleteitem.html',
                  {'keysearchform' : keysearchform,
                   'updatedeleteform' : updatedeleteform, 'item' : item})
___________________________________________________________________
class UpdatedeleteForm(forms.ModelForm):
    class Meta:
        model=Item
        fields=['itemcode', 'itemname', 'unitpr', 'qty']
       
class KeysearchForm(forms.Form):
    itemcode=forms.CharField(label='item code', max_length=5)
   

These are the view & Forms I am using. Please help.
 

UpdateView and DeleteView

-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wnUEARYKACcFgmTp0YkJkFrvKC74ta6lFiEEXOYF9uqFRn4815bYWu8oLvi1
rqUAALfUAP9IXS8CSOvH/BwW5tcVfXTgT2YTWrVx5WcLK9ol8uby3QD+JnK7
i4+jcEjZvdfJBQ0H6EfllzQvwYYCos/KLHh2dg4=
=TFwU
-----END PGP SIGNATURE-----

I want to make sure that the only people who can update and delete an object are either superusers or the person that originally created them but I'm not sure how to go about doing it. Can someone point me in the right direction?

I'm not sure which method(s) to override.

Thank you.

--
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/RC50Lr8yv1j7M_cjvPHLpvLJ1RzHJP3QQaF5oQu4vAmfeijfMbprfVyyHGTIvg9udwKhe_-XcM9tYH9tRyaX-MDQauXKf3PiJbMOq2hEfj4%3D%40protonmail.com.

Wednesday, August 23, 2023

Re: Error while showing detailed post

Hi Raghavan,

Thank you so much for the response, 

I have fixed the issue, But still facing one issue in uploading images while adding the post, 

I have created one model for the post 
class post(models.Model):
   
    title=models.CharField(max_length=200)
    author=models.CharField(max_length=100)
    Discription=models.CharField(max_length=350)
    Detailed_post=models.CharField(max_length=1500)
    img=models.ImageField(upload_to='media')
    def __str__(self):
        return self.title

And the I user model form to display the from in frontend 

class postForm(ModelForm):
    class Meta:
        model=post
        fields=["title",'author','Discription', 'Detailed_post','img']      
        widgets = {
            'title': TextInput(attrs={'class': 'input-name', 'style':'width:400px; '}),
            'author':TextInput(attrs={'class': 'input-author', 'style':'width:400px; '}),
            'Discription':Textarea(attrs={'class': 'input-Discription', 'style':'width:400px; '}),
            'Detailed_post':Textarea(attrs={'class': 'input-Detailed_post', 'style':'width:400px; '}),
           
        }




and my view is  
def add_post(request):
    if request.method=="POST":
        form=postForm(request.POST)
       
        if form.is_valid():
            form.save()
            return redirect('/News_post')
        else:  
            return HttpResponse("<h1>There is some Error your Post is not added</h1>")
    else:
        form=postForm()
    return render(request, 'add_post.html',{'form':form})


When submitting the form it's aware of hitting the else part, and when i remove the img its works fine





Thanks & Regard Dhiraj Kumar
Mobile No. : 9643843355, EXT: 250




On Tue, Aug 22, 2023 at 9:59 PM Mvd Raghava <mvdr20@gmail.com> wrote:
what issue are you facing. please send the error

On Sat, Aug 19, 2023 at 9:03 PM Dhiraj Kumar <dhiraj@nimbusitsolutions.com> wrote:
Hi new in Django, 

I want to display details post to the template but facing issue while trying to fetch post by id on the click of Continue Reading
Views.py

def show(request, id):
    print(id)
    try:
        showPost = post.objects.get(id=id)  # Assuming your model is named 'post'
    except post.DoesNotExist:
        # Handle the case where the post with the given ID doesn't exist
        raise Http404("Post does not exist")

    return render(request, 'show_post.html', {'showPost': showPost})




Urls.py 
from django.urls import path
from news import views
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('',views.home, name='home' ),
    path('about', views.about, name="about"),
    path('contact', views.contact, name="contact"),
    path('News_post', views.News_post, name='News_post'),
    path('add_post',views.add_post,name='add_post'),
    path('show/<int:id>/', views.show, name='show')

]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)










Thanks & Regard Dhiraj Kumar
Mobile No. : 9643843355, EXT: 250


--
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/CAAdfw9TdfFir%2BiFUyGxAhzWLdpDCtfSZr2ZPhi7DJrUauJUn-w%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFfOSBnje%3DqkUBaa8ZFrLLZ7Fme7-DWE-px1LpbT06b3yvmHKg%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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAdfw9S3MpiBeebBRaO62kEkWg_wj82KY56C2zEpJn82L3kTvw%40mail.gmail.com.

Tuesday, August 22, 2023

Re: AWS Polly w/ strictly Django and Javascript

Since Polly is an AWS service, you can use boto, the standard Python library:

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/polly.html


On August 14, 2023 4:26:09 PM CDT, Lightning Bit <thelegendofearthreturns@gmail.com> wrote:
Hello, how could one go about integrating AWS Polly voices onto a website utilizing only Django, HTML, CSS, and Javascript? I do not want to use "node.js" or "react". 


Saturday, August 19, 2023

Error while showing detailed post

Hi new in Django, 

I want to display details post to the template but facing issue while trying to fetch post by id on the click of Continue Reading
Views.py

def show(request, id):
    print(id)
    try:
        showPost = post.objects.get(id=id)  # Assuming your model is named 'post'
    except post.DoesNotExist:
        # Handle the case where the post with the given ID doesn't exist
        raise Http404("Post does not exist")

    return render(request, 'show_post.html', {'showPost': showPost})




Urls.py 
from django.urls import path
from news import views
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('',views.home, name='home' ),
    path('about', views.about, name="about"),
    path('contact', views.contact, name="contact"),
    path('News_post', views.News_post, name='News_post'),
    path('add_post',views.add_post,name='add_post'),
    path('show/<int:id>/', views.show, name='show')

]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)










Thanks & Regard Dhiraj Kumar
Mobile No. : 9643843355, EXT: 250


--
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/CAAdfw9TdfFir%2BiFUyGxAhzWLdpDCtfSZr2ZPhi7DJrUauJUn-w%40mail.gmail.com.