Re: profile page and new user will not save

2022-03-09 Thread 'Delvin Alexander' via Django users
Sorry for the late reply, but here is my signlay.py file

from django.db.models.signals import post_save
from django.contrib.auth.models import User
from django.dispatch import receiver
from .models import Profile


@receiver(post_save, sender=User)
def create_profile(sender, instance, created, **kwargs):
if created:
Profile.objects.create(user=instance)


@receiver(post_save, sender=User)
def save_profile(sender, instance, **kwargs):
instance.Profile.save()

On Wednesday, February 23, 2022 at 1:28:58 AM UTC-8 omkar...@gmail.com 
wrote:

> Something went wrong with the signals. Paste your signals.py file. 
>
> On Wed, Feb 23, 2022, 10:52 AM 'Delvin Alexander' via Django users <
> django...@googlegroups.com> wrote:
>
>> Hello Everyone,
>>
>> I am having trouble saving a new profile, and user when they are created. 
>> Upon creating a new user and profile, i get this:
>>
>> "TypeError: Profile.save() got an unexpected keyword argument 
>> 'force_insert'"
>>
>> Would anyone know why this is popping up for me
>>
>>
>> Here is my work for that particular page as well.
>>
>> from django.shortcuts import render, redirect
>> from django.contrib import messages
>> from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm
>> from django.contrib.auth.decorators import login_required
>>
>>
>> def register(request):
>> if request.method == 'POST':
>> form = UserRegisterForm(request.POST)
>> if form.is_valid():
>> form.save()
>> username = form.cleaned_data.get('username')
>> messages.success(request, f'Your Account has been created you 
>> are now able to log in {username}!')
>> return redirect('login')
>> else:
>> form = UserRegisterForm()
>> return render(request, 'users/register.html', {'form': form})
>>
>> @login_required
>> def profile(request):
>> if request.method == 'POST':
>> u_form = UserUpdateForm(request.POST, instance=request.user)
>> p_form = ProfileUpdateForm(request.POST, request.FILES, 
>> instance=request.user.profile)
>> if u_form.is_valid() and p_form.is_valid():
>> u_form.save()
>> p_form.save()
>> messages.success(request, f'Your Account has been updated!')
>> return redirect('profile')
>> else:
>> u_form = UserUpdateForm(instance=request.user)
>> p_form = ProfileUpdateForm(instance=request.user.profile)
>> 
>> context = {
>> 'u_form': u_form,
>> 'p_form': p_form,
>> }
>> 
>> return render(request, 'users/profile.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/39c57e72-9e09-403e-97db-562ef943db4an%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b7e20438-fa2d-4f72-9fa9-dfa761194c72n%40googlegroups.com.


Re: How to create dynamic models in django??

2022-03-09 Thread Ryan Nowakowski
On Sun, Feb 27, 2022 at 09:10:05AM +0530, Prashanth Patelc wrote:
> How to create dynamic models in django rest framework?
> Is there any chance to create dynamic models with APIs
> 
> Any examples please send me thanks in advance..
> 
> 1) Requirement is need create table name and fields in frontend
> 2) we are  getting the data and store in to the db create db structure
> 3) get the table name and fields create table in backend &postgresql store
> to
> 4)this code don't update or add into the models
> 5)store the data into the tables
> 4)get the data into the tables using orm or any raw queries

The WQ project uses the Entity-Attribute-Value data model:

https://v1.wq.io/1.2/docs/eav-vs-relational

-- 
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/20220309235228.GH4556%40fattuba.com.