Re: Playing Video with Django and html tag

2021-04-21 Thread Benjamin Schollnick
What web browser are you using?

I had to work my way around this as well, and it ended up being that I had to 
use:

RangedFileResponse module.
Name: django-ranged-response
Version: 0.2.0
Summary: Modified Django FileResponse that adds Content-Range headers.
Home-page: https://github.com/wearespindle/django-ranged-fileresponse
Author: Spindle
Author-email: jer...@wearespindle.com
License: MIT
Location: /Users/benjamin/venvs/quickbbs/lib/python3.9/site-packages
Requires: django
Required-by: 

And I am using this wrapper, for the download:

def download(request, filename=None):
"""
Replaces new_download.  

This now takes http:///downloads/?UUID=

This fakes the browser into displaying the filename as the title of the
download.  

"""
# Is this from an archive?  If so, get the Page ID.
d_uuid=request.GET.get("UUID", None)
if d_uuid == None:
d_uuid=request.GET.get("uuid", None)

if d_uuid in ["", None]:
raise Http404

page = request.GET.get('page', None)
if page is None:
download = index_data.objects.filter(uuid=d_uuid,
 ignore=False,
 delete_pending=False)[0]
else:
print ("Attempting to find page %s in archive" % page)

print("\tDownloading - %s, %s" % (download.fqpndirectory.lower(),
  download.name))
  
movie = download.filetype.is_movie
return respond_as_inline(request,
 "%s%s%s" % (
 configdata["locations"]["albums_path"],
 os.sep,
 download.fqpndirectory),
 download.name,
 ranged=movie)


def respond_as_inline(request, file_path, original_filename, ranged=False):
# https://stackoverflow.com/questions/36392510/django-download-a-file
# 
https://stackoverflow.com/questions/27712778/video-plays-in-other-browsers-but-not-safari
# 
https://stackoverflow.com/questions/720419/how-can-i-find-out-whether-a-server-supports-the-range-header
filename = os.path.join(file_path, original_filename)
if os.path.exists(filename):
mtype, encoding = mimetypes.guess_type(original_filename)
if mtype is None:
mtype = 'application/octet-stream'

with open(filename, 'rb') as fh:
if ranged:
response = RangedFileResponse(request, file=open(filename, 
'rb'), as_attachment=False, filename=original_filename)
response["Content-Type"] = mtype
else:
response = HttpResponse(fh.read(), content_type=mtype)
response['Content-Disposition'] = 'inline; filename=%s'% 
original_filename
return response
else:
print("File not found")
raise Http404

For the web side..

{% if item.filetype.is_movie %}
 
  

{% endif %}

Hope that helps.  And yes, the python code is intended as a starting place, as 
it’s very specific to my implementation of a web gallery..
But I’m more than happy to try to help…

- Benjamin


> On Apr 21, 2021, at 8:10 PM, Thiago Luiz Parolin  
> wrote:
> 
> try using {% static.. to server your file.
> 
> ‪Em qua., 21 de abr. de 2021 às 19:44, ‫תמר בביוף‬‎  > escreveu:‬
> Hello everyone
>  :I try to enable a video tag in HTML like this 
> 
> 
> 
> :My problem is that the video does not run on Django, and looks like a black 
>  Running on html alone it works,  
> Does anyone know what the problem is? Is not a video tag enough when using 
> Django?  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/db9c1818-3312-45b4-a652-6a2dbc5bb688n%40googlegroups.com
>  
> .
> 
> 
> -- 
> Thiago Luiz Parolin
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CANbmKysnyHnW7yz6jL_rBS5xBrdroHmZNKTzn%2Bx2D2Vj0dy8aA%40mail.gmail.com
>  
> 

Re: Playing Video with Django and html tag

2021-04-21 Thread Thiago Luiz Parolin
try using {% static.. to server your file.

‪Em qua., 21 de abr. de 2021 às 19:44, ‫תמר בביוף‬‎ 
escreveu:‬

> Hello everyone
>  :I try to enable a video tag in HTML like this
> 
> 
> 
> :My problem is that the video does not run on Django, and looks like a
> black
>  Running on html alone it works,
> Does anyone know what the problem is? Is not a video tag enough when using
> Django?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/db9c1818-3312-45b4-a652-6a2dbc5bb688n%40googlegroups.com
> 
> .
>


-- 
Thiago Luiz Parolin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANbmKysnyHnW7yz6jL_rBS5xBrdroHmZNKTzn%2Bx2D2Vj0dy8aA%40mail.gmail.com.


Re: Deploying my Django App to Heroku

2021-04-21 Thread Nzekwe Isaac
Try running makemigrations and migrations again before deploying again

On Wed, 21 Apr 2021, 22:30 ejike@gmail.com, 
wrote:

> Good day All,
>
> Please I am trying to deploy my App which uses Django/Python as the
> backend and React as the frontend to Heroku but I keep getting this error
> in the attached picture.
>
> Also attached is a screenshot of my Models.py.
>
> I would be very grateful for any assistance.
>
> Kind Regards,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/287b1a3a-abc5-4848-ade7-2de414e7b549n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACD%2B4V%3DPmh1OJbEYPW5u6vJG_aovPE-2vnHmwNGQrddbNjqHQg%40mail.gmail.com.


Showing a landing page with django-tenants package

2021-04-21 Thread Gabriel
Hi!

I am studying the django-tenants 
(https://github.com/django-tenants/django-tenants) and when I acces the 
principal page, it doesn´t show the landing page, just a message:

--



*Page not found (404)Request Method:GETRequest URL:http://127.0.0.1:8000/*


*Raised by:core.views.home*

*No tenant for hostname "127.0.0.1"*

*You're seeing this error because you have DEBUG = True in your Django 
settings file. Change that to False, and Django will display a standard 404 
page.*

-

*How I develop to show the primary page (landing page) ?*


- Follow the structure of the project

from django.contrib import admin

from django.urls import path
from core.views import home


urlpatterns = [
path('admin/', admin.site.urls),
path('', home, name='home'),
]


-- Core app (landing page) - view


from django.shortcuts import render

def home(request):
return render(request, 'core/index.html')


-- Settings.py file

ALLOWED_HOSTS = ['*']


# Application definition

SHARED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_tenants',
'customer',

]


TENANT_APPS = [
# The following Django contrib apps must be in TENANT_APPS
'django.contrib.contenttypes',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',

# your tenant-specific apps
'myclientapp',
'core',

]

INSTALLED_APPS = list(set(SHARED_APPS + TENANT_APPS))

Thank you very much!

Gabriel.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11b1a789-66ae-4f61-b06e-3cf0fed96e8cn%40googlegroups.com.


Playing Video with Django and html tag

2021-04-21 Thread תמר בביוף
Hello everyone
 :I try to enable a video tag in HTML like this 



:My problem is that the video does not run on Django, and looks like a 
black 
 Running on html alone it works,  
Does anyone know what the problem is? Is not a video tag enough when using 
Django?  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/db9c1818-3312-45b4-a652-6a2dbc5bb688n%40googlegroups.com.


Re: Assistance with Django Booking app

2021-04-21 Thread Ryan Nowakowski



On April 21, 2021 5:46:15 AM CDT, Eric 247ERICPOINTCOM  
wrote:
>I followed the steps as indicated in the README file and installed
>Django-booking successfully, but there are a couple of errors I get
>with
>this app when I run the server with: python manage.py runserver.
>
>This is what I get.
>
>(envirn) C:\Users\Eric\Desktop\Shop>python manage.py runserver
>Watching for file changes with StatReloader
>Exception in thread django-main-thread:
>Traceback (most recent call last):
>  File "C:\Program
>Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\threading.py",
>line 954, in _bootstrap_inner
>self.run()
>  File "C:\Program
>Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\threading.py",
>line 892, in run
>self._target(*self._args, **self._kwargs)
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\autoreload.py",
>line 53, in wrapper
>fn(*args, **kwargs)
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\core\management\commands\runserver.py",
>line 110, in inner_run
>autoreload.raise_last_exception()
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\autoreload.py",
>line 76, in raise_last_exception
>raise _exception[1]
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\core\management\__init__.py",
>line 357, in execute
>autoreload.check_errors(django.setup)()
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\autoreload.py",
>line 53, in wrapper
>fn(*args, **kwargs)
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\__init__.py",
>line 24, in setup
>apps.populate(settings.INSTALLED_APPS)
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\apps\registry.py",
>line 114, in populate
>app_config.import_models()
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\apps\config.py",
>line 211, in import_models
>self.models_module = import_module(models_module_name)
>  File "C:\Program
>Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py",
>line 127, in import_module
>return _bootstrap._gcd_import(name[level:], package, level)
>  File "", line 1030, in _gcd_import
>  File "", line 1007, in _find_and_load
>File "", line 986, in
>_find_and_load_unlocked
>  File "", line 680, in _load_unlocked
>File "", line 790, in exec_module
>  File "", line 228, in
>_call_with_frames_removed
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\booking\models.py",
>line 9, in 
>from django_libs.models_mixins import TranslationModelMixin
>  File
>"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django_libs\models_mixins.py",
>line 5, in 
>from django.utils.encoding import python_2_unicode_compatible
>ImportError: cannot import name 'python_2_unicode_compatible' from
>'django.utils.encoding'
>(C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\encodi
>ng.py)
>
>I have installed six
>I have also installed django.utils, but I just can't seem to run the
>server
>anymore. Is there a way I can manage to run the booking app without
>using
>django.utils

It looks like you're probably trying to run that Django booking app with a 
version of Django that it was never designed to run with. It looks like the 
author of Django booking didn't lock down the django version in requirements.txt

https://github.com/bitlabstudio/django-booking/blob/master/requirements.txt

However, based on the last commit message for requirements.txt, it looks like 
Django 1.9 was the last version used.

Since the author didn't lock down dependency versions you might have quite a 
challenging time finding versions of the dependencies that work properly.



>
>
>On Fri, Apr 9, 2021 at 12:29 AM Ryan Nowakowski 
>wrote:
>
>> On Thu, Apr 08, 2021 at 07:19:53AM -0700, Eric 247ERICPOINTCOM wrote:
>> > I am new to Python and Django, I just discovered that I can use
>Django
>> to
>> > easily implement a project that am working on.
>> >
>> > I would like to get some assistance with implementing a booking app
>into
>> my
>> > project.
>> >
>> > I came across Django-Booking but I dont know how exactly it works,
>>
>> Yup, you're in the position of wanting to leverage as much existing
>code
>> as possible, but being inexperienced enough to not know how to
>evaluate
>> the quality or usefulness of that existing code.  I feel for you for
>sure.
>> A couple of questions to hopefully help clarify things:
>>
>> 1. What kinds of things are you trying to book?  Rooms at a hotel,
>> tables at a restaurant, chairs at a barbershop?  It looks like
>> django-booking is set up to handle multiple people attached to a
>single
>> booking[a].  Is this something you need?
>>
>> 2. django-booking hasn't been updated in 5 years[b].  It looks like
>the
>> last update was for Django 1.9.  The latest Django is 3.2.  Is that a
>> 

Re: Required - Job vacancy in India

2021-04-21 Thread Satyajit Barik
what's your total and relevant experience in python?

On Wed, Apr 21, 2021 at 5:50 PM Mr. X Offencer 
wrote:

> Hello friends,
> May someone from this group help me to find a  relevant job for me in
> India. If possible nearer to Indore.
> Here is my job profile: Attachment below
>
>
> You can also visit my e-profile from here : profile.xoffencer.com
>
>
> Thanks
> Satyam Soni (Mr.XOffencer)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABz7kDSOCR8whqczuxhvbgyPMybyXzm89Da9XPypGC2p7yRz_Q%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANd-%2BoDc45D0PKsOFSCbQ%3DZiKc0iDpR2mTPOHFS%3DWE_JyaOZfQ%40mail.gmail.com.


Re: Assistance with Django Booking app

2021-04-21 Thread Kasper Laudrup
On 21/04/2021 12.51, Eric 247ERICPOINTCOM wrote:
> Thanks for your response, I have tried this option on pycharm. I just
> would like to know which of the packages I would need to install for
> this to work. 
> I checked that I dont have most of the packages installed.
> 

I'm not really sure what you're trying to do, but if you cloned this
project I mentioned, all package requirements are listed in the
requirements.txt file which is more or less standard for pip.

You can install them with:

# pip install -r requirements.txt

In a virtual environment.

Be aware that I mentioned this project of mine for inspiration. I've
never really intended it to be used by anyone else, but you're of course
free to do so, just don't expect much support from my side.

Anyway, good luck with your project.

Kind regards,

Kasper Laudrup

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d6dc34d7-970c-87f9-a487-2da483822309%40stacktrace.dk.


OpenPGP_signature
Description: OpenPGP digital signature


Re: Assistance with Django Booking app

2021-04-21 Thread Eric 247ERICPOINTCOM
Hi Kasper Laudrup,

Thanks for your response, I have tried this option on pycharm. I just would
like to know which of the packages I would need to install for this to
work.
I checked that I dont have most of the packages installed.

*Kind Regards*

*Eric Bawakuno | Computer Engineer | +27795639700| +27 815152254
| eric...@gmail.com   | **Address**: 29 Rochester Road,
Observatory | Cape Town, South Africa | 7925*
f



On Fri, Apr 9, 2021 at 1:03 AM Kasper Laudrup  wrote:

> On 08/04/2021 16.19, Eric 247ERICPOINTCOM wrote:
> > Good day,
> >
> > I am new to Python and Django, I just discovered that I can use Django
> > to easily implement a project that am working on.
> >
> > I would like to get some assistance with implementing a booking app into
> > my project.
> >
> > I came across Django-Booking but I dont know how exactly it works, do I
> > need to create an app for booking like a new app into my project or do I
> > need to use it as a built in package only. Your help will be highly
> > appreciated.
> >
>
> I was in pretty much the same situation as you. What I needed was a
> simple way to make bookings for our family summerhouse. Nothing fancy,
> just a way for one of us to book some dates and avoid having to write
> mails back and forth.
>
> To achieve that, I also thought it would be the most obvious to use an
> already made system, but it really turned out that nothing did really
> what I wanted, was outdated or had other issues I can't really remember.
>
> In the end, I implemented it myself and it turned out to be fairly
> trivial to do.
>
> Feel free to have a look at:
>
> https://github.com/laudrup/ebbamaala
>
> Be aware that this is not documented and very much made for this
> specific purpose and I really doubt I'll get around to generalize this,
> so this repository is not just the booking system code.
>
> It was a while ago I wrote it and back then I was even less experienced
> in Django than I am now, so if you feel like it, I think implementing
> something like that can be recommended as a good learning experience.
>
> I think I started by creating a Booking model with a User, a start and
> end date and then worked my way from there.
>
> Feel free to ask any questions and I'll see if I can help. Also be aware
> that I'm definitely not saying this is the best way to do it, but at
> least it's one way and it works well enough for my purpose :-)
>
> Good luck.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5acc1d25-0d02-f92d-43b9-62c373ede7cc%40stacktrace.dk
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFgqToXh_1EX%2B%2Br%3DESFwq0W6_fV%2BqtCBZVgBq%2BwiqE%2BNKL6ZmA%40mail.gmail.com.


Re: Assistance with Django Booking app

2021-04-21 Thread Eric 247ERICPOINTCOM
Hi Ryan,

Am trying to use booking on a marketing system that is developing for
different kinds of businesses like property where someone would be able to
book an appointment for a viewing or a service like a Mobile car wash where
someone would be able to book a car washer for a specific time. But on the
same system so it would be dynamic depending on the service someone would
like to book for or a product someone would like to schedule to buy like
shoes or anything.

I followed the steps as indicated in the README file and installed
Django-booking successfully, but there are a couple of errors I get with
this app when I run the server with: python manage.py runserver.

This is what I get.

(envirn) C:\Users\Eric\Desktop\Shop>python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\threading.py",
line 954, in _bootstrap_inner
self.run()
  File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\threading.py",
line 892, in run
self._target(*self._args, **self._kwargs)
  File
"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\autoreload.py",
line 53, in wrapper
fn(*args, **kwargs)
  File
"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\core\management\commands\runserver.py",
line 110, in inner_run
autoreload.raise_last_exception()
  File
"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\autoreload.py",
line 76, in raise_last_exception
raise _exception[1]
  File
"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\core\management\__init__.py",
line 357, in execute
autoreload.check_errors(django.setup)()
  File
"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\autoreload.py",
line 53, in wrapper
fn(*args, **kwargs)
  File
"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\__init__.py",
line 24, in setup
apps.populate(settings.INSTALLED_APPS)
  File
"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\apps\registry.py",
line 114, in populate
app_config.import_models()
  File
"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\apps\config.py",
line 211, in import_models
self.models_module = import_module(models_module_name)
  File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py",
line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1030, in _gcd_import
  File "", line 1007, in _find_and_load
  File "", line 986, in _find_and_load_unlocked
  File "", line 680, in _load_unlocked
  File "", line 790, in exec_module
  File "", line 228, in
_call_with_frames_removed
  File
"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\booking\models.py",
line 9, in 
from django_libs.models_mixins import TranslationModelMixin
  File
"C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django_libs\models_mixins.py",
line 5, in 
from django.utils.encoding import python_2_unicode_compatible
ImportError: cannot import name 'python_2_unicode_compatible' from
'django.utils.encoding'
(C:\Users\Eric\Desktop\Shop\envirn\lib\site-packages\django\utils\encodi
ng.py)

I have installed six
I have also installed django.utils, but I just can't seem to run the server
anymore. Is there a way I can manage to run the booking app without using
django.utils

*Kind Regards*

*Eric Bawakuno | Computer Engineer | +27795639700| +27 815152254
| eric...@gmail.com   | **Address**: 29 Rochester Road,
Observatory | Cape Town, South Africa | 7925*
f



On Fri, Apr 9, 2021 at 12:29 AM Ryan Nowakowski  wrote:

> On Thu, Apr 08, 2021 at 07:19:53AM -0700, Eric 247ERICPOINTCOM wrote:
> > I am new to Python and Django, I just discovered that I can use Django
> to
> > easily implement a project that am working on.
> >
> > I would like to get some assistance with implementing a booking app into
> my
> > project.
> >
> > I came across Django-Booking but I dont know how exactly it works,
>
> Yup, you're in the position of wanting to leverage as much existing code
> as possible, but being inexperienced enough to not know how to evaluate
> the quality or usefulness of that existing code.  I feel for you for sure.
> A couple of questions to hopefully help clarify things:
>
> 1. What kinds of things are you trying to book?  Rooms at a hotel,
> tables at a restaurant, chairs at a barbershop?  It looks like
> django-booking is set up to handle multiple people attached to a single
> booking[a].  Is this something you need?
>
> 2. django-booking hasn't been updated in 5 years[b].  It looks like the
> last update was for Django 1.9.  The latest Django is 3.2.  Is that a
> concern for you?
>
> 3. It it weird that django-booking includes an error logging table[c]?
> Django already 

Re: How Choose Random User from database ?

2021-04-21 Thread FIRDOUS BHAT
Scot Hacker's answer is preferable

On Wed, Apr 21, 2021 at 11:31 AM Scot Hacker  wrote:

>
> If the number of records you need to choose randomly between is not huge,
> this works fine:
>
> `User.objects.order_by('?').first()`
>
> You only need turn to use a special function or method if your query takes
> more than a microsecond to return, or you have a ton of traffic. i.e. use
> the ORM for random choices with caution.
>
> ./s
>
>
>
>
> On Monday, April 19, 2021 at 6:19:39 PM UTC-7 mustafab...@gmail.com wrote:
>
>> Thanks !
>>
>>
>>
>> Sent from Mail  for
>> Windows 10
>>
>>
>>
>> *From: *Kelvin Sajere
>> *Sent: *Tuesday, April 20, 2021 3:58 AM
>> *To: *django...@googlegroups.com
>> *Subject: *Re: How Choose Random User from database ?
>>
>>
>>
>> If you just want a random user, you could just use random.choice(). You
>> can use it in shell, in a function or wherever you want.
>>
>>
>>
>> Example:
>>
>>
>>
>> import random
>>
>> users = User.objects.all() #a list of all users
>>
>> random_user = random.choice(users) #a random user
>>
>>
>>
>> On Mon, Apr 19, 2021 at 20:45 Mustafa Burhani 
>> wrote:
>>
>> I want to Choose random user from databse is possible with django shell
>> or need to create model ? for random function ?
>>
>>
>>
>>
>>
>> Thanks !
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/055d5a55-ad28-4a97-b1ec-1d16369cc2a2n%40googlegroups.com
>> 
>> .
>>
>> --
>>
>> KeLLs
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users...@googlegroups.com.
>>
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CADYqDX1275VyPJcTfnX7%2B%3DtbmMSaFTYxph0m0t%2B-PH3bTLK9Ow%40mail.gmail.com
>> 
>> .
>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fe5658e1-3b1c-447a-90a1-4f0a0c888d41n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFB6YJrFyAKth2jonyMCYCLKp1svg2yZoxPYq6GfbW1ap2v%3DsA%40mail.gmail.com.


Re: How Choose Random User from database ?

2021-04-21 Thread Scot Hacker

If the number of records you need to choose randomly between is not huge, 
this works fine:

`User.objects.order_by('?').first()`

You only need turn to use a special function or method if your query takes 
more than a microsecond to return, or you have a ton of traffic. i.e. use 
the ORM for random choices with caution.

./s




On Monday, April 19, 2021 at 6:19:39 PM UTC-7 mustafab...@gmail.com wrote:

> Thanks !
>
>  
>
> Sent from Mail  for 
> Windows 10
>
>  
>
> *From: *Kelvin Sajere
> *Sent: *Tuesday, April 20, 2021 3:58 AM
> *To: *django...@googlegroups.com
> *Subject: *Re: How Choose Random User from database ?
>
>  
>
> If you just want a random user, you could just use random.choice(). You 
> can use it in shell, in a function or wherever you want.
>
>  
>
> Example:
>
>  
>
> import random
>
> users = User.objects.all() #a list of all users
>
> random_user = random.choice(users) #a random user
>
>  
>
> On Mon, Apr 19, 2021 at 20:45 Mustafa Burhani  
> wrote:
>
> I want to Choose random user from databse is possible with django shell or 
> need to create model ? for random function ?
>
>  
>
>  
>
> Thanks !
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/055d5a55-ad28-4a97-b1ec-1d16369cc2a2n%40googlegroups.com
>  
> 
> .
>
> -- 
>
> KeLLs
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com.
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CADYqDX1275VyPJcTfnX7%2B%3DtbmMSaFTYxph0m0t%2B-PH3bTLK9Ow%40mail.gmail.com
>  
> 
> .
>
>  
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fe5658e1-3b1c-447a-90a1-4f0a0c888d41n%40googlegroups.com.