Carlos Eduardo
I supose that's the problem.
Anonymous
??
Carlos Eduardo
mmm I mean the engine fails even in localhost
Anonymous
Which database are you using
Anonymous
???
Carlos Eduardo
But we made some changes
Carlos Eduardo
And it already works in localhost.
Anonymous
Which database...?
Carlos Eduardo
Akash
If anyone has used cookiecutter-django what's the best way to change project name and domain.
I built a project template named "web" with cookiecutter-django that I want to reuse in multiple projects.
Now I want to copy it to different repo with different project name and domain.
Right now my website name is the project-slug I used. Is changing html template enough or what else I have to change?
Anonymous
how do i can access my list from database to my base.html
Anonymous
any one is there
Carlos Eduardo
just pass the object to the template that extend base.html
Carlos Eduardo
you can use it on base.html normaly
Carlos Eduardo
just take care and validate if the object exist, if you don't do it you gonna have problems in other views
Carlos Eduardo
Anonymous
Anonymous
all right let me try this
Anonymous
Hello everybody.
Help me to solve the following problem, please:
I have a queryset
SomeModel.objects.filter(~Q(info=None)).order_by('-upd')[:num]
, but when I try to access fields from there, many fields are empty (even which are not null by the database definition).
All works fine if I do
.values()
on the queryset, but then I have dicts, not objects (which is more comfortable to deal with (IDE suggestions)).
I think I need to fetch all fields explicitly from the database. But I dont know how to do it.
Paul
Hi. To existing project need to add new field to Permission from django.contrib.auth.models.
I find add_to_class, but don't know how to save it.
I need to filter values by new field(integer).
Can I save add_to_class or any suggestions?
Paul
I just need a field to filter by it permissions.
I decided to add new class with this field and with FK to Permission model.
So i can add permssions there, filter by this field and continue using Permission model
Claudio
Hi everyone, how can I ensure that when i create a table with a model, all the values are created in the table?
https://pastebin.com/zYqkdAVg
I would have all status inside the table when i create it
Андрей
Андрей
Claudio
check your migration file
I know i can make it in a migration, but can i do it automatically without having to create again the manual migration if I reset all the migrations?
Claudio
Anonymous
can i use another app model within other app templet
Андрей
Claudio
Anonymous
how
Anonymous
like 1_app.models import model_name(in 2_app)
Anonymous
like tis
Андрей
from app1.models import MyModel
Anonymous
from home.models import SecondaryMenuHome
Андрей
exactly
Anonymous
def index(request):
sec_menu = SecondaryMenuHome.objects.all()
for item in sec_menu:
Андрей
yep
Anonymous
but is not woking
Андрей
you should return the httpresponse with context
Anonymous
how
Anonymous
??
cant get
Anonymous
i want do some thing like this
Anonymous
foo_list = models.Foo.objects.all()
for foo in foo_list:
foo.non_db_property = some_method()
render_to_response('template.html', {'foo_list': foo_list})
Anonymous
but for seme change there is my model
Андрей
try
Андрей
return render(request, template, content)
Андрей
from django.shortcuts import render
Андрей
where content is your dict
Андрей
but your code looks ok
Андрей
non_db_property?
Андрей
you can use something like content =my_list = [{'model':x,'property':'123'}for x in UserProfiles.objects.all()]
Андрей
and you will have list of dicts
Андрей
just change '123' to your some_method()
Андрей
in template:
{% for c in content%}
{{c.model.your_field}}
{{c.property}}
{%endfor%}
Андрей
{% for key, value in choices.items %}
<li>{{key}} - {{value}}</li>
{% endfor %}
Anonymous
>>> Models.objects.filter(id=55)[0].id
0
>>> Models.objects.filter(id=55).values()[0]['id']
55
Someone explain me this please. I cannot understand...
Orack
if i only want to create api
Orack
is flask better or django ?
Anonymous
No
Yegor
Shubham
Hello
Shubham
With reference to the documentation, https://www.django-rest-framework.org/api-guide/authentication/#how-authentication-is-determined
I was trying to use CustomAuthToken, in my app view and import it in url
Shubham
But it giving circular import error
Shubham
my project without customAuth - https://github.com/shubham1507/school/blob/master/users/views.py
Shubham
from rest_framework.authtoken.views import ObtainAuthToken
from rest_framework.authtoken.models import Token
from rest_framework.response import Response
class CustomAuthToken(ObtainAuthToken):
def post(self, request, *args, **kwargs):
serializer = self.serializer_class(data=request.data,
context={'request': request})
serializer.is_valid(raise_exception=True)
user = serializer.validated_data['user']
token, created = Token.objects.get_or_create(user=user)
return Response({
'token': token.key,
'user_id': user.pk,
'email': user.email
})
Anonymous
Anyone know how to update the is_confirmed element in serailizer
Mirco
GraphQL
?
You are a bit confused
Mohit
Any knows how to implement connection pooling in Sqlalchemy ?
Orack
has anyone used django-shop ?
Orack
how is it
Mirco
ಶಶಾಂಕ್
How to connect multiple database in django