techy
Which best website to study Django
New to Django? here is some resources to start Official docs tutorial Django Girls simpleisbetterthancomplex.com Mozilla Developer Network #videos thenewboston sentdex #books Django by Example Tango with Django Two Scoops of Django Django ORM Cookbook
Naveen
I will recommend #netninja video on Django..really simple
Oğuzhan
Hey I created a module Schedule for booking which contains date and day field . And I want to remove all module objects which contains dates before today automatically.
Instead data loss I suggest you to adding a new field which is Boolean type and I would set its default value to 1 and instead deleting object. You want to update object’s value from 1 to 0.
007
Exception Value: Cannot assign "'Lead'": "CustomerProfile.status_level" must be a "CustomerEnquiryStatus" instance. url :- https://dpaste.de/iFA7#L8
007
How to solve this issue ?
Oğuzhan
status_level because of this is foreign key you can not do that
Oğuzhan
You need to send a data which should be an id to it
007
Means ? But status_level is charfield
Oğuzhan
Yes
Oğuzhan
You need to convert it as charfield
007
Can you share me the code , how to save text to status_level ?
krishna
Hello, I just started learning django I am trying to upload an image which saves to db and it should show image in UI as well. It is saving to db.but the image is not showing inthe ui
krishna
Can any one guide me to show the image in ui
Oğuzhan
Did image appear when you upload?
krishna
Did you check your static or media url settings?
Yes it is uploading to media folder
Anonymous
hello i have a few questions
Mirco
Yes it is uploading to media folder
Show your code, it's faster than ask you thousands questions
Anonymous
how can i not let users see login and signup form after they have loogin successfully ?
Oğuzhan
In template?
Anonymous
i did that and but when i put in the login url it still show the form even thou am logged in
Oğuzhan
In view you should consider login_required decorator
007
Did you try? What I said?
I'm not getting you , so give me idea in code format
Anonymous
ok
krishna
that is my views.py code
Mirco
Use pastebin or similar pls Read ⬇️
krishna
sorry
krishna
def uploadimg(request): if request.method == 'POST': form = imgForm(request.POST,request.FILES) if form.is_valid(): #image = request.FILES['image'] img = request.FILES.get('image') form.save() return render(request,'sucess.html',{'img':img}) else: form = imgForm() return render(request,'index.html',{'form':form})
krishna
that si my views code to save and show image
Oğuzhan
This is not related with your code problem is your url.
Oğuzhan
I mean your problem
krishna
<img src="{{ img }}" />
krishna
that si how i am calling in html page
Oğuzhan
Where you save your image? What is the path?
krishna
media folder
krishna
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/'
Сергей
can anyone help me with this error OSError: cannot identify image file my.jpg image exist by I recieve this error I use python3 django and wanna open image by from PIL import Image
krishna
no its not working
krishna
when i upload image train.png it is changing name to train_ytafsy.png
krishna
is that the issue?
Сергей
how can I save image to image field from file system programstecly?
Anonymous
this is my code
Anonymous
We cannot help ya until you don't send your code
{% if not request.user.is_authenticated %} <div class="link-btn"> <a href="{% url 'login' %}" class="btn-style-one">LogIn</a> <a href="{% url 'register' %}" class="btn-style-one">Signup</a> {% else %} <a href="{% url 'logout' %}" class="btn-style-one">LogOut</a> {% endif %}
Mirco
You need to check it into your views as well and redirect user where you want to
Mirco
ok how can i do that in my views ?
By checking if request.user.is_authenticated 😊
Anonymous
ok
Mirco
ok
Try to let templates just display data, make your logic into views/models
Anonymous
ok thank you
Mirco
ok thank you
Yw 😊
Anupam
Please can anyone suggest links to better understand usercreationform concept.
Anonymous
Hey, I am creating a doctor appointment app in which I create a Schedule Model which contains date field and Boolean field. Boolean field shows that date field is older than today or not and I want to check all schedule objects in every 24 hours and update its Boolean field automatically. Ex. I just created a schedule object with date value 14 June and I want tomorrow to change Boolean field of all schedule objects automatically
GOD OF THUNDER ️
Hii
Guilherme
This is my suggestion.
GOD OF THUNDER ️
Anyone help mi for create chatbot
Guilherme
Or you can use async requests inside your view in Django
GOD OF THUNDER ️
Plz
GOD OF THUNDER ️
Anyone help mi for create chatbot
George
George
Let me 🦆 DuckDuckGo that for you: 🔎 django channels
Mirco
Hi, Rajat https://pypi.org/project/schedule/
read about celery or django-q as well
Gaurav
Hi Everyone I am working on a project and I am using celery for the data processing in that I have arroyn 20 tasks which are scheduled to run daily but some of these are long running tasks my celery app is taking much space on server I need to overcome this problem to reduce the space requirement Is there anyway through which we can only load fixed size scripts in celery so that it will not consume much space?
Сергей
hi I have ProcessedImageField what is the way to write image from directory?
Anonymous
Hi I wanna ask about what’s the best practice for these model fields Representing gender : by multiple choice with numbers or simply by M,F. Limiting a range of numbers to be entered in the field, e.g, entering only numbers between 10-40 Thanks 🌹
Anders (izzno / gooood) 🇳🇴
Anyone know if theres a max number/time for SESSION_COOKIE_AGE
Mirco
Anyone know if theres a max number/time for SESSION_COOKIE_AGE
If u don't find anything on docs, try to check the source code