Mirco
Code
Sarthak
could 2 or more compute engines running Django apps use the same domain name and how?
Ghorz
Ghorz
isa
Mirco
Thanks :)
I strongly suggest you to try django-q , it's one of the best atm
Less headaches etc. etc.
It has redis as broker by default
isa
Ç
Wang
Wang
Ç
if you want to do so, you can build init(self,. ..) method for modelform.
Anonymous
Ç
Firstly, call. super().__init__(), then self.fields['text'].Widget.attrs(...)
Ç
But it is not good experience
Wang
Mirco
Anonymous
b
i am getting this error-
b
django.db.utils.OperationalError: no such column: todolist_items.time_created
Anonymous
Anonymous
Did you python manage.py migrate?
b
yes I did, multiple time
b
error still appears
b
actually, I added a field in models
b
then this happened
Muflone
joe did you made one of these things?
1) removed your migration files?
2) applied changes to your db (eg using sql)?
b
no
b
I added a new field in model
Muflone
do you have that field in your migrations files?
Muflone
in particular in the last file
b
yes
b
it's there
Muflone
is it in the latest migration file?
b
yes
b
it's there
Muflone
then you deleted the migration file before
Muflone
unapply it and apply it again
b
I never deleted the files
Muflone
paste your python migrate.py showmigrations (using a pastebin)
b
nevermind, code runs now
Muflone
...
b
no it doesn't
b
wait I'm
b
# Generated by Django 3.0.5 on 2020-05-01 15:04
import datetime
from django.db import migrations, models
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
('todolist', '0008_remove_items_time'),
]
operations = [
migrations.AddField(
model_name='items',
name='time_created',
field=models.DateTimeField(auto_now_add=True, default=datetime.datetime(2020, 5, 1, 15, 4, 27, 135609, tzinfo=utc)),
preserve_default=False,
),
]
Muflone
what dbms are you using?
b
default
Muflone
echo 'select * from django_migrations ORDER BY id DESC limit 5' | sqlite3 default.db
b
what's this
Muflone
it will get the latest 5 migrations from your default.db
b
do I run this in prompt ?
Muflone
are you using linux?
b
no
b
windows
Salohiddin Yoqubov
class Question ....
class Answer (models.Model):
question = models.Foreignkey......
How can I get unanswered questions using Question.objects.annotate?
Muflone
windows hasn't the sqlite command line.
open the db using a db explorer
Muflone
windows
as an alternative, unapply your migration and apply it again
python manage.py YOUR_APP LATEST_NUMBER-1
George
George
😄
Муродали
hi guys
how to know the object id number pair or odd that coming from database
Martin
hai guys
Martin
ho we can add a new button in admin panel in django
Muflone
Martin
Gil
in home admin page
https://docs.djangoproject.com/en/3.0/ref/contrib/admin/#overriding-admin-templates
George
Муродали
for exmaple i used :
{% if post.id%2==1 %}
<div>odd number</div>
{% else %}
<div>pair number</div>
{% endif %}
Муродали
George
where is my mistake
probably signs are used differently on the templates , you should check how to do arithmetic in your engine.
maybe its %% instead of % of there is a is_pair function.
Муродали
George
Let me 🦆 DuckDuckGo that for you:
🔎 djanjo template arithmetic
Муродали
class MyModel(models.Model):
int_1 = models.IntegerField()
int_2 = models.IntegerField()
result = MyModel.objects.annotate(
diff=F(int_1) + F(int_2)
).filter(diff__gte=5)
@hyunlee1o consider it?
George
Муродали
Муродали
do u know