Dmitry
No
Any model created after post request?
Michael the wolf 🐺
try print(request.POST) and check if the data is there actually
Renad
Any model created after post request?
No, I didn’t make separate app for user is that a problem?
Dmitry
No, I didn’t make separate app for user is that a problem?
I guess you use built-in user model. Can you share code of UserForm class?
Renad
I guess you use built-in user model. Can you share code of UserForm class?
from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm class UserForm(UserCreationForm): email = forms.EmailField(widget=forms.TextInput(attrs={'placeholder': 'Email Address'})) gender = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Enter your gender M for male F for female'})) date = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Enter a date'})) certificate = forms.FileField() class Meta: model = User fields = ('email', 'username', 'password1', 'password2', 'gender', 'date', 'certificate')
Dmitry
No, I didn’t make separate app for user is that a problem?
and an important question, is there input type='sumbit' in your html template?
Dmitry
what happens when you're submitting the form?
Renad
goes back to the form again
Dmitry
Nothing is printing
you tried print that out before if form.is_valid() ?
Hasan
goes back to the form again
you can use directly UserCreationForm in veiws instead of this form and fields
Renad
Any model created after post request?
from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm class UserForm(UserCreationForm): email = forms.EmailField(widget=forms.TextInput(attrs={'placeholder': 'Email Address'})) gender = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Enter your gender M for male F for female'})) date = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Enter a date'})) certificate = forms.FileField() class Meta: model = User fields = ('email', 'username', 'password1', 'password2', 'gender', 'date', 'certificate')
Hasan
you can use directly UserCreationForm in veiws instead of this form and fields
if request.method == "POST": signup_form = UserCreationForm(request.POST) if signup_form.is_valid(): signup_form.save() like this
Dmitry
I guess your form isn't valid and everything after if form.is_valid(): isn't reached. you should check which fields in user model are required and specify them in your form
Dmitry
Worked! But i need to override it and use custom fields how can i do that?
you should extend user model or create your own model and specify one to one relation
Renad
from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm class UserForm(UserCreationForm): email = forms.EmailField(widget=forms.TextInput(attrs={'placeholder': 'Email Address'})) gender = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Enter your gender M for male F for female'})) date = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Enter a date'})) certificate = forms.FileField() class Meta: model = User fields = ('email', 'username', 'password1', 'password2', 'gender', 'date', 'certificate') I already did it in here but why this isn’t correct?
Umar
in the same order?
Not necessary
Dmitry
in the same order?
https://docs.djangoproject.com/en/3.1/topics/auth/customizing/ It seems to me the easiest way to create custom Account model is to inherit the built-in user model in one to one relation. Check the "Extending the existing User model"
Umar
You can create another model say profile then link User model by onetoone relationship with profile profile will contain additional information about users
Anonymous
I'm trying to create a simple view on django but the app url is not displaying, i'm still geting the rocket home page as if i didn't include the app url. i can't find what is wrong with the code
Anonymous
I'm trying to send a screenshot of the code but is saying access denied
Anonymous
Show us your code
Doragonsureiyā
I'm trying to send a screenshot of the code but is saying access denied
To share code or error tracebacks, be considerate and use an online pasting service - here is a list of suggested sites: - https://del.dog - https://dpaste.org - https://linkode.org - https://hastebin.com - https://bin.kv2.dev If you post a wall of text message (many lines), delete it quick or you may get a warn strike.
Anonymous
'tiredapp url' from django.urls import path from . import views urlpatterns = [ path('', views.home), path('api/', views.SendLocation.as_view()) ]
Anonymous
'tiredproject url' from django.contrib import admin from django.urls import path, include urlpatterns = [ path('', include('tiredapp.urls')) ]
Anonymous
def home(request): return HttpResponse('<h1>Hello from Sylva</h1>')
Anonymous
I can't see what is wrong with the code
Anonymous
I get this error
Anonymous
Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/app/ Using the URLconf defined in warapiproject.urls, Django tried these URL patterns, in this order: admin/ The current path, app/, didn't match any of these.
Anonymous
when i try to put a slash on the app url
Anonymous
urlpatterns = [ path('app/', include('tiredapp.urls')) ]
Anonymous
There's no admin/ in the url but for some weird reason, django is seeing admin, i deleted since because i don't need it
лямбдλ
Hello, what book would you recommend for learning Django.
Mirco
Hello, what book would you recommend for learning Django.
Django for Beginners written by William Vincent or Django by example
Mirco
Doragonsureiyā
thanks
You're welcome! 😊
лямбдλ
can you advise, whether to read the book Django 3.0 Vladimir Dronov.
лямбдλ
Many thanks, I'm sorry to trouble you.
Anonymous
Favour Afenikhena: Good day I am new here I am sorry for this request but I am having an error in my django project I am using django hosts but when I am logged in . In my main domain I am not logged in . In my other subdomain
Ghorz
<form method="POST" action="">
Use print as a break point at everystep
Jerome
Get PyCharm, Support Django.
Thanks, i finally pulled the trigger for PyCharm )
Felipe
Hey guys, how u doing? I'm with a problem with the DRF pagination URLs. The requests are made from an HTTPS URL, but in the pagination the links are with HTTP. Has anyone been through something similar?
Sarxt
hello Guys
Sarxt
I need help in creating a business/ ecommerce website with django and I'm a novice
Anonymous
Django.db.utils.OperationError: no such table: AppName
Anonymous
Hello everyone
Anonymous
You, Help me please
Anonymous
What is mistake
Maybe you created this model but forgot to migrate the database
Anonymous
Django serializer responding output multiple times, the same output..I found that it's doing it for every object of that particular serializer class
Anonymous
How to resolve this
Naresh
data=xyz(parameters) response=request.post(url,data=json) return response When I tried this am getting error like Type Error 'module' object is not iterable How to solve this
Naresh
when you type(data) what do you get?
['name':'naresh','age':26] like this am getting
Agent Q
Agent Q
array
Its not in an array
Agent Q
Then?
Make it an array.
Naresh
The parameters am passing are like this {'parameters':[{ 'name':'naresh', 'age':25}]}
Naresh
Make it an array.
The parameters am passing are like this {'parameters':[{ 'name':'naresh', 'age':25}]}
Naresh
yes
When I tried it giving error dict object has no attribute dump