Anonymous
?
Manish
How to call model class in view .py method?? Actually I want to save a value in the a class field from form view
Manish
I have imported class but I couldn't save field value in field of a class method
Manish
Models.py class Post (models.model): post = models.CharField() Forms.py class HomeForm(forms.Form): post = forms.CharField(label='Post) Views.py from .model import Post def post_blog(request): if request.method == 'POST': form=HomeForm(request.POST) if form.is_valid(): n = form.cleaned_data['post'] t = Post(post=n) #I am getting an issue here I could not save the string of n in the post field
Anonymous
In this example you don’t need to add post to form But you can use save=form.save(commit=True) save.post=post save.save()
Manish
Yo.. thanks man.. 😊
Wang
Yo.. thanks man.. 😊
maybe you can do that if form.is_valid(): form.save() return redirect('/path')
Arun
How to link function in views as link under href tag html
Wang
How to link function in views as link under href tag html
use name of url add app_label for example view names home_page app names blog in templelate {% url 'blog:home_page' %}
Wang
<a href="{% url 'blog:home_page' %}">home page view</a>
Mirkənan
Hey chat, I have this model: class AppUser(TimeStampedModel): ....... notifications = models.ForeignKey( "UserNotifications", on_delete=models.CASCADE, null=True, blank=True ) ........ I want to implement function something like this; def send_notf(notification): firebase_send_notf(notification) for every_user in AppUser objects: every_user.update(UserNotificationsForeignKey(notification))
Mirkənan
how do I do that?
Mirkənan
the bottom one is pseudocode
Adiziel
Hey anybody can tell how to handle multiple types of user, for eg. A website with admin ,teachers and student users, admin can access all information in panel but when teacher and student login through website, teacher see their stuff and students their and also everybody's profile is different based on their activities, Plz consider this I'm a beginner
Adiziel
you have groups
Can u plz point me to some for help over internet
Muflone
Can u plz point me to some for help over internet
I have not a link here. just open google e write django users groups
Adiziel
Ok thanks 👍 for the hint
LORD
Is it possible ? I have to calculate value of hash or want to decrypt the hash using python and i have no more power to decrypt it for more time or low GPU power , and i want that i will upload the hash on server and server will calculate my hash and it will send to my mail , i have Django in intermediate level . So i can do ?
Pritam
Hey, can anyone please give me a resource or something so that I can understand the role of clean function in ModelForm like how we validate it and use this function.
Sarthak
I want to see the logs as seen when you python manage.py runserver I have uploaded project on compute engine + gunicorn + nginx
Sarthak
dpaste.org/qAOy
Sarthak
this code is giving integrity error after every first run
Sarthak
for new user
Sarthak
🆘
Mirco
dpaste.org/qAOy
Why don't u use DRF instead of creating views with json response ?
Sarthak
DRF? If I am not wrong u are saying form fields, just because everything was setup this way
Mirco
And variables like u_ and up_ are very uglies user and user_profile are much better honestly
Mirco
Django Rest Framework
Sarthak
can you be more specific
Mirco
!search
Doragonsureiyā
Step 1: Open a browser Step 2: Write down https://google.com or https://duck.com and press Enter Step 3: In the search box write down the same words you asked here Step 4: Read the firsts results
Sarthak
drf where in the response?
Mirco
The first result and you have DRF docs
Sarthak
instead of JSONresponse
Mirco
drf where in the response?
Yes, Django Rest Framework already does what you are writing and you can save lots of code
SNIR
are there any packages on drag&drop for ManytoMany field?
Sarthak
i have a small code base, it doesn't pinch me but the integrity error does
Sarthak
thoughts there
Mirco
Follow what I'm suggesting to u
Mirco
And then share the traceback if you wanna a real help
Sarthak
ok
Mirco
IntegrityError means all and means nothing if you don't share traceback I bet you have when you save the user profile And study Django signals as well, it's very common to use them to create user profiles instead of how you did
Mirco
You are not using the power of Django about not reinventing the wheel 😁
Sarthak
😄
Sarthak
how to see the traceback, its running on compute engine, gunicorn
Mirco
You have error logs if you correctly configured gunicorn
Mirco
If you know it's an IntegrityError, you are looking at the traceback
Sarthak
postman
Mirco
You have all the traceback sent by Django
Sarthak
no
Mirco
Yes
Mirco
Otherwise you wouldn't know it's an IntegrityError
Sarthak
Ah
Diego
Does anyone know how can i create a calendar/price/status on DRF? So the user can set for the selected day a especific price and status?
Sarthak
so thankful
Anonymous
Yes
Bro lookout my issue please
Anonymous
Ash: How to get template variable value in JavaScript???? Like I have to acces the entered value in {{form.product}} In JavaScript
ㅤㅤㅤ
In scripts tag
Anonymous
How?
Izbash
dpaste.org/qAOy
Maybe I junior at Django, but for which reason on 21 line between token and underscore comma used for?
Sarthak
Unused variable
Sarthak
it returns 2 things maybe
Sarthak
i am also junior
Sarthak
Micro can tell
Sarthak
Micro I found it, I have been creating the same user .... again at each login
Shivam
Can anyone help with a good book to learn django restframework and API, although I'm trying to find pdf of "Django for APIs: Build web APIs with Python and Django by William S. Vincent", If anyone have this book then please share or any other good book for drf and api
Mirco
Bro lookout my issue please
I'm not your bro
saran
*use
Mirco
?