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.