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, <
bayesalioudiawt...@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+unsubscr...@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
> <https://groups.google.com/d/msgid/django-users/8a202205-cf75-4445-9642-e995fec56833n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOzVPC_26jEEARrqmZ%3Dt%2BsLc7LQhJejyXykiNvW%2BBZLGQ%2BQH7A%40mail.gmail.com.

Reply via email to