Sheshadri
class ValeForm(forms.ModelForm): class Meta: model = Vale fields = ['producto', 'cantidad']
Two ways : 1. password1 = forms.CharField(label=_("Password"), widget=forms.PasswordInput) 2. class Meta: model = Model fields = ('all') widgets = { 'some_field': autocomplete.ModelSelect2(url='somedata'), }
Anonymous
Not visible in where?
The patient.html page
Anonymous
{% for i in obj %} <a href="{% url 'remove' pk=i.pk %}" class="list-group-item">{{i.first_name}}</a> {% endfor %}
Anonymous
This didn't work?
Yes..list is not showing
Shihasz
Yes..list is not showing
You are passing context as 'names' itself. Change obj to names here(here only)
Daro
is there any way to implement how a form is rendered to html???
Shihasz
Didnt get u
You are totally confusing urself u have passed {'names':obj} as context to template. So template can access 'names' variable only that holds objects
Anonymous
You are totally confusing urself u have passed {'names':obj} as context to template. So template can access 'names' variable only that holds objects
{% for i in names %} <a href="{% url 'remove' pk=i.pk %}" class="list-group-item">{{i.first_name}}</a> {% endfor %}
Anton
Sheshadri dude, i find out, that reverse for my app working if i don't use kwargs argument in reverse(). But if i'm use it, than Noreversematch calls
Anton
Hey guys, can you help me? When i transfer dict to kwargs in reverse func (reverse('view-path-name', kwargs={'text':'hello'})) i get error 'Noreversematch, can't find view', but if i delete kwargs all is working. Who have ideas why?
Future
Hello everyone I'm doing API registration using restauth and get this error "CRC Failed: CSRF token missing or incorrect."tell me why
Future
did everything as on https://django-rest-auth.readthedocs.io/en/latest/installation.html#registration-optional
Anonymous
You are totally confusing urself u have passed {'names':obj} as context to template. So template can access 'names' variable only that holds objects
List is rendering properly but remove obj function is giving error `ValueError at /remove/^(?P16\d+)/$ First argument to get_object_or_404() must be a Model, Manager, or QuerySet, not 'WSGIRequest'.`
Anonymous
`def removeObj(pk): object = get_object_or_404(Patient,pk) object.delete()`
Anonymous
like this ?
Shihasz
def removeObj(request, pk): object = get_object_or_404(Patient,pk) object.delete()
Anonymous
def removeObj(request, pk): object = get_object_or_404(Patient,pk) object.delete()
its throwing Cannot resolve keyword '1' into field. Choices are: age, detail, first_name, id, last_name, numvisit, user, user_id
Luis
Hello! I'm trying to do my first Django project and I think that I need to do my sqlite database in memory in order to insert a lot of data in a few seconds. If I configure the database with: 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), All works fine, but I'm tried to put: 'NAME': 'file::memory:' And syncdb works properly, after that the tables are not accesibles or not exist. Any help please??
cj
also why do you want a inmemory database?, Django does it automatically for running tests if your primary DB is sqlite3, but that's for running tests only, not for "production" things
Luis
The full command is: >python manage.py migrate --run-syncdb. Django version 3.04
Luis
It is because I need to work with the data but persistence does not matter. Performance is more important.
cj
It is because I need to work with the data but persistence does not matter. Performance is more important.
then use PostgreSQL : https://www.postgresql.org/docs/12/non-durability.html
cj
I will search about it, thank you for your help!!
that link I sent you has the information you're looking for
Shihasz
https://pastebin.com/gFnGVkV7
In patient model , 'user' field is referring to primary key of the user. So use user=request.user.pk in filter method u have used to retrieve objects
Shihasz
done but still same error
Still u repeating same mistake in the view, passing names to template
Anonymous
I have a "Course" model for courses, what is the best way to get users to get courses after purchase? I am creating a platform for courses, and I arrived at the part where I have to make the user have access to the course after purchase, we will leave all other subjects as a means of payment etc out of the subject. I just want to know what is the best way to give the user access to the course. Should I just create an FK and add the user to the list after purchase? Or should I tweak something to do with Django groups and permissions?
Aravinda
from django.views.generic import DeleteView Class PersonDeleteView(DeleteView): template_name = "carljohnson.html" queryset = Person.objects.all() can we delete without using DeleteView?
Aravinda
Why not ?
Can you explain me bro?
Mirco
Can you explain me bro?
First I'm not your bro 😊 Second you can just call delete() of Django ORM
Mirco
DeleteView is there to help u don't reinvent the wheel and write less code
Aravinda
First I'm not your bro 😊 Second you can just call delete() of Django ORM
data = Person.object.get(id=id_data) data.delete() return redirect(tosomewhere) Like this right
Aravinda
Ok😇
Mirco
But you have to consider relations too For example if Person has a PROTECTED relation instead of CASCADE or SET NULL , that delete will raise an exception
Mirco
You have to delete carefully
__init__
How to solve "Incorrect type: Expected pk value, received str."
__init__
Where I try to save multiple object at once in rest framework
Anders (izzno / gooood) 🇳🇴
Interested in python development? This is something you should not miss. https://realpython.com/free-courses-march-2020
Anders (izzno / gooood) 🇳🇴
(Not commercial, free content)
Anders (izzno / gooood) 🇳🇴
I learned to package my app for pypi using this resource
Yes, Dan has a great deal of resources, and I like the way he/they dont assume any knowledge in any tutorial.
Ghorz
Yes, Dan has a great deal of resources, and I like the way he/they dont assume any knowledge in any tutorial.
I also used his/their to learn how to build android apps with python (Kivy) and Django celery
Anders (izzno / gooood) 🇳🇴
I also used his/their to learn how to build android apps with python (Kivy) and Django celery
That's great. Now I know this channel is not for small talk so go join Python Offtopic for more interesting conversations ;).
Anders (izzno / gooood) 🇳🇴
Anonymous
Hey guys how to get instagram news feed in django
Anonymous
To my website in a simple way
©aptain
Hey guys how to get instagram news feed in django
I don't know if I anyone is allowed to give link but to help you I am pasting it maybe helpful to you https://www.digitalocean.com/community/tutorials/django-authentication-with-facebook-instagram-and-linkedin https://django-social-widgets.readthedocs.io/en/latest/
Anonymous
Anyone have python django in visual studio tutorials...?
Anonymous
`def removeObj(request,userid): object = Patient.objects.filter(user=userid) object.delete() return render(request,"pages/patients.html")` All my objects are getting deleted with this code I think its because a user has same user id , what parameter should I use so that my objects dont get deleted
Sheshadri
Why are you using userid ? You should be using id of the patient object
Anonymous
Why are you using userid ? You should be using id of the patient object
I tried using pk but its error `TypeError at /remove/30/ 'int' object is not iterable`
Sheshadri
change your path to path("remove/<int:pk>",removeObj,name="remove"),
Sheshadri
path("remove/<int:pk>/",removeObj,name="remove"),
Sheshadri
def removeObj(request, pk): object = Patient.objects.get(pk=pk) object.delete()
Sheshadri
def removeObj(request, pk): obj = Patient.objects.get(pk=pk) obj.delete()
Sheshadri
object maybe a reserved keyword
Aneesh
{%url 'index'%} not working properly
Aneesh
Please help