Re: Import csv file on django view

2020-07-24 Thread Jani Tiainen
Hi,

I highly can recommend to use pandas to read csv. It does pretty good job
to guess a lot of things without extra config.

Of course it's one more extra dependency.


pe 24. heinäk. 2020 klo 17.09 Ronaldo Mata 
kirjoitti:

> Yes, I will try it. Anythin I will let you know
>
> El mié., 22 de julio de 2020 12:24 p. m., Liu Zheng <
> firstday2...@gmail.com> escribió:
>
>> Hi,
>>
>> Are you sure that the file used for detection is the same as the file
>> opened and decoded and gave you incorrect information?
>>
>> By the way, ascii is a proper subset of utf-8. If chardet said it ascii,
>> decoding it using utf-8 should always work.
>>
>> If your file contains non-ascii UTF-8 bytes, maybe it’s a bug in chardet?
>> You can try it directly, without mixing it with django’s requests first.
>> Make sure you can detect and decode the file locally in a test program.
>> Then put it into the app.
>>
>> If you share the file, i’m also glad to help you try it.
>>
>> On Thu, 23 Jul 2020 at 12:04 AM, Ronaldo Mata 
>> wrote:
>>
>>> Hi Kovy, this is not solved. Liu Zheng but using
>>> chardet(request.FILES['file'].read()) return encoding "ascii" is not
>>> correct, I've uploaded a file using utf-7 as encoding for example and the
>>> result is wrog. and then I tried
>>> request.FILES['file'].read().decode('ascii') and not work return bad data.
>>> Example for @ string return "+AEA-" string.
>>>
>>> El mié., 22 jul. 2020 a las 11:16, Kovy Jacob ()
>>> escribió:
>>>
 I’m confused. I don’t know if I can help.

 On Jul 22, 2020, at 11:11 AM, Liu Zheng  wrote:

 Hi, glad you solved the problem. Yes, both the request.FILES[‘file’]
 and the chardet file handler are binary handlers. Binary handler presents
 the raw data. chardet takes a sequence or raw data and then detect the
 encoding format. With its prediction, if you want to open that puece of
 data in text mode, you can use the .decode() method of
 bytes object to get a python string.

 On Wed, 22 Jul 2020 at 11:04 PM, Kovy Jacob 
 wrote:

> That’s probably not the proper answer, but that’s the best I can do.
> Sorry :-(
>
>
> On Jul 22, 2020, at 10:46 AM, Ronaldo Mata 
> wrote:
>
> Yes, the problem here is that the files will be loaded by the user, so
> I don't know what delimiter I will receive. This is not a base command 
> that
> I am using, it is the logic that I want to incorporate in a view
>
> El mié., 22 jul. 2020 a las 10:43, Kovy Jacob ()
> escribió:
>
>> Ah, so is the problem that you don’t always know what the delimiter
>> is when you read it? If yes, what is the use case for this? You might not
>> need a universal solution, maybe just put all the info into a csv 
>> yourself,
>> manually.
>>
>> On Jul 22, 2020, at 10:39 AM, Ronaldo Mata 
>> wrote:
>>
>> Hi Kovy, I'm using csv module, but I need to handle the delimiters of
>> the files, sometimes you come separated by "," others by ";" and rarely 
>> by
>> "|"
>>
>> El mié., 22 jul. 2020 a las 10:28, Kovy Jacob ()
>> escribió:
>>
>>> Could you just use the standard python csv module?
>>>
>>> On Jul 22, 2020, at 10:25 AM, Ronaldo Mata 
>>> wrote:
>>>
>>> Hi Liu thank for your answer.
>>>
>>> This has been a headache, I am trying to read the file using
>>> csv.DictReader initially i had an error trying to get the dict keys when
>>> iterating by rows, and i thought it could be encoding (for this reason i
>>> wanted to prepare the view to use the correct encoding). for that 
>>> reason I
>>> asked my question.
>>>
>>> 1) your first approach doesn't work, if i send utf-8 file, chardet
>>> returns ascii as encoding. it seems request.FILES ['file']. read () 
>>> returns
>>> a binary with that encoding.
>>>
>>> 2) In the end I realized that the problem was the delimiter of the
>>> csv but predicting it is another problem.
>>>
>>> Anyway, it was a task that I had to do and that was my limitation. I
>>> think there must be a library that does all this, uploading a csv file 
>>> is
>>> common practice in many web apps.
>>>
>>> El mar., 21 jul. 2020 a las 13:47, Liu Zheng (<
>>> firstday2...@gmail.com>) escribió:
>>>
 Hi. First of all, I think it's impossible to perfectly detect
 encoding without further information. See the answer in this SO post:
 https://stackoverflow.com/questions/436220/how-to-determine-the-encoding-of-text
  There
 are many packages and tools to help detect encoding format, but keep in
 mind that they are only giving educated guesses. (Most of the time, the
 guess is correct, but do check the dev page to see whether there are 
 known
 issues related to your problem.)

 Now let's say you have decided to use chardet. 

Customer specific translations

2019-11-25 Thread Jani Tiainen
I've use-case where my django app is delivered to multiple customers in
multiple languages.

Due the nature of application end users do use for certain terms their own
wording, which differ significantly from others.

For example:

"Delivery route". Some may call it "driving route". Some "route" and some
just "delivery route".

Any ideas how to handle this?

-- 
Jani Tiainen
Software wizard

https://blog.jani.tiainen.cc/

Always open for short term jobs or contracts to work with 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/CAHn91odVXDb_Tu3pAmmKtZMNZZyLDzHak9WMmMxU6HZrY0v_Zg%40mail.gmail.com.


Re: Django jobs available

2019-11-18 Thread Jani Tiainen
Send your application and our recruitees will check it out.

ma 18. marrask. 2019 klo 15.06 Mohammad yunus 
kirjoitti:

> What if I am Freshers?
>
> On Mon, 18 Nov 2019, 1:25 pm Jani Tiainen,  wrote:
>
>>
>> If you are an experienced software developer looking for new challenges -
>> this could be your opportunity!
>>
>>
>>
>> Keypro is internationally growing company specialized in network
>> information management systems and GIS solutions and related professional
>> services.
>>
>>
>>
>> We are looking for enthusiastic *Full Stack Software Developers* to join
>> our team to work on challenging and interesting projects, developing Keypro
>> web-solutions for domestic and international customers.
>>
>> We expect candidates to have strong understanding of agile software
>> development process and practices, web development experience, database and
>> sql knowledge. Additional plus if you know Python, Django and Docker.
>>
>> Working with us is a great opportunity to utilize your skills, learn new
>> things and have direct impact on the results.
>>
>>
>> If you are inventive, independent, willing to work hard to reach the
>> goals - you are the one we are looking for.
>>
>>
>> We offer this full-time permanent position in our offices in Joensuu,
>> Finland.
>>
>> Job starts as agreed.
>>
>>
>>
>> Send your application to *care...@keypro.fi *
>>
>>
>> --
>> Jani Tiainen
>> Technical Team Lead
>> Keypro Oy
>>
>> --
>> 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/CAHn91odU%3DY76pHqf%2BFKWTFXTj_3SBJMa4OnNEt6d-eLK2td2og%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAHn91odU%3DY76pHqf%2BFKWTFXTj_3SBJMa4OnNEt6d-eLK2td2og%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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/CAEQiGcP%2BNY-ysCjL%3Dsdt_9z_6MrS9k%2B5tdEv%3D8JagkUEP%3DKdeA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAEQiGcP%2BNY-ysCjL%3Dsdt_9z_6MrS9k%2B5tdEv%3D8JagkUEP%3DKdeA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAHn91od%3DFe_uhWjFz2ZYX4nqAtZmYMwYG%3DtnyjuTRh1ixJtGfw%40mail.gmail.com.


Django jobs available

2019-11-17 Thread Jani Tiainen
If you are an experienced software developer looking for new challenges -
this could be your opportunity!



Keypro is internationally growing company specialized in network
information management systems and GIS solutions and related professional
services.



We are looking for enthusiastic *Full Stack Software Developers* to join
our team to work on challenging and interesting projects, developing Keypro
web-solutions for domestic and international customers.

We expect candidates to have strong understanding of agile software
development process and practices, web development experience, database and
sql knowledge. Additional plus if you know Python, Django and Docker.

Working with us is a great opportunity to utilize your skills, learn new
things and have direct impact on the results.


If you are inventive, independent, willing to work hard to reach the goals
- you are the one we are looking for.


We offer this full-time permanent position in our offices in Joensuu,
Finland.

Job starts as agreed.



Send your application to *care...@keypro.fi *


-- 
Jani Tiainen
Technical Team Lead
Keypro Oy

-- 
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/CAHn91odU%3DY76pHqf%2BFKWTFXTj_3SBJMa4OnNEt6d-eLK2td2og%40mail.gmail.com.


Re: Django leaflet

2019-10-30 Thread Jani Tiainen
Also I did workshop on last DjangoCon EU where I used leaflet without
additional magic.

You can find short docs and code at http://dceu2019.tiainen.cc

su 27. lokak. 2019 klo 2.42 Perceval Maturure 
kirjoitti:

>
> Hi all
> How do u wire your template and view to display maps in Django leaflet
>
> Sent from my iPhone
>
> --
> 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/EF3DE386-7F05-472A-A2CA-D7E29F388DCD%40gmail.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/CAHn91of1DbOEVoYTuymY9hcOy9LbDS87%3DWFJaab-VarP6CABGQ%40mail.gmail.com.


Re: django.contrib.gis for Windows 10

2019-10-30 Thread Jani Tiainen
Hi.

First postgis should bring all necessary libs since it uses very same
geospatial libs as osgeo.

Very important thing is to make sure that if you have 32bit libs you use
32bit python and same with 64bits. You just can't mix libs with different
bit sizes.

In linux this is much easier since it makes way harder to mix bit sizes.

But like many others having native geospatial in windows is a pain. Some of
my colleagues have been doing that since geodjango has even existed.

to 13. kesäk. 2019 klo 21.24 Thanasis  kirjoitti:

> Hello.
> I want to use the GeoDjango application. I begun with the tutorial GIS
> Tutorial .
> I installed properly the PostgreSQL and PostGis for Windows 10. In
> addition, I follow the steps and I installed the OSGeo4W
> 
> in order to get the geospartial libraries. I foolowed the steps in order to
> create the environment variables GDA L_DATA and PROJ_LIB. So, I continued
> with the tutorial
> https://docs.djangoproject.com/en/2.2/ref/contrib/gis/tutorial/#use-ogrinfo-to-examine-spatial-data
>  which
> this command works properly. I make a geographic model and try to make a
> migration in the database. Although, I get a big traceback
>
> Traceback (most recent call last):
>   File "manage.py", line 21, in 
> main()
>   File "manage.py", line 17, in main
> execute_from_command_line(sys.argv)
>   File
> "C:\Users\examples\vent\lib\site-packages\django\core\management\__init__.py"
> , line 381, in execute_from_command_line
> utility.execute()
>   File
> "C:\Users\examples\vent\lib\site-packages\django\core\management\__init__.py"
> , line 357, in execute
> django.setup()
>   File "C:\Users\examples\vent\lib\site-packages\django\__init__.py",
> line 24, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File "C:\Users\examples\vent\lib\site-packages\django\apps\registry.py",
> line 122, in populate
> app_config.ready()
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\admin\apps.py",
> line 24, in ready
> self.module.autodiscover()
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\admin\__init__.py"
> , line 26, in autodiscover
> autodiscover_modules('admin', register_to=site)
>   File
> "C:\Users\examples\vent\lib\site-packages\django\utils\module_loading.py",
> line 47, in autodiscover_modules
> import_module('%s.%s' % (app_config.name, module_to_search))
>   File "C:\Users\examples\vent\lib\importlib\__init__.py", line 127, in
> import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 1006, in _gcd_import
>   File "", line 983, in _find_and_load
>   File "", line 967, in
> _find_and_load_unlocked
>   File "", line 677, in _load_unlocked
>   File "", line 728, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\__init__.py"
> , line 5, in 
> from django.contrib.gis.admin.options import GeoModelAdmin,
> OSMGeoAdmin
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\options.py"
> , line 2, in 
> from django.contrib.gis.admin.widgets import OpenLayersWidget
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\admin\widgets.py"
> , line 3, in 
> from django.contrib.gis.gdal import GDALException
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\__init__.py"
> , line 28, in 
> from django.contrib.gis.gdal.datasource import DataSource
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\datasource.py"
> , line 39, in 
> from django.contrib.gis.gdal.driver import Driver
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\driver.py"
> , line 5, in 
> from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as
> rcapi
>   File
> "C:\Users\examples\vent\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py"
> , line 9, in 
> from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
>   File "C:\Users\examples\
> vent\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 47, in
> 
> lgdal = CDLL(lib_path)
>   File "c:\program files (x86)\python37-32\Lib\ctypes\__init__.py", line
> 356, in __init__
> self._handle = _dlopen(self._name, mode)
> OSError: [WinError 193] %1 is not a valid Win32 applicationEnter code here
> ...
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> 

Re: Auto assigning 2 types of user roles on sign up

2019-10-23 Thread Jani Tiainen
Hi.

Personally I would do it as follows:

On invitation create invited user account at least with email and with
member role. Make account disabled. You might also add invitation key which
you can put in email and check as well.

When invited user starts sign up procedure you can just fill in the blanks
and enable account.


ke 23. lokak. 2019 klo 4.38 Stephanie Semerville <
stephanie.semervi...@gmail.com> kirjoitti:

> I am new to Django and trying to create a website that has two user roles
> primary and member. What i would like to happen is for by default a primary
> user to sign up and be assigned the primary role. When that primary user
> logs into the website, I would like them to have the ability to invite new
> users to the website. When that new user receives the invitation email and
> is redirected to the same sign up form, I would like that user to be auto
> assigned the member role on form submit. I have heard about the save()
> method but not sure how to use it and what file it goes in. Would the
> process change if all users can potentially be both roles?
>
> --
> 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/c80f1b02-d1e8-4a9d-a8ca-80af61260e79%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/CAHn91ocJzy1FqtEvLuPzXgh3vEuEdPPgAVt56VjZrwKqBhwRMA%40mail.gmail.com.


Re: CSS not working

2019-10-11 Thread Jani Tiainen
Hi.

As you see Django indeed found your static file.

Next step is to open up developer tools in browser and load your page. You
should be able to use it to determine was file even loaded and was your
style applied to link

Note that if I'm not mistaken plain color only affects unvisited links and
visited link may stay different colored and thus seemingly you see that it
wasn't doing "nothing".


pe 11. lokak. 2019 klo 9.30 yasar arafath Kajamydeen 
kirjoitti:

> *@ Jani - Executed the  given cmd, Please find the output and please guide
> me further ..*
>
>
> (mypython) C:\Users\kajamydeenya\telusko>python manage.py findstatic -v 3
> polls/style.css
> Found 'polls/style.css' here:
>   C:\Users\kajamydeenya\telusko\polls\static\polls\style.css
> Looking in the following locations:
>   C:\Users\kajamydeenya\telusko\static
>   C:\Users\kajamydeenya\telusko\polls\static
>
> C:\Users\kajamydeenya\telusko\mypython\lib\site-packages\django\contrib\admin\st
>
>
>
>
> *Regards,*
> *Yasar Arafath K*
>
> On Friday, October 11, 2019 at 12:30:19 PM UTC+8, Jani Tiainen wrote:
>>
>> Hi.
>>
>> You could try to diagnose issue with findstatic management command:
>>
>> ./manage.py findstatic -v 3 polls/style.css
>>
>> You should get a list of paths Django tried to look for your static file
>> (stylesheet) and of course was it found.
>>
>>
>> pe 11. lokak. 2019 klo 6.19 yasar arafath Kajamydeen 
>> kirjoitti:
>>
>>> Hi All,
>>>
>>> I just added style sheet in my application but its not working , Please
>>> try to help me.
>>>
>>>
>>> Setting.py
>>>
>>>
>>>
>>> import os
>>>
>>> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
>>> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>>>
>>>
>>> # Quick-start development settings - unsuitable for production
>>> # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
>>>
>>> # SECURITY WARNING: keep the secret key used in production secret!
>>> SECRET_KEY = '@$k&=42v@e7u26@0+woy#%aopsiv&55jjj$a=x2tr52f_5ipyh'
>>>
>>> # SECURITY WARNING: don't run with debug turned on in production!
>>> DEBUG = True
>>>
>>> ALLOWED_HOSTS = []
>>>
>>>
>>> # Application definition
>>>
>>> INSTALLED_APPS = [
>>> 'polls.apps.PollsConfig',
>>> 'django.contrib.admin',
>>> 'django.contrib.auth',
>>> 'django.contrib.contenttypes',
>>> 'django.contrib.sessions',
>>> 'django.contrib.messages',
>>> 'django.contrib.staticfiles',
>>>
>>>
>>> ]
>>>
>>> MIDDLEWARE = [
>>> 'django.middleware.security.SecurityMiddleware',
>>> 'django.contrib.sessions.middleware.SessionMiddleware',
>>> 'django.middleware.common.CommonMiddleware',
>>> 'django.middleware.csrf.CsrfViewMiddleware',
>>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>>> 'django.contrib.messages.middleware.MessageMiddleware',
>>> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>>> ]
>>>
>>> ROOT_URLCONF = 'telusko.urls'
>>>
>>>
>>> TEMPLATES = [
>>> {
>>> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
>>> 'DIRS': [os.path.join(BASE_DIR,'templates')],
>>> 'APP_DIRS': True,
>>> 'OPTIONS': {
>>> 'context_processors': [
>>> 'django.template.context_processors.debug',
>>> 'django.template.context_processors.request',
>>> 'django.contrib.auth.context_processors.auth',
>>> 'django.contrib.messages.context_processors.messages',
>>> ],
>>> },
>>> },
>>> ]
>>>
>>> WSGI_APPLICATION = 'telusko.wsgi.application'
>>>
>>>
>>> # Database
>>> # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
>>>
>>> DATABASES = {
>>> 'default': {
>>> 'ENGINE': 'django.db.backends.sqlite3',
>>> 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),  # Or path to 
>>> database file if using sqlite3.
>>> 'USER': '',  # Not used with sqlite3.
>>> 'PASSWORD': '',  # Not used with sqlite3.
>>> 'HOST': '',  # Set to empty string for localhost. N

Re: CSS not working

2019-10-10 Thread Jani Tiainen
Hi.

You could try to diagnose issue with findstatic management command:

./manage.py findstatic -v 3 polls/style.css

You should get a list of paths Django tried to look for your static file
(stylesheet) and of course was it found.


pe 11. lokak. 2019 klo 6.19 yasar arafath Kajamydeen 
kirjoitti:

> Hi All,
>
> I just added style sheet in my application but its not working , Please
> try to help me.
>
>
> Setting.py
>
>
>
> import os
>
> # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>
>
> # Quick-start development settings - unsuitable for production
> # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
>
> # SECURITY WARNING: keep the secret key used in production secret!
> SECRET_KEY = '@$k&=42v@e7u26@0+woy#%aopsiv&55jjj$a=x2tr52f_5ipyh'
>
> # SECURITY WARNING: don't run with debug turned on in production!
> DEBUG = True
>
> ALLOWED_HOSTS = []
>
>
> # Application definition
>
> INSTALLED_APPS = [
> 'polls.apps.PollsConfig',
> 'django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
>
>
> ]
>
> MIDDLEWARE = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> ]
>
> ROOT_URLCONF = 'telusko.urls'
>
>
> TEMPLATES = [
> {
> 'BACKEND': 'django.template.backends.django.DjangoTemplates',
> 'DIRS': [os.path.join(BASE_DIR,'templates')],
> 'APP_DIRS': True,
> 'OPTIONS': {
> 'context_processors': [
> 'django.template.context_processors.debug',
> 'django.template.context_processors.request',
> 'django.contrib.auth.context_processors.auth',
> 'django.contrib.messages.context_processors.messages',
> ],
> },
> },
> ]
>
> WSGI_APPLICATION = 'telusko.wsgi.application'
>
>
> # Database
> # https://docs.djangoproject.com/en/2.2/ref/settings/#databases
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),  # Or path to database 
> file if using sqlite3.
> 'USER': '',  # Not used with sqlite3.
> 'PASSWORD': '',  # Not used with sqlite3.
> 'HOST': '',  # Set to empty string for localhost. Not used with 
> sqlite3.
> 'PORT': '',
> }
> }
>
>
> # Password validation
> # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
>
> AUTH_PASSWORD_VALIDATORS = [
> {
> 'NAME': 
> 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
> },
> {
> 'NAME': 
> 'django.contrib.auth.password_validation.MinimumLengthValidator',
> },
> {
> 'NAME': 
> 'django.contrib.auth.password_validation.CommonPasswordValidator',
> },
> {
> 'NAME': 
> 'django.contrib.auth.password_validation.NumericPasswordValidator',
> },
> ]
>
>
> # Internationalization
> # https://docs.djangoproject.com/en/2.2/topics/i18n/
>
> LANGUAGE_CODE = 'en-us'
>
> TIME_ZONE = 'UTC'
>
> USE_I18N = True
>
> USE_L10N = True
>
> USE_TZ = True
>
>
> # Static files (CSS, JavaScript, Images)
> # https://docs.djangoproject.com/en/2.2/howto/static-files/
>
> STATIC_URL = '/static/'
> STATICFILES_DIRS = [
> os.path.join(BASE_DIR, 'style.css'),
> ]
>
>
>
>
>
> *style.css*
>
>
>
>
> li a {
> color: green;
> }
>
>
>
>
>
>
>
> *index.html*
>
>
> {% load static %}
>
> 
> {% if latest_question_list %}
> 
> {% for question in latest_question_list %}
>   {{ 
> question.question_text }}
> {% endfor %}
> 
> {% else %}
> No polls are available.
> {% endif %}
>
>
>
>
>
> Regards,
>
> Yasar Arafath K
>
> --
> 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/3a71830f-e494-47b0-be2d-6d43e8d7cb27%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 

Re: University management system

2019-10-09 Thread Jani Tiainen
Hi.

How realistic, given your requirements, you think you as a developer can
implement all that in one week?

Ok, lets break this down a bit.

Requirement 1 hierarchical users. This is rather trivial to do if you don't
need fancy ui but can rely on admin facilities.

Requirement 2 blogging. If you checkout Django Girls tutorial it gives
basis to write one.

Requirement 3 fancy stuff like images etc in blogs. Now it starts to get
tricky. Like how you upload images? How to size and position them? How you
add links? Do you want to make sure all user input is safe or do you trust
users not to do bad things. This is one of the big requirements which has
possibilty to be real time sink. You said that you have checked out some
blogs. Why they didn't fit to your requirements?

Requirement 4 forums or comments. If you think a bit there is actually very
little difference between those two. Both are usually time based and might
be hierarchical also.

Requirement 5 reports. This might be one of the simplest things to
implement since django orm provides pretty good aggregation support. You
just need to figure out what and how you want to represent the data.

Requirement 6 grading system. Or "rating" fortunately there exists quite
many django apps that does this.


ke 9. lokak. 2019 klo 19.55 Ankita Gupta 
kirjoitti:

> Hello everyone!
> I have a project to make on university management system.
> BASIC requirements-
> 1. Heirarichal mode(multiple users like mentor, student, Dean, advisors
> etc)
> 2. Students need to post daily blogs about their progress(if certain task
> is given to them by their mentors).
> 3. Blogs will have images, url, links, etc.
> 4. Discussion forum or maybe comment system in simple language where
> mentor and student can interact over the blog.
> 5. Weekly and monthly report generator of student's progress like no. Of
> blogs, how much they were active etc.
> 6. Mentor provided with grading facility just like we have different
> emojis on Facebook post.
> I want to know if is this possible with any cms because I am very much
> short of time. And I have less practical knowledge of django. I have tried
> many open source projects regarding blog part but couldn't find useful to
> me. I have to submit this project in 1 week.
> Django users, waiting for your valuable response to this thread.
>
> --
> 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/5740d448-d6ad-48b7-a8ab-11bb6a6982ab%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/CAHn91oeC6CprFmtJxE_RRmUuj8CVm%3D4zG4mNVScm6w%2B6VqksOw%40mail.gmail.com.


Re: Why and when I should override the default AdminSite

2019-10-09 Thread Jani Tiainen
Hi.

I've been working with Django about 10 years and yet I haven't need for
overriding admin.

Admin is great tool for CRUD while developing but I wouldn't push it too
far. Specially trying to put any business logic in admin doesn't go well in
the long run.

And it's really easy to build proper management console with generic class
based views which can cope with business requirements easily.

ke 9. lokak. 2019 klo 11.12 Jérôme Le Carrou 
kirjoitti:

> I am newbie in DJango
> I've started to read Django documentation and particularly the admin
> related documentation
>
> I would like to understand when an why it should be pertinent to override
> the default AdminSite
>
> 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/9ecd5e6a-c1b4-4642-8cda-f5746b4b9216%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/CAHn91ocBFuY%2BFuW5mSO1RfhbT%2BvCbkFVmTRvF0tO93ZQeK23kQ%40mail.gmail.com.


Re: ListView from 2 model

2019-10-08 Thread Jani Tiainen
Hi,

ListView and most other generic views are designed mostly to work with
single model.

There are few ways to tackle your problem depending on your needs.

to 3. lokak. 2019 klo 0.53 Yann Mbella  kirjoitti:

> hi everyone,
> I got a problem in listing two models from a listview that is,  a list of
> one model and another model together (eg Books and Authors)
>
> --
> 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/915dbb5a-78bc-4d06-9a96-b0a43fa84be7%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/CAHn91ocSWw%2BMBaBcSfsGDquFQ0uqK9zr%3DN%2B%2B2TGMhaPmpKafRg%40mail.gmail.com.


Re: How to generate a unique 9 digit random id for every registered user?

2019-10-04 Thread Jani Tiainen
Note that above solution doesn't guarantee unique id. As it is a problem of
any pseudorandom generator.

So it is possible (but unlikely) that insertion fails.

pe 4. lokak. 2019 klo 18.12 Aldian Fazrihady  kirjoitti:

> import random
> import string
>
> from django.db import models
>
>
> def generate_random_code():
> return ''.join(random.choices(string.ascii_uppercase + string.digits, 
> k=9))
>
>
> class MyModel(models.Model):
> code = models.CharField(
> max_length=9, default=generate_random_code, db_index=True
> )
>
> Hi, please try the code above.
>
> On Fri, Oct 4, 2019 at 9:53 PM yashwanth .k 
> wrote:
>
>> Hello,
>>
>> My model consists of user details such as username and his id which is
>> auto-generated by DB(indexing).
>> Apart from this, I need to assign a random unique 9 digit number for
>> every user.
>> The reason for assigning a random number to a registered user is to
>> search a particular user using his permanent random id which we have
>> generated.
>>
>> Solutions with the model description will be very helpful.
>>
>>
>> Thank you!
>>
>> --
>> 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/8eb92ef2-ffe0-431d-b4aa-3d6c5a119c3f%40googlegroups.com
>> 
>> .
>>
>
>
> --
> Regards,
>
> Aldian Fazrihady
> http://aldianfazrihady.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/CAN7EoAYykEHF8qxAEc%2BPh71ue%3DKLzpT3P5MuE2Dw58gG2HmUEw%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/CAHn91oc4scdb1Vd5W9_pifq128kE87PRJ-ac_oiQbCe3QEMi5w%40mail.gmail.com.


Re: for loop template

2019-10-04 Thread Jani Tiainen
Counter0 only exists for variables declared within template itself for for
loops. Lista isn't for loop variable and thus it's always empty.


pe 4. lokak. 2019 klo 17.53 Luca Bertolotti 
kirjoitti:

> from the view i give to the template the following variables
>
> selezione = Dbasedett.objects.filter(idbase=mod_id, revdbase=rev_test)
> lista = ['test', 'test_one']
>
> Than i return render(.{'selezione':selezione, 'lista':lista}
>
> In the form i need to do this:
>
> 
>
> {% for dati in selezione %}
> 
> {{ dati.pos }} {{ dati.matr }} {{ 
> lista.forloop.counter0
> }}
> 
> {% endfor %}
>
> But {{ lista.forloop.counter0 }} is empty
>
> Any help
>
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ebb1381a-02a7-46b9-b9c1-0d064596bed7%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/CAHn91oe8Mq5WCtuqouqo0Rnhr-VqHg_L37a%2Bi2vDO6Dfp5gF-Q%40mail.gmail.com.


Re: compsite key

2019-10-04 Thread Jani Tiainen
Hi.

Django doesn't support composite keys.


pe 4. lokak. 2019 klo 14.47 narendra thapa 
kirjoitti:

> as i was trying to make a composite key on students model . i wanna make
> composite key of field enrolled year and roll no but django is not
> accepting a two primary key in same model
>
> --
> 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/ae2576ec-e3ae-4ec6-bbf0-e93e1965378e%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/CAHn91odh9%2BsyA9fBGMYWbR0rFFp0cUOjo5u2TkvuWePqJje1AA%40mail.gmail.com.


Re: Django 2.2.6 fails to serve some static files in Windows 10

2019-10-04 Thread Jani Tiainen
Also you never put STATIC_ROOT to STATICFILES_DIRS.

Because then you would with collectstatic command copy STATICFILES_DIRS to
STATIC_ROOT...


ke 2. lokak. 2019 klo 19.07 red sky  kirjoitti:

> My system: Windows 10 1903. Python 3.7.4, 64 bit.
>
> My directory structure:
> %USERPROFILE%/Desktop/myproject/manage.py
> %USERPROFILE%/Desktop/myproject/some_app (...)
> %USERPROFILE%/Desktop/myproject/myproject/db.sqlite3
> %USERPROFILE%/Desktop/myproject/myproject/urls.py
> %USERPROFILE%/Desktop/myproject/myproject/static (...)
> %USERPROFILE%/Desktop/myproject/myproject/static/css (...)
> %USERPROFILE%/Desktop/myproject/myproject/media (...)
> %USERPROFILE%/Desktop/myproject/myproject/some_apps (...)
> %USERPROFILE%/Desktop/myproject/myproject/settings/
> %USERPROFILE%/Desktop/myproject/myproject/settings/__init__.py
> %USERPROFILE%/Desktop/myproject/myproject/settings/settings_base.py
> %USERPROFILE%/Desktop/myproject/myproject/settings/settings_devel.py
> %USERPROFILE%/Desktop/myproject/myproject/settings/settings_production.py
>
>
> My urls.py (last part):
> if ENVIRONMENT=="development":
> import debug_toolbar
> urlpatterns += [path('__debug__/',include (debug_toolbar.urls))]
> urlpatterns += static(MEDIA_URL,document_root=MEDIA_ROOT)
> urlpatterns += static(STATIC_URL,document_root=STATIC_ROOT)
> urlpatterns += router.urls
>
> My settings:
>
> STATIC_URL = '/static/'
> STATIC_ROOT = os.path.join(BASE_DIR , 'static')
> MEDIA_ROOT = BASE_DIR + '/media/'
> (...)
> MEDIA_URL='/media/'
>
> I also tried with and without the following setting in several variants:
> STATIFCILES_DIRS = ["","//",STATIC_ROOT,
> "%userprofile%\\Desktop\\myproject\\myproject\\"]
>
> The template: The error happens both with  href="/static/css/styles.css" and
> {% load static %} (...) href="{% static css/styles.css}" . I think the
> template is not the problem here.
>
> The error:"GET /static/css/styles.css HTTP/1.1" 404 1767
>
> The error takes place also with static requests (
> http://127.0.0.1:8000/static/css/styles.css)
>
> Strange behaviour:
> If I change the setting static_url to STATIC_URL = "static/" the css file
> is served. However, debug_toolbar ceases to serve her own static files and
> doesn't work anymore ("GET
> /myproject/static/debug_toolbar/img/ajax-loader.gif HTTP/1.1" 404 14554)
>
> I have tried many things, to no avail.
>
> Thank you.
>
> --
> 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/aa231cc0-c3bf-4d3d-8bf0-6578d1952eff%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/CAHn91od2G_oN57oB_mAE-_%2B_wod30SoUWBTg%2BcXAvkSeaD04Pw%40mail.gmail.com.


Re: Django 2.2.6 fails to serve some static files in Windows 10

2019-10-04 Thread Jani Tiainen
Hi.

It seems that you have mixed some concepts here.

First you rarely need to manually serve static files in development. Django
takes care of that when using runserver.

STATIC_ROOT is location where static files are collected when you run
collectstatic management command. And that command you usually run when
deploying your site to production.

STATIC_URL is absolute path to static assets. With runserver django serves
static files using this url.

In production you usually need to configure your webserver to serve files
from STATIC_ROOT using url defined by STATIC_URL.

Media file serving is a different story and that you have to do yourself
since django doesn't have any default serving for them.

ke 2. lokak. 2019 klo 19.07 red sky  kirjoitti:

> My system: Windows 10 1903. Python 3.7.4, 64 bit.
>
> My directory structure:
> %USERPROFILE%/Desktop/myproject/manage.py
> %USERPROFILE%/Desktop/myproject/some_app (...)
> %USERPROFILE%/Desktop/myproject/myproject/db.sqlite3
> %USERPROFILE%/Desktop/myproject/myproject/urls.py
> %USERPROFILE%/Desktop/myproject/myproject/static (...)
> %USERPROFILE%/Desktop/myproject/myproject/static/css (...)
> %USERPROFILE%/Desktop/myproject/myproject/media (...)
> %USERPROFILE%/Desktop/myproject/myproject/some_apps (...)
> %USERPROFILE%/Desktop/myproject/myproject/settings/
> %USERPROFILE%/Desktop/myproject/myproject/settings/__init__.py
> %USERPROFILE%/Desktop/myproject/myproject/settings/settings_base.py
> %USERPROFILE%/Desktop/myproject/myproject/settings/settings_devel.py
> %USERPROFILE%/Desktop/myproject/myproject/settings/settings_production.py
>
>
> My urls.py (last part):
> if ENVIRONMENT=="development":
> import debug_toolbar
> urlpatterns += [path('__debug__/',include (debug_toolbar.urls))]
> urlpatterns += static(MEDIA_URL,document_root=MEDIA_ROOT)
> urlpatterns += static(STATIC_URL,document_root=STATIC_ROOT)
> urlpatterns += router.urls
>
> My settings:
>
> STATIC_URL = '/static/'
> STATIC_ROOT = os.path.join(BASE_DIR , 'static')
> MEDIA_ROOT = BASE_DIR + '/media/'
> (...)
> MEDIA_URL='/media/'
>
> I also tried with and without the following setting in several variants:
> STATIFCILES_DIRS = ["","//",STATIC_ROOT,
> "%userprofile%\\Desktop\\myproject\\myproject\\"]
>
> The template: The error happens both with  href="/static/css/styles.css" and
> {% load static %} (...) href="{% static css/styles.css}" . I think the
> template is not the problem here.
>
> The error:"GET /static/css/styles.css HTTP/1.1" 404 1767
>
> The error takes place also with static requests (
> http://127.0.0.1:8000/static/css/styles.css)
>
> Strange behaviour:
> If I change the setting static_url to STATIC_URL = "static/" the css file
> is served. However, debug_toolbar ceases to serve her own static files and
> doesn't work anymore ("GET
> /myproject/static/debug_toolbar/img/ajax-loader.gif HTTP/1.1" 404 14554)
>
> I have tried many things, to no avail.
>
> Thank you.
>
> --
> 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/aa231cc0-c3bf-4d3d-8bf0-6578d1952eff%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/CAHn91oetF9CMNjSH_zXTccN8oqtLWKj1nf95CVgFmz2WeBvu%2Bg%40mail.gmail.com.


Re: MongoDB Connect with Django

2019-09-29 Thread Jani Tiainen
Hi.

Personally I even would try to use any special backend that tries to map
non-relational database with tool (ORM) that is meant for relational
database.

You can connect to mongodb just fine with plain python connector and read
data from there. You don't need anything magical for it.

Of course you are not able to use some things mainly ones that do relate
ORM. But that sacrifice you did already.


la 28. syysk. 2019 klo 17.00 'Abhishek Sharma' via Django users <
django-users@googlegroups.com> kirjoitti:

> Error during connecting Django with MongoDB, Please help on it.
>
> django.core.exceptions.ImproperlyConfigured: 'django_mongodb_engine' isn't
> an available database backend.
> Try using 'django.db.backends.XXX', where XXX is one of:
> 'mysql', 'oracle', 'postgresql', 'sqlite3'
>
>
>
> *Regards,*
> Abhishek
>
>
> On Fri, Sep 27, 2019 at 9:18 PM Kasper Laudrup 
> wrote:
>
>> On September 27, 2019 3:56:03 PM GMT+02:00, 'Abhishek Sharma' via Django
>> users  wrote:
>>>
>>> Hi Guy,
>>>
>>> My question is, I'm trying to connect mongodb from localhost using dango
>>> freamwork.
>>>
>>> Realy greatfull if any budy help on it.
>>>
>>> Regards,
>>> Abhishek
>>>
>>>
>>> On Fri, Sep 27, 2019, 6:43 PM Kasper Laudrup 
>>> wrote:
>>>


 On 27/09/2019 14.47, 'Abhishek Sharma' via Django users wrote:
 > Thanku! Kasper but i didn't find a solution
 >

 Then it would probably be easier for people to help you with a solution
 if you started by clarifying what your problem is...

 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/7166e14c-f156-f5ee-17a3-5e978293b52c%40stacktrace.dk
 .

>>>
>>>
>>>
>>>
>>> --
>>>
>>> The information in this e-mail and any attachments is confidential and
>>> may be legally privileged. It is intended solely for the addressee or
>>> addressee's. If you are not an intended recipient, please delete the
>>> message and any attachments and notify the sender of nondelivery. Any use
>>> or disclosure of the contents of either is unauthorised and may be
>>> unlawful. All liability for viruses is excluded to the fullest extent
>>> permitted by law. Any views expressed in this message are those of the
>>> individual sender, except where the sender states them, with requisite
>>> authority, to be those of the organisation.
>>>
>>>
>> Hi buddy,
>>
>> That's not a question.
>>
>> What have you tried so far?
>>
>> Did you follow the instructions that someone was kind enough to send you
>> a screenshot of?
>>
>> Which errors did you get, where's your code?
>>
>> Your not going to get any help until you figure out how to ask a question
>> that someone can actually answer.
>>
>> Kind regards,
>>
>> Kasper
>>
>> --
>> 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/890A2FB0-C7C9-47DC-9FB1-678A7D68F73A%40stacktrace.dk
>> 
>> .
>>
>
>
>
>
> --
>
> The information in this e-mail and any attachments is confidential and may
> be legally privileged. It is intended solely for the addressee or
> addressee's. If you are not an intended recipient, please delete the
> message and any attachments and notify the sender of nondelivery. Any use
> or disclosure of the contents of either is unauthorised and may be
> unlawful. All liability for viruses is excluded to the fullest extent
> permitted by law. Any views expressed in this message are those of the
> individual sender, except where the sender states them, with requisite
> authority, to be those of the organisation.
>
> --
> 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/CADXAtDYfPft7Jder7CXP1OHQ6UMOghoMvimOhdeFLq7fcc-vgg%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 

Re: Template linting

2019-09-28 Thread Jani Tiainen
Hi.

It could be intetesting thing to play with for example pyparsing-library.

But to my knoledge there is (not yet) such a linting tool.


la 28. syysk. 2019 klo 17.00 Tobias Bengfort 
kirjoitti:

> Hi,
>
> I was wondering whether there are any good options for linting HTML
> templates. I have searched for a while, but all I found falls into one
> of these categories:
>
> - half baked attempts that were abandoned at some point
> - HTML linters that get confused by template syntax
> - template linters for specific template languages, but not django
>
> My main motivation is finding missing closing tags in HTML, but anything
> on top of that would be welcome.
>
> I cannot be the first person with this question. How do you check your
> templates?
>
> tobias
>
> --
> 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/590a6d82-1112-9c1f-dfcf-3e41473d0b42%40posteo.de
> .
>

-- 
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/CAHn91oc4WUh0HAtg68ajtgBEF5n47dO2hikU7i1FqO78TRpKBw%40mail.gmail.com.


Re: list records of another app in another app

2019-09-24 Thread Jani Tiainen
Hi.

Just import models and use them?

ti 24. syysk. 2019 klo 22.10 Perceval Maturure 
kirjoitti:

>
> Hi awesome django users
> i want to list model records of App1 in  a detail view of App2
> any ideas?
> Regards
>
> --
> *Perceval Maturure*
>
> *083 303 9423*
>
> --
> 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/CAFZtZmAH2ObYHnCwmAkU0uBd8WK%3D0ch%2BVriJRVpu0w9FJKQ3DA%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/CAHn91oekrTWY%3DjYEEdCjvWso2DqwdrT-kKTA8nCM5LkQbtZPvA%40mail.gmail.com.


Re: Transaction.atomic()

2019-09-23 Thread Jani Tiainen
And TL;DR; versio.

Code which is wrapped within atomic transaction will guarantee that if code
breaks changes are rolled back.

ma 23. syysk. 2019 klo 15.42 Aryan Patel  kirjoitti:

> Hi colleagues,
>
> I want to understand if transaction.atomic() in django guarantees that the
> client is getting status what the django is sending?
>
> This question is just for discussion whether the django builds a pipeline
> with the client and if the network broke down while the django is sending
> the status then transaction.atomic will be reverted back or it will
> successfully commits regardless whether the client is getting status or
> not?
>
> --
> 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/571c334b-9508-41e7-b360-2d312774c192%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/CAHn91oeob-NwqPq6w5CsojZqmLTdLsVx_61-EL5vG-V-%3D2fGxw%40mail.gmail.com.


Re: queryser variable from template to a view

2019-09-18 Thread Jani Tiainen
Well that is the side-effect of capturers they convert value to desired
format.

You can find documentation about pre-defined converters and how to register
your own at
https://docs.djangoproject.com/en/2.2/topics/http/urls/#path-converters


ke 18. syysk. 2019 klo 19.33 Luca Bertolotti 
kirjoitti:

> Hello
> if i pass 
> and in the view i do this
>
> def exmple(request,myvar):
>   sort = myvar.order_by()
> i get an error because myvar is a string instead i near a query set
>
> Luca
>
> Il giorno mercoledì 18 settembre 2019 15:56:19 UTC+2, Jani Tiainen ha
> scritto:
>>
>> Hi.
>>
>>  to the rescue!
>>
>> Also it is recommended to use {% url %} tag to construct urls not to
>> hardcode them and once were there Django convention is to end urls to slash.
>>
>> ke 18. syysk. 2019 klo 15.53 Luca Bertolotti 
>> kirjoitti:
>>
>>> Hello i need to pass a query set from template to a view:
>>>
>>> 
>>>
>>> in which way i have to define the urls file
>>>
>>> path('test//***what to write+++', views.test, name='test'),
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/2ad42877-766c-49b9-af51-e67007af80f9%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/2ad42877-766c-49b9-af51-e67007af80f9%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
> 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/22af4b9c-839d-4d8a-ab73-94c2f6c72466%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/22af4b9c-839d-4d8a-ab73-94c2f6c72466%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAHn91ocKUjJHzggSGsSzmDMwLpvmxCPzV1DZYfRb%2BhLhpg8vAQ%40mail.gmail.com.


Re:

2019-09-18 Thread Jani Tiainen
Hi.

Technically that is impossible.

Group by is used to make sql aggregate to know aggregation criteria.

Let's take simple example:

Let's have table with columns name, job and salary.

Rows in table would be:

Jani,programmer,100
Ahmmed,programmer,100

Now lets calculate average salary of programmer:

select job, avg(salary) from table group by job

Now selecting name there doesn't make sense. If you would like actually
represent names with average  salary you can do that by joining temporary
table. So query would look like this:

select *,b.avg from table a join (select job, avg(salary) as "avg" from
table) b join a.job = b.job

This should be possible with pure django as well.


ke 18. syysk. 2019 klo 9.46 Shakil Ahmmed 
kirjoitti:

>
> How to select all field but group by one field
> --
>
> 
> Shakil Ahmmed
> about.me/shakilahmmed
> 
>
> --
> 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/CA%2BEpJfzNPZ_vRqyHan92VsDY9MAjsxogKVh4FEBdwXWLd%3DHXtQ%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/CAHn91oerN_kMNvi%3DDJQXr9_oSWRncNO%2BmkbkbE7Naies%3DfTD_Q%40mail.gmail.com.


Re: queryser variable from template to a view

2019-09-18 Thread Jani Tiainen
Hi.

 to the rescue!

Also it is recommended to use {% url %} tag to construct urls not to
hardcode them and once were there Django convention is to end urls to slash.

ke 18. syysk. 2019 klo 15.53 Luca Bertolotti 
kirjoitti:

> Hello i need to pass a query set from template to a view:
>
> 
>
> in which way i have to define the urls file
>
> path('test//***what to write+++', views.test, name='test'),
>
> --
> 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/2ad42877-766c-49b9-af51-e67007af80f9%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/CAHn91odFE%2Bk07BwQzr8sBjwe1e9wevM2SutVzMs2uhxvKkTsjw%40mail.gmail.com.


Re: ORM

2019-09-17 Thread Jani Tiainen
Most tools are capable of exporting uml to code format. A little googlin
should help.

ma 16. syysk. 2019 klo 18.57 Yann Mbella 
kirjoitti:

> I needed the contrary having uml diagrams and generating models from
> does diagram
>
> Le lun. 16 sept. 2019 à 16:43, Yann Mbella  a
> écrit :
>
>> Thanx for the information
>>
>> Le ven. 13 sept. 2019 à 06:24, Jani Tiainen  a écrit :
>>
>>> Hi.
>>>
>>> There exists django-extensions package that has management command to
>>> make UML diagram for your models.
>>>
>>>
>>> pe 13. syysk. 2019 klo 5.22 Yann Mbella 
>>> kirjoitti:
>>>
>>>> Got little problem is it possible to have a plugin which mapps or
>>>> reproduce my class diagrams drawn in an IDE of UML in my models app
>>>>
>>>> --
>>>> 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/13525e44-e176-409a-a55e-0595834c780f%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/13525e44-e176-409a-a55e-0595834c780f%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>> --
>>> 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/CAHn91odRe_26%3DuuAwCQOOapK_UeKPE1tOtmXQP-df8%3Dnxf4k3g%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAHn91odRe_26%3DuuAwCQOOapK_UeKPE1tOtmXQP-df8%3Dnxf4k3g%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
> 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/CAEaFv0FoE4D8_zNNv%2B3T3HUx1AzF%3DgGFPjUFLVL0sqQzc6Vtsg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAEaFv0FoE4D8_zNNv%2B3T3HUx1AzF%3DgGFPjUFLVL0sqQzc6Vtsg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAHn91odykqZaVd6jup5Di7R_P1Fp0%2BFS2UWDRrKVJfavZRWm0g%40mail.gmail.com.


Re: Django Post request erro

2019-09-13 Thread Jani Tiainen
Hi.

Could you describe exactly in both cases:
What do you expect to happen? What does actually happen!

Also instead of using hardcoded urls you should always use {% url %} tag to
form urls in templates.

pe 13. syysk. 2019 klo 16.53 Ruturaj Singare 
kirjoitti:

> Hi Everyone I got one problem I have 2 form in index.html but having its
> own url pattern but both forms redirects to on e url using post request can
> you please help me.
>
> I am your regular subscriber on youtube
> Please help
>
> My url patterns :
>
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('', views.index, name='index'),
> path('home', views.index, name='index'),
> path('paid', views.paid, name='paid')
> ]
>
>
> My index.html form section
>
>  
> 
> {% csrf_token %}
> 
> 
>
>   
>   
> 
>   Sr. No
>   Menu Items
>   Quantity
> 
>   
>   
>  {% for order in orderList %}
> 
>   {{ forloop.counter }}
>   {{ order.MenuItem }}
>   {{ order.Qty }}
> 
> {% endfor %}
>   
> 
>  
>   {% csrf_token %}
>   
>   
>  
>   
>
>
>
> 
>
> I think all ok but not working
>
> --
> 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/CAEhU20eLZt-%2B4u-kntwUzLL%3DO2vBbYXZ1FthB5Jn90Pb7wOT3Q%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/CAHn91ocXQ-%3D3q%3D-x9gLVAbg%3Dkv%3DbA7zKPFA9RrJzpb_BHvtkug%40mail.gmail.com.


Re: ORM

2019-09-12 Thread Jani Tiainen
Hi.

There exists django-extensions package that has management command to make
UML diagram for your models.


pe 13. syysk. 2019 klo 5.22 Yann Mbella  kirjoitti:

> Got little problem is it possible to have a plugin which mapps or
> reproduce my class diagrams drawn in an IDE of UML in my models app
>
> --
> 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/13525e44-e176-409a-a55e-0595834c780f%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/CAHn91odRe_26%3DuuAwCQOOapK_UeKPE1tOtmXQP-df8%3Dnxf4k3g%40mail.gmail.com.


Re: Maps API

2019-09-12 Thread Jani Tiainen
Hi.

I had workshop about geotracking and Django at Djangocon eu 2019.

You can find my material at http://dceu2019.tiainen.cc

to 12. syysk. 2019 klo 17.33 Aniket Jain 
kirjoitti:

> Hello guys,
> Hey anyone is having idea that which API we can use for the grps tracking
> system for the vechiles like Uber and ola.
>
> --
> 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/CADV%2BovL2fdAiu5wqoEDXw3aKgVRW_FSAud3uE%3D_Nux-4vsEzCQ%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/CAHn91offTpSmUc-u16AHg50buOWWa6kL%3DoVu%2Bx2cUNJwR_F4%3DQ%40mail.gmail.com.


Re:

2019-09-10 Thread Jani Tiainen
Please paste your errors as plain text.

Images are really hard to read in mobile devices and searching image for
keywords is really impossible.

ti 10. syysk. 2019 klo 23.36 Duncan Jerry 
kirjoitti:

> you should post images of the errors you are getting so that its easy for
> us to figure out a solution for you
>
> On Tue, Sep 10, 2019 at 1:09 PM Abhishek Ghaskata <
> abhishekghaskata1...@gmail.com> wrote:
>
>> I am getting error models has no 'objects' member.
>> So what should I do?
>>
>> --
>> 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/CA%2B5xdHPwjnyUVC_gw-QS9SW75RFj6obHvNJkKrwxtKSSmZQMzg%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/CAA8zVqug8iPVo3V2CB_A5tqTVVo1NQyU8Tk07VqH8kQbjj2kfA%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/CAHn91ofa9s0CHEKPcCjuY8EqJYMNxPqLryBTE5ghSScdvc6cMQ%40mail.gmail.com.


Re: Python +django

2019-09-08 Thread Jani Tiainen
Hi.

You're on good track.

Using Django doesn't require much but knowing Python, HTML and CSS surely
helps.

Django Girls do have excellent tutorial to get you kickstarted with Django.

CSS can be easily handled with libs like bootstrap or material ui.

What comes to programmin itself it takes a good while to learn. Few months
and you will handle most tasks with rather easily.

su 8. syysk. 2019 klo 21.09 kemo0 king  kirjoitti:

> I am new on programming  ,to be a programmer and getting the ability to
> create a web program that is one of my dreams , I have started   with
> python  I know little about html and css and js now I want to learn django
> am I on the right  way what should I learn before diving in django  I need
> ur help
>
> --
> 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/69cfa675-0023-464b-a4ad-080f4c59db4d%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/CAHn91od6KXyi28tE55TuuRvZvDaibH5H3xS5Q6%2BTHavby20iRw%40mail.gmail.com.


Re: styling tables in django

2019-09-01 Thread Jani Tiainen
Hi.

Templates are just a text and very common thing is to render templates as
html.

So there is no magic involved what comes to styling. It is just CSS which
would make your tables styled. And that is beyond Django.

If you want to use CSS file as included as a link in html header part there
exists small magic which comes into play  - static files.

Django Girls tutorial also have quite nice part about styling that you
might want to read.

If

su 1. syysk. 2019 klo 1.52 Kean  kirjoitti:

> Hi,
>
> New to Django, appreciate the guidance,
>
> I'm looking to style template so both header and data records are note
> wrapped.
> please see current setup.
>
> Please can anyone help with the template code, appreciate, it's not quite
> django, but more bootstrap4 django.
>
> Best,
> K
>
>
>
>
>
> --
> 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/ec35ddf7-12ff-47cc-a41e-4b6736faed22%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/CAHn91ofTehEXZqyKyOpO_cXAh4MgWuiz624W%3DCQQW_aW35Q0UA%40mail.gmail.com.


Re: Unsynchronized sequence

2019-08-30 Thread Jani Tiainen
Hi.

You really need to give more context than that.

What you exactly did? What you expected to happen? What was the actual
outcome? Preferably with all commands and code you used with responses you
got.

ke 28. elok. 2019 klo 16.49 Ezequias Rocha 
kirjoitti:

> Hello everyone
>
> I am using django rest framework and I noticed that even I changing the
> current sequence in my database (PostgreSQL) the next element in database
> (generated by django) isn't created as I expect.
>
> Could someone tell me if you have experienced this before?
>
> Best regards
> Ezequias
>
> --
> 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/60700f56-aed8-44f3-902a-d084b13407df%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/CAHn91oeRPekNb-FgCrbFKXZCYctQaF%2ByAitnJeZvSbdVvJVkQw%40mail.gmail.com.


Re: How to find out when a fix will be released

2019-08-27 Thread Jani Tiainen
Oh yes there it is explained in depth

https://docs.djangoproject.com/en/dev/internals/release-process/#supported-versions

ke 28. elok. 2019 klo 8.12 Jani Tiainen  kirjoitti:

> It's not weird at all. Django has 8 month release cycle. Usually only bugs
> that are security issues or causes data loss are backported to older
> releases.
>
> I think this procedure is documented somewhere...
>
> ke 28. elok. 2019 klo 8.06 wd  kirjoitti:
>
>> It's so weird, the code is already in master 7 months, but still not
>> released yet?
>>
>> On Wed, Aug 28, 2019 at 6:09 AM John MacLaughlin <
>> john.maclaugh...@carbonlighthouse.com> wrote:
>>
>>> I see this ticket was addressed, fixed, and merged. However, it's not in
>>> the latest release (2.2.4)
>>>
>>> Ticket: https://code.djangoproject.com/ticket/29393
>>> PR: https://github.com/django/django/pull/10730
>>>
>>> How can I find out when this fix will be released?
>>>
>>> --
>>> 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/639528f1-a182-4818-a836-e65cfbf3d1d4%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/639528f1-a182-4818-a836-e65cfbf3d1d4%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> 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/CABexzmi8ad8r6n978Bs-O1A0_T-FX3fS%2BnJL-iGeyKokHWRJjg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CABexzmi8ad8r6n978Bs-O1A0_T-FX3fS%2BnJL-iGeyKokHWRJjg%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/CAHn91ofghfnRgfqMA7L9ntp3MgqKFr7uEw%2BRFdVKxtXMcvmU7w%40mail.gmail.com.


Re: How to find out when a fix will be released

2019-08-27 Thread Jani Tiainen
It's not weird at all. Django has 8 month release cycle. Usually only bugs
that are security issues or causes data loss are backported to older
releases.

I think this procedure is documented somewhere...

ke 28. elok. 2019 klo 8.06 wd  kirjoitti:

> It's so weird, the code is already in master 7 months, but still not
> released yet?
>
> On Wed, Aug 28, 2019 at 6:09 AM John MacLaughlin <
> john.maclaugh...@carbonlighthouse.com> wrote:
>
>> I see this ticket was addressed, fixed, and merged. However, it's not in
>> the latest release (2.2.4)
>>
>> Ticket: https://code.djangoproject.com/ticket/29393
>> PR: https://github.com/django/django/pull/10730
>>
>> How can I find out when this fix will be released?
>>
>> --
>> 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/639528f1-a182-4818-a836-e65cfbf3d1d4%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/CABexzmi8ad8r6n978Bs-O1A0_T-FX3fS%2BnJL-iGeyKokHWRJjg%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/CAHn91oebax64wepMOxuh2vWsVzYuBGPhsbfHDXymf%3Dx8m_h5Ww%40mail.gmail.com.


Re: Django real-time chat app

2019-08-27 Thread Jani Tiainen
Hi.

Greatly depends on your definition of real-time...

ti 27. elok. 2019 klo 8.01 Suraj Thapa FC 
kirjoitti:

> Anyone have real-time pluggable chat system app in 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/CAPjsHcENui0Yv%2BnVYpEtxyo0ZOtwjQ6b1tCv_xtUpzW3VLMT%3Dg%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/CAHn91oesbX9usLfWeH7nya1590AF_JG0K4eCw9kfcY%3DbGKEpbQ%40mail.gmail.com.


Re: Database Views

2019-08-27 Thread Jani Tiainen
Hi.

You really need to provide more context. Without knowing your data, tables
involved in a view. Your model and query you used and query you used to
verify wrong (or correct) results it is virtually impossible to help you
further.


ti 27. elok. 2019 klo 17.47 HULUGESH B  kirjoitti:

> Hi All,
>
>
> I am facing issues in Django Models:
>
> If connect databse views in models.
>
> It shows less records than actual number of records. Kindly assist me. How
> to solve. This is not all the time.. sometimes it is correct sometimes not
> correct.
>
> --
> 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/29c228cc-295a-487e-a5df-afb1471b8730%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/CAHn91ocVY%2B-Z-9_GYKa0gbT5MCg%2Bh%2BvBzfLEgVf5QmnArV%2BaZw%40mail.gmail.com.


Re: How to customize admin page rendering?

2019-08-25 Thread Jani Tiainen
Hi.

Instead of trying that I suggest that you build your own managenent console
where you can do all you want to.

Admin is a great tool but it can't replace proper management tools. Mainly
because admin isn't built for much of customization beyond what you can
find from the docs.

su 25. elok. 2019 klo 17.17 Pema Galey  kirjoitti:

> I want to change/customize rendering of admin default page. For example,
> in search_field, I want to add placeholder or help text for searching.
>
> Help me in customization.
>
> Thank you
>
> --
> 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/f2544e7b-7bf8-4c73-9384-4a932233a319%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/CAHn91oeGnxv%3DwR8XQrPxsROugi5p8WRQTkLANzauqGAxSiQikw%40mail.gmail.com.


Re: Best DRF Cheatsheet?

2019-08-21 Thread Jani Tiainen
Hi.

Wouldn't it be much better to improve DRF documentation itself rather than
create yet an another documentation that you have to maintain?

ke 21. elok. 2019 klo 19.58 Charles Thayer  kirjoitti:

> I've been using Django with DRF off and on for probably over 5 years now.
> There are still parts that I'm always needing to look up and review. Anyone
> know of a one-pager cheatsheet that covers all the annoying details well,
> like read_only vs write_only vs required, and nesting serializers, etc.?
>
> Thanks,
> /charles
>
> --
> 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/d768f5b6-c52d-4831-bf0a-aa27ca366d47%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/CAHn91ocpv2RH4b1DTd1QHReC965bAWvNYb6wfo8KHDYehMKXFg%40mail.gmail.com.


Re: Postgres along with Mongodb

2019-08-12 Thread Jani Tiainen
Hi.

Yes you can. Of course since mongodb isn't relational database you get best
experience by using native python api to mongodb and Django orm for
postgres.


ma 12. elok. 2019 klo 15.57 Suraj Thapa FC 
kirjoitti:

> How can I use postgres along with Mongodb
> Different table different db
>
> --
> 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/CAPjsHcFTL%2BQXENUo5MuffZo%2BsQ-TRvJ_ksqLG9_BTktGrLToLA%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/CAHn91oetCWG2A%3DbQMCCXV-BStvfA_G%2B9uTGZTFM2c%3DravOJrsw%40mail.gmail.com.


Re: Storing credentials in the DB

2019-08-12 Thread Jani Tiainen
Unfortunately storing password in db has a fundamental flaw. To be able to
use to access any remote source it has to be in usable form. Wether
digested or plain text form it doesn't matter since at the moment you use
it to login other resource it is in plain format (whatever format that is).


ma 12. elok. 2019 klo 16.24 Sundararajan Seshadri 
kirjoitti:

> If I understand is right, user stores the credentials in a database, say A
> and another application, probably using a different database B wants to use
> the credentials from A.
>
> Right?
>
> There is no problem at all, except you need to:
>
> (a) write your own hook for validating the password in the application
> using the database B, but will access the credentials in A. Either you can
> define A in django itself or through plain Python itself, you can access it.
>
> (b) Note that the password will be (and should be) stored encrypted and
> 'normally' you will be in no position to 'decode' the original password.
> Whatever password is entered while using the application will be subject to
> same encryption and the result will be compared with what is in the
> database for allowing the login. Hopefully this mechanism is still OK for
> you.
>
> Cheers.
>
> =
>
> On Sunday, August 11, 2019 at 7:01:26 PM UTC+5:30, Lance Haig wrote:
>>
>> Hi,
>>
>> I want to allow users to add credentials to th site that allow us to
>> pull details ffrom anothr site into our environment.
>>
>> This will mean that their credentials will need to be useable by a
>> regular process that will fetch the data but it is stored securely.
>>
>> I was thinking about using the same storage mechanisim for the passwords
>> that django offers but I am not sure how one would then allow a process
>> in the application to use those credentials to aces the otehr site.
>>
>> Does anyone have a suggestion on how to accomplish this?
>>
>> Regards
>>
>> Lance
>>
>>
>> --
> 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/6c1ab523-b622-44b6-9e65-d2731ed05df1%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/CAHn91odcosmCvpPqj%3DCiC8LDjs5yhfivejpZnMOC1PnW%2BCAKTw%40mail.gmail.com.


Re: Django parameters

2019-08-12 Thread Jani Tiainen
Hi.

Yes and no.

Django isn't cms but web application development library written in python.

So yes you can do all those things. How much work and effort it requires
depends on many factors.


ma 12. elok. 2019 klo 14.13 tomas mracnik 
kirjoitti:

> Hi, we are considering a new cms system in our company. Does Django allows
> features like customize widget , emmbeding and single sign-on Active
> directory or office 365 ? Thank you for your answers.
>
> --
> 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/e38b9731-bca7-4edb-ba80-3e4bf1d670dc%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/CAHn91oeupMefg7YHsg54PRGc04c3kTZZDCGdV7dg0XFrvKPkxw%40mail.gmail.com.


Re: database migrations

2019-08-04 Thread Jani Tiainen
Hi.

To me this sounds more debugging issue than migrations or database problem.

Since it is most definitely your code that doesn't work right.

Of course if youre building and testing features that fill thousands of
entries or relatively complex data there are options.

Personally I use "template database". Rather big db but at least it is in
known state.

You could have scripts to populate db after creation. Many ways to do that
as well.

la 3. elok. 2019 klo 13.19 Perceval Maturure 
kirjoitti:

> Question is what’s the best way forward to avoid situations where u will
> have to create a new database if ur applications do not work with the
> current databases so as to avoid populating the database with data again
>
>
>
>
> Sent from my iPhone
>
> On 02 Aug 2019, at 14:39, Perceval Maturure  wrote:
>
> Dear all
> creating a new database as applications increase has been one of the
> solutions to some of the errors i have encountered especially after adding
> a django cms by hand in my development environment.
>
> i cant imagine a situation like that in a production environment as this
> will mean re-entry of data.
> please share some thought*
> Regards
> --
> *Perceval Maturure*
>
> *083 303 9423*
>
> --
> 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/2D3BA6A6-EDC6-4599-B519-64593AE64A1F%40gmail.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/CAHn91od2f91AxBwRKPXDHPG8D0_%3D-aMTReya%2BxH%2B_5K6O%3DWyGA%40mail.gmail.com.


Re: database migrations

2019-08-03 Thread Jani Tiainen
Hi.

So... what is the actual question?

pe 2. elok. 2019 klo 15.40 Perceval Maturure 
kirjoitti:

> Dear all
> creating a new database as applications increase has been one of the
> solutions to some of the errors i have encountered especially after adding
> a django cms by hand in my development environment.
>
> i cant imagine a situation like that in a production environment as this
> will mean re-entry of data.
> please share some thought*
> Regards
> --
> *Perceval Maturure*
>
> *083 303 9423*
>
> --
> 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/CAFZtZmBdeYCM0HXUkuM2k1V%3D_6B%3DUUDr%3DNZn77yun0On_gsDuA%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/CAHn91ofV7kcy60fucbTgQBVXgohhoXLZMtJDFPfJ9zp7qThxFg%40mail.gmail.com.


Re:

2019-07-29 Thread Jani Tiainen
My mistake.

I thuought that OP was asking about uploading and storing multiple files to
model.

First part (uploading) is easy since docs do cover that.

Second part is tricky since it requires data structure capable of storing
multiple files and there are so many ways to do that.



ma 29. heinäk. 2019 klo 18.22 Aldian Fazrihady 
kirjoitti:

> Multiple file uploads already there for many years. The link I shared
> above show you how to do that the Django way.
>
> Regards,
>
> Aldian Fazrihady
> http://aldianfazrihady.com
>
> On Mon, 29 Jul 2019, 21:52 Jani Tiainen,  wrote:
>
>> Hi.
>>
>> TL; DR; you can't.
>>
>> You though can upload multiple files just fine you just need to handle
>> them manually.
>>
>> Also if you plan to keep files around your models must enable that.
>>
>>
>> ma 29. heinäk. 2019 klo 15.48 Suraj Thapa FC 
>> kirjoitti:
>>
>>> How can I create a file field which one can upload Multiple files in
>>> it...
>>>
>>> --
>>> 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/CAPjsHcE%2BMSVGHiQ0bx4z_2pxMMiE57FD44kFn4hE%3DsSLaj66kw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAPjsHcE%2BMSVGHiQ0bx4z_2pxMMiE57FD44kFn4hE%3DsSLaj66kw%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> 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/CAHn91of_AD_METU8A3J4qhHo_E93Qd4hJyS73uRQh43GpRsAgg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAHn91of_AD_METU8A3J4qhHo_E93Qd4hJyS73uRQh43GpRsAgg%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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/CAN7EoAYAh%2Bou8fyzcBhyHn25SDx7%3D3Vw%2BY7OGY2%2B%3D3fjk-C0kg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAN7EoAYAh%2Bou8fyzcBhyHn25SDx7%3D3Vw%2BY7OGY2%2B%3D3fjk-C0kg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
>

-- 
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/CAHn91odErG3F4HGUCBFFh6oQdmg3CEDC2N3gCLNUUeUPrm1bbw%40mail.gmail.com.


Re:

2019-07-29 Thread Jani Tiainen
Hi.

TL; DR; you can't.

You though can upload multiple files just fine you just need to handle them
manually.

Also if you plan to keep files around your models must enable that.


ma 29. heinäk. 2019 klo 15.48 Suraj Thapa FC 
kirjoitti:

> How can I create a file field which one can upload Multiple files in it...
>
> --
> 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/CAPjsHcE%2BMSVGHiQ0bx4z_2pxMMiE57FD44kFn4hE%3DsSLaj66kw%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/CAHn91of_AD_METU8A3J4qhHo_E93Qd4hJyS73uRQh43GpRsAgg%40mail.gmail.com.


Re: forms.Form with class in html-rendering

2019-07-28 Thread Jani Tiainen
Hi.

Be aware that pushing rendering data like styles to form code has a nasty
drawback.

If you want to change that it is code change. And at some point it will get
burden to maintain styles in code.

There are few options still. Recent versions of django renders widgets
using templates. Use that.

There are few libs like django-sniplates that allows same.

Finally you don't even need to use form rendering. You can write html
manually. (This is what I do usually)

su 28. heinäk. 2019 klo 17.28 Kai Kobschätzki 
kirjoitti:

> Hi Juhana,
>
> thanks for the fast response! This is helpfull, I will study it :)
>
> Best Greetings
> bengoshi
> On 7/28/19 4:13 PM, Juhana Jauhiainen wrote:
>
> Hi,
>
> You can achieve this by customizing the widget which renders the HTML for
> the form field. You can find more information in the documentation here
> https://docs.djangoproject.com/en/2.2/ref/forms/widgets/
>
> -Juhana
>
> On Sun, 28 Jul 2019 at 16.57, Kai Kobschätzki 
> wrote:
>
>> Heiho,
>>
>> I wrote a class in views.py
>>
>> class UploadFileForm(forms.Form):
>> file = forms.FileField()
>>
>> and I use it in a function like
>>
>> def import_data(request):
>> if request.method == "POST":
>> form = UploadFileForm(request.POST,
>>   request.FILES)
>> [...]
>>return render(
>>   request,
>>   'import_form.html',
>>  {
>> 'form': form,
>>  [...]
>>
>> in my template import_form.html I embedded with
>>
>> {{ form }}
>>
>> It renders to
>>
>> File:> name="file" required id="id_file">
>>
>> All fine, all things do what they should do.
>>
>> But I want to insert in this rendering such thing like class="btn btn-info", 
>> so it would render
>> .
>>
>> How is it possible? I wasn't able to find anything in the documentation.
>>
>> Thanks for your help,
>>
>> bengoshi
>>
>>
>>
>>
>> --
>> 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/6341d842-c40d-b84e-fe6f-d35c188b332b%40gmail.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/CABScFx8P0Ov9S%3D3nxeHOR36n-D%3Dh4cjCk0cijFjEfmwsxP9jQQ%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/0db13a21-be1b-2297-fbc4-c9cbcd9a09ff%40gmail.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/CAHn91ocnEw0yNW7ivy-NNK8poWuBj4h7Mc05ie6xBjXn-DiMiQ%40mail.gmail.com.


Re: Overriding methods in models of other developers

2019-07-27 Thread Jani Tiainen
You  can do that with proxy models which allows you to override and add
methods.

Of course if there is a need to really modify original model it gets tricky.

la 27. heinäk. 2019 klo 10.49 אורי  kirjoitti:

> Hi,
>
> I had to change the following lines because tests failed:
>
> class Friend1(object):
> def __str__(self):
> return "User {} is friends with {}".format(self.to_user, 
> self.from_user)
>
>
> class FriendshipRequest1(object):
> def __str__(self):
> return "Friendship request from user {} to {}".format(self.from_user, 
> self.to_user)
>
>
> Friend.__str__ = Friend1.__str__
> FriendshipRequest.__str__ = FriendshipRequest1.__str__
>
>
> אורי
> u...@speedy.net
>
>
> ‪On Sat, Jul 27, 2019 at 9:26 AM ‫אורי‬‎  wrote:‬
>
>> Django users,
>>
>> I want to override def __str__ of models I'm using, but the models are
>> maintained by other developers. I think the __str__ is only used by the
>> admin interface. I found out that I can do something like this:
>>
>> from django.contrib import admin
>> from django.contrib.sites.models import Site
>> from django.contrib.auth.models import Group
>>
>> from friendship.models import Follow, Friend, FriendshipRequest, Block
>>
>>
>> class ReadOnlyModelAdmin(admin.ModelAdmin):
>> """
>> ModelAdmin class that prevents modifications through the admin.
>>
>> The changelist and the detail view work, but a 403 is returned
>> if one actually tries to edit an object.
>> """
>> actions = None
>>
>> # We cannot call super().get_fields(request, obj) because that method 
>> calls
>> # get_readonly_fields(request, obj), causing infinite recursion. Ditto 
>> for
>> # super().get_form(request, obj). So we assume the default ModelForm.
>> def get_readonly_fields(self, request, obj=None):
>> return self.fields or [f.name for f in self.model._meta.fields]
>>
>> def has_add_permission(self, request):
>> return False
>>
>> # Allow viewing objects but not actually changing them.
>> def has_change_permission(self, request, obj=None):
>> return (request.method in ['GET', 'HEAD'] and 
>> super().has_change_permission(request, obj))
>>
>> def has_delete_permission(self, request, obj=None):
>> return False
>>
>>
>> admin.site.unregister(Site)
>> admin.site.register(Site, ReadOnlyModelAdmin)
>>
>> admin.site.unregister(Group)
>> # admin.site.register(Group, ReadOnlyModelAdmin)
>>
>> admin.site.unregister(Block)
>> admin.site.unregister(Follow)
>> admin.site.unregister(Friend)
>> admin.site.unregister(FriendshipRequest)
>> # admin.site.register(Block, ReadOnlyModelAdmin)
>> # admin.site.register(Follow, ReadOnlyModelAdmin)
>> admin.site.register(Friend, ReadOnlyModelAdmin)
>> admin.site.register(FriendshipRequest, ReadOnlyModelAdmin)
>>
>>
>> class Friend1(Friend):
>> def __str__(self):
>> return "User {} is friends with {}".format(self.to_user, 
>> self.from_user)
>>
>>
>> class FriendshipRequest1(FriendshipRequest):
>> def __str__(self):
>> return "Friendship request from user {} to 
>> {}".format(self.from_user, self.to_user)
>>
>>
>> Friend.__str__ = Friend1.__str__
>> FriendshipRequest.__str__ = FriendshipRequest1.__str__
>>
>> But, is it possible override __str__ in a cleaner way? It seems to me not
>> such a clean way to override a method (but it works). But I have to use the
>> model itself, because there is a lot of code in the package I'm using that
>> uses the model itself.
>>
>> (We are using our own Block model which I think we developed before they
>> developed a similar model. We are not using their Follow model too).
>>
>> אורי
>> u...@speedy.net
>>
> --
> 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/CABD5YeHNUEozN0vg_M5Hz9QrCTUAzH--u9SHtPVeDvJ4ZgWeOA%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/CAHn91odhu6Dtaxq%3DtVA5vmWSPmJUyRL42o--h--awBm3BHVjpw%40mail.gmail.com.


Re: Django keeps crashing

2019-07-26 Thread Jani Tiainen
Hi.

Unfortunately it is you. Withouth full source code it's hard to help.

Error indicates that you may have a typo in your settings.py.

If possible put up your project in github for example and join #django irc
channel on freenode. You get help in no time.

Also as you being beginner Django Girls do have very excellent tutorial to
get started.

pe 26. heinäk. 2019 klo 20.17 Kean Dumba  kirjoitti:

> Hi,
>
> New to Django, and python coding (4 days).
> Heard great things about Django, thought I'd try and use it to learn and
> develop.
> However, already frustrated. host8000 server crashes whenever i make any
> updates to files,
> even in the venv. It then won't run, it just gives an error report
> attached.
> I'm using python v3.7, pip3 and latest version of Django.
> I've just lost my 6th project as only fix is to delete files, reinstall
> and build everything again...
>
> not sure if its me or a bug, but would be most grateful for any guidance
> and support to understand and fix
>
> Best,
>
> Kean
>
>
> --
> 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/8112adc9-1cec-4550-8de8-5c567beb75dd%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/CAHn91ofqAX79t7mBXx_BbLsjRq2P6bOxN%2BBv3H0%3D3OXBmdeCYQ%40mail.gmail.com.


Re: SQLite 3.8.3 or later is required (found 3.7.17).

2019-07-19 Thread Jani Tiainen
Hi.

Error is simple. Python is using too old version of sqlite. There are few
options to fix that depending what os your system runs on.

Though sqlite is not very suitable for production so you may want to use
something better like Postgres.


pe 19. heinäk. 2019 klo 22.14 anchal agarwal 
kirjoitti:

> This is my whole Traceback
> Traceback (most recent call last):
>   File "manage.py", line 15, in 
> execute_from_command_line(sys.argv)
>   File
> "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 381, in execute_from_command_line
> utility.execute()
>   File
> "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py",
> line 357, in execute
> django.setup()
>   File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line
> 24, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py",
> line 114, in populate
> app_config.import_models()
>   File "/usr/local/lib/python3.7/site-packages/django/apps/config.py",
> line 211, in import_models
> self.models_module = import_module(models_module_name)
>   File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in
> import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 1006, in _gcd_import
>   File "", line 983, in _find_and_load
>   File "", line 967, in
> _find_and_load_unlocked
>   File "", line 677, in _load_unlocked
>   File "", line 728, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File "/home/ec2-user/wavybeatz/music/models.py", line 4, in 
> class Album(models.Model):
>   File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py",
> line 117, in __new__
> new_class.add_to_class('_meta', Options(meta, app_label))
>   File "/usr/local/lib/python3.7/site-packages/django/db/models/base.py",
> line 321, in add_to_class
> value.contribute_to_class(cls, name)
>   File
> "/usr/local/lib/python3.7/site-packages/django/db/models/options.py", line
> 204, in contribute_to_class
> self.db_table = truncate_name(self.db_table,
> connection.ops.max_name_length())
>   File "/usr/local/lib/python3.7/site-packages/django/db/__init__.py",
> line 28, in __getattr__
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>   File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line
> 201, in __getitem__
> backend = load_backend(db['ENGINE'])
>   File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line
> 110, in load_backend
> return import_module('%s.base' % backend_name)
>   File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in
> import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 1006, in _gcd_import
>   File "", line 983, in _find_and_load
>   File "", line 967, in
> _find_and_load_unlocked
>   File "", line 677, in _load_unlocked
>   File "", line 728, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File
> "/usr/local/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py",
> line 66, in 
> check_sqlite_version()
>   File
> "/usr/local/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py",
> line 63, in check_sqlite_version
> raise ImproperlyConfigured('SQLite 3.8.3 or later is required (found
> %s).' % Database.sqlite_version)
> django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is
> required (found 3.7.17).
>
> On Sat, Jul 20, 2019 at 12:29 AM anchal agarwal 
> wrote:
>
>> I used default sqlite as my Database
>> DATABASES = {
>> 'default': {
>> 'ENGINE': 'django.db.backends.sqlite3',
>> 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
>> }
>> }
>> My python version is python3 and Django version is 2.1.5
>>
>> On Fri, Jul 19, 2019 at 7:06 PM Desh Deepak 
>> wrote:
>>
>>> Hi, show me your database connection, also tell me python and Django
>>> version.
>>>
>>>
>>> On Fri, 19 Jul 2019, 18:06 anchal agarwal, 
>>> wrote:
>>>
 Hello Django users,
 i am trying to deploy my django on AWS
 I am following this
 https://medium.com/@charlesthk/deploy-nginx-django-uwsgi-on-aws-ec2-amazon-linux-517a683163c6
 Everything was going right but when i run python manage.py migrate ,
 it's giving me this error
 django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is
 required (found 3.7.17).
 how can i resolve this?
 Please help me

 --
 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 post to this group, send email to django-users@googlegroups.com.
 Visit this group at https://groups.google.com/group/django-users.
 To view this discussion on the web visit
 

Re: use of migrate command and how to see the tables

2019-07-19 Thread Jani Tiainen
Hi.

Migrate command applies migrations, changes to your models, into database.

For example if you add a new field in your model you need to create a
migration (piece of code that reflects your change) using makemigrations
command.

Once you have made migration(s) you need to apply them so database contains
a colum in a table that your model represents.


pe 19. heinäk. 2019 klo 11.23 yasar arafath Kajamydeen 
kirjoitti:

> Hi all,
>
> can some one tell me what is the use of migrate command ?
>
> when i enter the command i got the following error (No migration to apply)
> . I dont know what to do further and also i would like to create tables
> (sqlite) .
>
>
> [image: migrate.JPG]
>
>
> Note - I am a beginer to Django ..  Most welcome with your reply
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e715d8b3-9ed7-433d-9bf2-94899b196289%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ocrDXRqKVF7PhfOD764G91bCv45pqJUtTgyS3nF_v%2BihA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: sqlite update on CentOS 7 for latest django version

2019-07-18 Thread Jani Tiainen
Hi.

I think Python has built in version so you might need to build custom
version of python.

Pyenv is pretty neat tool to handle custom python builds.

ke 17. heinäk. 2019 klo 21.36 Tal  kirjoitti:

> Or is Python's sqlite built into Python, not depending on /usr/bin/sqlite3
> at all?
> Would I have to recompile Python for a newer version of sqlite that django
> can use?
>
> PS. I know I can downgrade django. I'm wondering how complex it is to
> compile a new version of sqlite for it to use.
>
> On Wednesday, July 17, 2019 at 12:14:54 PM UTC-6, Tal wrote:
>>
>> When using the latest django from PyPI in CentOS 7, running "./manage.py
>> runserver" gives an error about sqlite being too old.
>> Since there's no newer sqlite version in the CentOS repos, I tried
>> building sqlite from scratch:
>>
>> curl -L https://www.sqlite.org/2019/sqlite-amalgamation-329.tar.gz >
>> sqlite-amalgamation-329.tar.gz
>> tar -xvf sqlite-amalgamation-329.tar.gzcd sqlite-autoconf-329
>> ./configure
>> make
>> make install
>>
>>
>> This sets up the latest sqlite3 to /usr/local/bin/.
>> Since /usr/local/bin is ahead of /usr/bin in my PATH, just running
>> "sqlite3" in the terminal runs the latest sqlite.
>> It runs without issues, and shows that it's the latest version:
>>
>> my_hostname# sqlite3
>>
>> SQLite version 3.29.0 2019-07-10 17:32:03
>> Enter ".help" for usage hints.
>> Connected to a transient in-memory database.
>> Use ".open FILENAME" to reopen on a persistent database.
>> sqlite>
>>
>>
>> Running "./manage.py runserver" again, it still tries to use the old
>> version in /usr/bin, and fails.
>> My django is running in a pipenv virtual environment, where PATH still
>> has /usr/local/bin/ ahead of /usr/bin, and running "sqlite3" in terminal
>> still shows the latest version.
>>
>> I followed the traceback django gives me to the dbapi2.py module, where
>> to figure out the sqlite version it does this:
>>
>> import _sqlite3
>> _sqlite3.sqlite_version
>>
>>
>> If I run "python" in my virtualenv, and type those 2 lines, it shows the
>> old version of sqlite too.
>> _sqlite3 is not written in python - it's a compiled binary, so I can't
>> examine it to see where it looks.
>>
>> Am I missing something?
>> How can I tell _sqlite3 that there's a newer version of sqlite available
>> on the system?
>> Does _sqlite3 even care about /usr/local/bin/sqlite3? Or is there some
>> sqlite library it's looking for?
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3d011ce9-c849-48a7-82be-0ea08edb4566%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofxska88xCDjXjhksE1goYSXJsBnMcehfr2jum3HLLewA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Query questions. Please help me.

2019-07-17 Thread Jani Tiainen
Hi.

You can use dictionary unpacking to kwargs.

.filter(**{"name__contains": "foo", "somefield__gt": 123})



ke 17. heinäk. 2019 klo 23.04 나르엔  kirjoitti:

> Hello, I am studying django.
>
> When I use objects.filter, I want to search various columns.
>
> Columns to search for are unknown and have been receiving columns to
> search through checkbox in html.
>
> What should I do? Please teach me.
> It's blocked from below.
> selectoptions is name in checkbox.
>
>
> ---
> def get_queryset(self):
> context = super(SearchListView, self).get_queryset()
> query = self.request.GET.get('q')
> selectOptions = self.request.GET.getlist('selectoptions')
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/dbdb681d-e7ad-44db-a825-512cc9436575%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofMwQCD_B3UH7Knb6TgvDtwa2A2YnA5OO3jBa7Vsr%2BH7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: What's the best way to have app access permissions?

2019-07-16 Thread Jani Tiainen
We use django groups for that. So we give groupnames like ALLOW_SOMETHING
and then in code and templates we do check if user has that group or not.

ti 16. heinäk. 2019 klo 19.26 Tal  kirjoitti:

> I know you can have permissions on individual models that control which
> users have access to them, but I need something for my apps.
>
> Ex. If a user logs in, does he have access to the store_app? The
> forum_app? etc.
>
> I have a solution that looks something like this:
>
> models.py:
>
> class MyUser(AbstractUser):
> for app_short_name, app_long_name in settings.APP_CHOICES:
> add_field = "allow_{} = ".format(app_short_name)
> add_field += "models.BooleanField(verbose_name='Allow Access to
> {}', default=False, null=False)".format(app_long_name)
>
> exec(add_field)
>
>
> settings.py:
>
> APP_CHOICES = [
> ('store_app', 'Store App'),
> ('forum_app', 'Forum App'),
> ]
>
> It works, but I'm not sure if it's bad practice to have dynamically
> generated fields in models.py like this, or if there's a better/simpler way
> to do this.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e2672373-5cc1-495d-8d46-5e99bdf58fbe%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofQvtNg%2BB1Lsna8DbmjChF3H2ixP9Q5DntUEpa_vByVmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: E-Mail Client Django

2019-07-16 Thread Jani Tiainen
Hi.

Err... if you don't find one code a one?

ma 15. heinäk. 2019 klo 23.08 Sebastian Jung 
kirjoitti:

> Hello,
>
> i want a full complete E-Mail client like https://www.mailpile.is/ but in
> django. I need only from mailpile a view with template with email
> directories on left side and in rest with a list with date and subject.
> When user click on email then on bottom open detailview from email.
>
> And i want a template to send a new html e-mail with a html editor like ck
> editor. I need imap, pop3 and smtp with ssl/tls
>
> I don't find on google a simliar project.
>
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c15693e9-20c3-4b27-b2fb-de082bb9e581%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oc7Uwua6dmk%3D7EE83F7PvOYHgqk6DhES6srYkvJB%2BKRgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reach the server

2019-07-16 Thread Jani Tiainen
Hi.

Did you mapped 8000 port to outside of vagrant box? And did you told
runserver to listen all interfaces (0.0.0.0) since by default runserver
listens to localhost. In case of vagrant "localhost" interface is within
vagrant box itself.

ti 16. heinäk. 2019 klo 5.22 CHENXIN YANG 
kirjoitti:

> I created the new Django project on a vagrant virtual box, but I had
> trouble reaching the server at http://127.0.0.1:8000/ after running the
> server.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8a75bfed-68f1-45f5-a029-1367674fab2f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91odXjkr65U-GFyq%2B112goYsu%2BU6ORQww6Y87vxN9rs%2BSgA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: angular or vue js

2019-07-16 Thread Jani Tiainen
Any. Django really don't care about it. There exists also at least react
and svelte too...

ti 16. heinäk. 2019 klo 13.33 Pradeep Singh 
kirjoitti:

> which framework is good with django angular or vue js please suggest
> me best one
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANwgZcad1jLUj%3DpbQh2VHLGNSxgJDw9GHGP8cfd%3D1t%3D8NVK2%2BA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91of%3D%3DKR7aX5bUfdn9dUPYnRJG3%2B9Y2p%3DcLtTSt5THnLJuQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ModelForm "error_css_class" not getting applied to ValidationErrors raised in model.clean()

2019-07-16 Thread Jani Tiainen
Full_clean is Django internal method which you should't touch.

.clean() method validation errors go to special non-field errors and by
quick look it should get correct css class.

If you could provide minimal project with suspected faulty behavior (for
example in github) it would be easier to see if there is something wrong
there.

ti 16. heinäk. 2019 klo 15.32 Jacob Greene 
kirjoitti:

> Thank you for the reply! And good catch haha, I'm not actually. I editing
> these by hand so I wasn't posting some confusing telephony terminology. I'm
> displaying errors in my templates by marking them with that "form_error"
> css class. They are just red and bold, most errors are shown with the
> correct CSS class like my UniqueConstraints or any exceptions I throw in
> the modelForm clean() method, but any exceptions I throw in the
> Model.clean() or Model.full_clean() do not get the correct css class.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/82018028-f0d8-46f7-a542-1bd7b072b8e8%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oc4Z9BONy7gP0B6wZrG2NG-OTogXkCTeORm0d274sxL7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ModelForm "error_css_class" not getting applied to ValidationErrors raised in model.clean()

2019-07-16 Thread Jani Tiainen
At least you should't call super.clean_fields() in clean() method...

Also how are you outputting errors in your template?


ti 16. heinäk. 2019 klo 5.22 Jacob Greene 
kirjoitti:

> Hello! Has anyone dealt with this before? It seems that my forms don't add
> the CSS class to errors raised in model.clean() or model.clean_fields()
> methods.
>
> I have a form that looks something like this:
>
> class HttpsFaxBoxForm(forms.ModelForm):
> error_css_class = 'form_error'
>
>
> class Meta:
> model = FaxBox
> fields = ('outbound_cid_profile', 'id')
>
>
>
> And I run validation in my models(keep the admin page consistent) like
> this:
>
> class FaxBox(models.Model):
>
> something = fields.CharField(max_length=100)
>
>
> def clean(self):
> if self.something == "shouldn't be here":
>
> raise ValidationError('This should not be here! Please fix!')
> super().clean_fields(exclude=None)
>
>
> But when this exception gets raised, the CSS class isn't applied to it in
> the template. Anyone know of a way to work around this? Thanks for reading!
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8cfa5a86-ccaf-47f7-8b10-93fbaaaf4386%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oc%3DSMymVzxKzv%2BjeZJKobc5PUrfwYMfAccVdqk-9GnQ5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Create a multitab home page of a blog

2019-07-16 Thread Jani Tiainen
Hi.

Well most of the things you describe are not spesific to django but just
how you do layout your data with HTML.

And yes all can be done with django.

Being sensible? That is really subjective matter.

ti 16. heinäk. 2019 klo 5.22 Nicolas Huergo  kirjoitti:

> Hey!
>
> I'm pretty much new to Django, so I cannot figure this out:
>
> I have the home page and the way to post updates in my blog, but I want to
> sort the posts into categories. Like sports, fitness, politics. But I want
> to do it into two lists of multiple tabs, one horizontal and one vertical.
> And I'd like to make the horizontal and vertical tabs combine, so that when
> I click on horizontal tab01 and vertical tab01, e.g., it renders a certain
> view (or category of posts). Does this make any sense? Is it possible with
> Django? If so, how?
>
> Help is much appreciated.
>
> Cheers.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2d0684a9-c581-4b31-8009-2b043ed25ba5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ocQNs7PxO%3DL%3D0eDUkrkcCjNDPJEgrqWCPVBwG%3DEqZoUwg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Form validations

2019-07-11 Thread Jani Tiainen
Hi.

Usually you validate user input and by using Forms or ModelForms.


to 11. heinäk. 2019 klo 12.50 Irfan Khan  kirjoitti:

> Dear members,
> I wanted to validate the form which contains the name, phone number,
> address,email, etc..,
> I have developed and tested it if we give any character it’s saving to
> database table.so I wanted to validate the every field for example
> In name field it should take only alphabets,
> And in phone number field it should take only numbers like
> Can any one please guide me which is best practice to perform
> Thanks in advance
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALKGViqQgLhqAzPgG5S-sz4ZdwA2z_q6KeTUQoxtNrzrrA21sQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oephj3rT2JoJZaGk5MtSfdJV0Bcb1j9jngE99YW5VyFng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ValueError

2019-07-10 Thread Jani Tiainen
Hi.

Because indentation is broken it's hard to say exact problem location but
in your view some code path doesn't return anything and thus you see error
about returning None.

ke 10. heinäk. 2019 klo 21.05 Desh Deepak 
kirjoitti:

> Hi, I want to insert some data in MysqlDatabase from the template (HTML
> file).
> but, it shows error like this...
>
> The view Naturalgreen.views.index didn't return an HttpResponse object. It 
> returned None instead.
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/
> Django Version: 2.0
> Exception Type: ValueError
> Exception Value:
>
>
> Python Version: 3.7.3
> Django Version: 2.0
>
>
> (views.py)
> from django.shortcuts import render
> from django.http import HttpResponse
> from Naturalgreen.models import signin
>
>
> # Create your views here.
>
> def index(request):
> if request.method == 'POST':
> if request.POST.get('username') and request.POST.get('password'):
> POST = naturalgreen_signin()
> POST.username = request.POST.get('username')
> POST.password = request.POST.get('password')
> post.save()
> return HttpResponseRedirect(request, "index.html")
> else:
> return HttpResponse(request, 'home.html')
>
>
> (models.py)
>
> from django.db import models
>
> # Create your models here.
> class signin(models.Model):
> username = models.CharField(max_length=200, blank=False)
> password = models.CharField(max_length=150, blank=False)
>
>
> class Meta:
> db_table ="naturalgree_signin"
>
>
> (index.html)
> {% load static %}
> 
> 
> 
> 
> Natural Green
>
> 
>
> 
> 
> Please Enter your Login Details !
> 
> {% csrf_token %}
> Username: 
> Password: 
> Login
> 
> 
>
> 
>
> 
>
>
>
> thanks:
> Desh Deepak
> +917011101001
> deshdeepak...@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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJ0m4xjVuP91YmjZ423UZfgiRoPtg3GvgsRgZR_KMc2vOgFXBQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91odRt0T0Vc_izSbRHV3J%2BshVquKb4-__6bfvjaMSeUuyHg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can I override __new__ in Django ModelForm?

2019-07-10 Thread Jani Tiainen
Hi.

You can add fields dynamically on model __init__ method and AFAIK that's
best and recommended way to do it.

I'm not sure is that even in Django docs.


ke 10. heinäk. 2019 klo 17.44 אורי  kirjoitti:

> Hi,
>
> I have a ModelForm with Django 1.11, and I'm moving a few fields to
> another model. Calling make_migrations causes an error because these fields
> don't exist in the current model. I added some of the fields to the form,
> but one of the fields is a TranslatedField and therefore there are
> currently 2 fields, and in the future there might be more, depending on the
> number of languages. The name of the field is city, and currently I get an
> error message "Unknown field(s) (city_en, city_he) specified for
> SiteProfile" (because I'm using 2 languages - "en" and "he") - but I want
> to create all the fields dynamically with a for loop over the languages we
> use in the project. Can I override (and is it a good programming method)
> the __new__ method or is there another way? I prefer not to hard-code the
> specific field names (city_en and city_he) because they may change in the
> future, depending on how many languages we use.
>
> You can see my current commit (not working) on GitHub:
>
> https://github.com/speedy-net/speedy-net/commit/f2c9b306c1a5f7a41b19d605f7871c07a67af93f
>
>
> And the current code of this branch:
>
> https://github.com/speedy-net/speedy-net/blob/uri_move_fields_to_speedy_net_2019-07-10_b/speedy/match/accounts/forms.py
>
>
> I would like to know what is the best programming method to define a
> dynamic list of fields (which are all identical, and only one of them will
> be used, the other are removed in the __init__ method) in a ModelForm where
> the fields are saved in another model (there are 2 models but only one
> form).
>
> I still didn't commit the migrations because of this error when running
> make_migrations.
>
> (I defined a command make_migrations which only does makemigrations)
>
> Thanks!
> אורי
> u...@speedy.net
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABD5YeFv7HFCmFqvQeg5HdQLBs%3DYbxbRO4oukpdFX175exNSHA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91odauAH%2B2Jnjdb7Yx61juKqmo3h2M05B3uNc1NDig7D9UA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Login Secret key

2019-07-10 Thread Jani Tiainen
Oh you want to have false security.

First this has nothing to do with Django and it's secret key. You can use
any secret key in your case it would be user input. Also you can use any
cryptography algorithm to secure your data in the database.

And here is the problem - to make user experience pleasant you have to
store this secret key somewhere unless you want to have user input secret
key every time you read and write to database. Not just in login.

Because you store the key it does exist somewhere. And if attacker already
got to your settings.py it pretty much means that attacker sees your code
and can read the key. And you lost the game.

ke 10. heinäk. 2019 klo 9.54 Sebastian Jung 
kirjoitti:

> I encrypt several fields in Database. Now it's possible that a Hacker get
> Database and settings.py. i want Maximum Security and i think when User at
> Login Page Input Secret Key that ist optimal. Also i want AS SaaS No Access
> to Data in database because Data ist high Security.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2e15e2f0-0400-4158-a4ec-69e06e65bbc2%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91odgLvs8u%3DK%2BaFXhWNgc4OYTLyNjst0YcGXWETV%3DjRgjCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Login Secret key

2019-07-10 Thread Jani Tiainen
Hi.

What are you trying to do?

In other words why do you need to replace secret key by user input at login?


ke 10. heinäk. 2019 klo 8.54 Sebastian Jung 
kirjoitti:

> Hello,
>
> I want in my Login Page a further field Secret Key. This Input ist
> replacement dir Secret Key in settings.py. Ist this possible? Can someone
> explain me how?
>
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d8ec843c-0de4-4e20-b264-7fd45d455777%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oew_0H-5hMO0hM2EdvXN1rx6i4kwC55W9cQwWKsu5TZbg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: E-mail sending... but.. not sending?

2019-07-09 Thread Jani Tiainen
Hi.

Looks like your backend isn't right if you see message in the console.

Also if using gmail you have allowed insecure apps?

ti 9. heinäk. 2019 klo 17.47 grwhumphries 
kirjoitti:

> I've got a bit of a mystery.  I've got a Django Wagtail project with
> Spirit as an added app.   I'm trying to get the e-mail system working...
>
> I've included the following in settings/base.py
> EMAIL_NAME = 'myem...@gmail.com'
>
> EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
> EMAIL_USE_TLS = True
> EMAIL_HOST = 'smtp.gmail.com'
> EMAIL_HOST_USER = EMAIL_NAME
> EMAIL_HOST_PASSWORD = PASSWORD
> EMAIL_PORT = 587
> DEFAULT_FROM_EMAIL = EMAIL_NAME
>
> ADMINS = (
> ('You', EMAIL_NAME),
> )
>
> MANAGERS = ADMINS
>
>
> I then ran the following test
>
> *from django.conf import settings*
> *from django.core.mail import send_mail*
>
> *send_mail('test','test message', 'myem...@gmail.com
> ',['otherem...@gmail.com '])*
>
>
> The output from this in the console suggests the e-mail sent...
>
> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: test
> From: myem...@gmail.com
> To: otherem...@gmail.com
> Date: Tue, 09 Jul 2019 14:14:42 -
> Message-ID: 
>
> test message
>
> ---
>
>
> However... nothing arrives at the e-mail address.   All email addresses
> and passwords are correct and have been double and triple checked.
>
> Any thoughts on to what I might be missing?
>
> Cheers all.
>
>
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/22baf6e8-f873-4a56-b497-7c90621d90c0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oc_ajFHnC9Oy77ACQ0Zn-uKnNB09dyYoHwyWSD%3DfNtELQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: cicking to menu in navebar leads another subpage /subpage

2019-07-09 Thread Jani Tiainen
It is explained at least in official tutorial part 3 in very detail.

https://docs.djangoproject.com/en/2.2/intro/tutorial03/


ti 9. heinäk. 2019 klo 16.34 Surya Adhikari 
kirjoitti:

>  Home 
>
> like this also it is not working can you please exaplin me where and how 
> should i use {% url %}
>
>
> On Monday, 8 July 2019 22:26:07 UTC+5:45, Jani Tiainen wrote:
>>
>> Hi.
>>
>> There are two things wrong.
>>
>> First and most important is that you should always use {%url %} template
>> tag to form urls to other django urls and preferably by using named url
>> patterns.
>>
>> Secondly your hardcoded urls are relative. So each time you click link it
>> is appended to current url. If you would have been using url-tag you even
>> wouldn't have this problem.
>>
>> ma 8. heinäk. 2019 klo 18.51 Surya Adhikari 
>> kirjoitti:
>>
>>> i have a menu bar as, HOME   GALLERY
>>> When i click Home its the index page which is being display after when i
>>> click Gallary dropdown menu as  house it redirects to  search.html . BUT
>>> when i  again click hotel it redirects to  127.0.0.1/search/ search1
>>> insted of 127.0.0.1/search1.
>>>
>>>
>>>
>>> i have 3 web pages as:  search.html, search1.html, search2.html. i am
>>> inheriting search.html to all of those HTML file.
>>>
>>> My code:
>>>
>>>
>>>
>>> 
>>>
>>>   Home
>>>
>>>   
>>> Gallary
>>>   
>>> 
>>> 
>>>house
>>>   hotel
>>>   hospital
>>>
>>> 
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/b9c81c3c-30e0-4b3c-84cc-5316ac408089%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/b9c81c3c-30e0-4b3c-84cc-5316ac408089%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f1687106-1103-4de8-9e0f-8721054bedd6%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f1687106-1103-4de8-9e0f-8721054bedd6%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oeOQqw7EHFPhWYF2_OKFGEX-3ghAP-OoCFT0MSREvgJ4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trademark search

2019-07-09 Thread Jani Tiainen
Well...

Short answer is yes, no and maybe.

Longer anwer is that you can do that with plain Django. Idea itself is so
simple that it byself doesn't require any magic.

Most if the required building blocks for such an web app has been dealt
with default Django tutorial. If you did that you're already capable of
building similar trademark search site.


ti 9. heinäk. 2019 klo 15.47 Django Dojo  kirjoitti:

> Are there any Django packages or api being used?
>
> On Tuesday, July 9, 2019, Jani Tiainen  wrote:
>
>> Hi.
>>
>> Web page, database and most propably some programming to make search
>> magic happen.
>>
>> ti 9. heinäk. 2019 klo 13.44 Django Dojo 
>> kirjoitti:
>>
>>> Hello,
>>> I’m trying to build a trademark search like:
>>> https://www.trademarkengine.com/free-trademark-search/trademark-search.
>>>
>>> Can someone recommend to me how it’s done
>>>
>>> Thank you
>>>
>>> --
>>> 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 post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/818598b9-54f1-42d6-bb27-98204e68a81a%40googlegroups.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAHn91odgw1718Sn55-nndb-thXxGcDCkQEZX1o2O4x_64VeG1g%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAHn91odgw1718Sn55-nndb-thXxGcDCkQEZX1o2O4x_64VeG1g%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CANO9Ro_m_znGmbvu7pTkvWbG2Urv7scsj7JwEuS6oBJGtYHVgQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANO9Ro_m_znGmbvu7pTkvWbG2Urv7scsj7JwEuS6oBJGtYHVgQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofhbjDgCvynT1JerdHy2OLTN2k4bD1n8sB1h0vBDrwCqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: CockroachDB & Django

2019-07-09 Thread Jani Tiainen
Hi.

You should setup test environment that runs Django database tests against
your backend. Preferably somewhere visible to public.

That way it would be easier to start figuring out areas of improvement.

ti 9. heinäk. 2019 klo 2.29 'Andy Woods' via Django users <
django-users@googlegroups.com> kirjoitti:

> Hello All!
>
> I'm a product manager at Cockroach Labs
>  working on our SQL product
> area. CockroachDB leverages the Postgres wire protocol to provide
> distributed SQL to our customers. Because we support the same protocol as
> Postgres, we can often take advantage of the drivers, ORMs, and tools
> already created for Postgres with CockroachDB.
>
> Over the years we've seen community interest
>  in making a
> CockroachDB specific implementation of Django. In fact, one of our
> engineers even went so far as to build a working prototype
>  that passes the
> initial Django tutorial.
>
> We are now seeking help from experts in the Django community in advancing
> our prototype to the next level. We would happily welcome contributors to
> our open-source Django prototype.
>
> We'd also love any beta testers who would be willing to give our prototype
> a try and provide feedback to us.
>
> If this is something you might be interested in, please let me know.
>
> Thank you!
>
> Andy
>
> a...@cockroachlabs.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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/816723fc-bae9-46a3-adce-31cd0f5b40e2%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oco5VCraBwrQB6gMoA%2BhLDXELcgaUdZ-YTcBS8rREiKHg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trademark search

2019-07-09 Thread Jani Tiainen
Hi.

Web page, database and most propably some programming to make search magic
happen.

ti 9. heinäk. 2019 klo 13.44 Django Dojo  kirjoitti:

> Hello,
> I’m trying to build a trademark search like:
> https://www.trademarkengine.com/free-trademark-search/trademark-search.
>
> Can someone recommend to me how it’s done
>
> Thank you
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/818598b9-54f1-42d6-bb27-98204e68a81a%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91odgw1718Sn55-nndb-thXxGcDCkQEZX1o2O4x_64VeG1g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NEWBIE

2019-07-09 Thread Jani Tiainen
And to give some perspective I have been working with Django @work last 10
years and I'm still far from mastering it. I'm pretty good with Django
though.

In other words it really takes a lot. Interns at work do get hang of basics
in about two months but really them to get up to speed takes somewhere
around half a year. And this is for people who do work about 8 hrs day, 5
days a week.

ti 9. heinäk. 2019 klo 14.00 Afotro Ben  kirjoitti:

> Hello,i am new to programming and want to take learn and master web
> development with Gjango.Can anyone here tell me what it takes to doing it
> in 2 months?
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/db91f5d5-c494-4d34-8188-3e9b4279cf3d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ochAgLN%3DfoO4DzQCk23wO1rMjVyA6jBK47ywiJeiLww5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: reg: Object of type 'ListSerializer' is not JSON serializable

2019-07-08 Thread Jani Tiainen
Hi.

In your view instead of using Response(serializer) you need to use
Response(serializer.data)

HTH.


ma 8. heinäk. 2019 klo 19.48 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> kirjoitti:

> hello Members,
>
> I am working on some POC for django rest framework. Its very simple setup,
> nothing complicated. While I was doing my testing I am facing below error:
>
> ===
> TypeError at /api/status/
>
> Object of type 'ListSerializer' is not JSON serializable
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/api/status/
> Django Version: 1.11.8
> Exception Type: TypeError
> Exception Value:
>
> Object of type 'ListSerializer' is not JSON serializable
>
> Exception Location: /usr/lib/python3.6/json/encoder.py in default, line
> 180
> Python Executable: /root/PycharmProjects/vrest/bin/python
> Python Version: 3.6.5
> Python Path:
>
> ['/root/PycharmProjects/src',
>  '/usr/local/buildtools/current/sitecustomize',
>  '/usr/lib/python36.zip',
>  '/usr/lib/python3.6',
>  '/usr/lib/python3.6/lib-dynload',
>  '/root/PycharmProjects/vrest/lib/python3.6/site-packages']
>
> Server time: Mon, 8 Jul 2019 16:03:26 +
> ===
> Below are the details :
> -
> serializers.py
>
> from rest_framework import serializers
> from STATUS.models import Status
>
>
> class StatusSerializer(serializers.ModelSerializer):
> class Meta:
> model = Status
> fields = [
> 'user',
> 'content',
> 'image'
> ]
>
> def validate_content(self, value):
> if len(value) > 500:
> raise serializers.ValidationError("way too long string")
>
> def validate(self, data):
> content = data.get('content', None)
> if content =='':
> content = None
> image = data.get('image', None)
> if content is None and image is None:
> raise serializers.ValidationError('Required fields')
> return data
>
>
> models.py
> -
>
> from django.db import models
> from django.conf import settings
>
>
> def upload_status_image(instance, filename):
> return "updates/{user}/{filename}" .format(user=instance.user, 
> filename=filename)
>
>
> class StatusQuerySet(models.QuerySet):
> pass
>
>
> class StatusManager(models.Manager):
> def get_queryset(self):
> return StatusQuerySet(self.model, using=self._db)
>
>
> class Status(models.Model):
> user = models.ForeignKey(settings.AUTH_USER_MODEL)
> content = models.TextField(null=True, blank=True)
> image = models.ImageField(upload_to=upload_status_image)
> updated = models.DateTimeField
> timestamp = models.DateTimeField(auto_now_add=True)
>
> objects = StatusManager()
>
> def __str__(self):
> return str(self.content)[:50]
>
> class Meta:
> verbose_name = 'status post'
> verbose_name_plural = 'status posts'
>
> views.py
>
> from django.views.generic import View
> from rest_framework.views import APIView
> from rest_framework.response import Response
> from .serializers import StatusSerializer
> from STATUS.models import Status
>
>
> class StatusListSearchAPIView(APIView):
> permission_classes = []
> authentication_classes = []
>
> def get(self, request, format=None):
> qs = Status.objects.all()
> serializer = StatusSerializer(qs, many=True)
> return Response(serializer)
>
> forms.py
>
> from django import forms
> from .models import Status
>
> class StatusForm(forms.ModelForm):
> class Meta:
> model = Status
> fields = [
> 'user',
> 'content',
> 'image'
> ]
>
> def clean_content(self, *args, **kwargs):
> content = self.cleaned_data.get('content')
> if len(content) > 240:
> raise forms.ValidationError('Content is too long')
> return content
>
> def clean(self, *args, **kwargs):
> data = self.cleaned_data
> content = data.get('content', None)
> if content == '':
> content = None
>
> image = data.get('image', None)
> if content is None and image is None:
> raise forms.ValidationError('Content or image is required..')
> return super().clean(*args, **kwargs)
>
> app.urls.py
>
> from django.conf.urls import url, include
> from django.contrib import admin
> from .views import StatusListSearchAPIView
>
> urlpatterns = [
> url(r'^$', StatusListSearchAPIView.as_view()),
> #url(r'^create/$', StatusCreateAPIView.as_view()),
> #url(r'^(?P.*)/$', StatusDetailAPIiew.as_view()),
> #url(r'^(?P.*)/update/$', StatusUpdateAPIView.as_view()),
> #url(r'^(?P.*)/update/$', StatusDeleteAPIView.as_view()),
>
> ]
>
> project.urls.py
>
> from django.conf.urls import url, include
> from django.contrib import admin
>
> urlpatterns = [
> 

Re: cicking to menu in navebar leads another subpage /subpage

2019-07-08 Thread Jani Tiainen
Hi.

There are two things wrong.

First and most important is that you should always use {%url %} template
tag to form urls to other django urls and preferably by using named url
patterns.

Secondly your hardcoded urls are relative. So each time you click link it
is appended to current url. If you would have been using url-tag you even
wouldn't have this problem.

ma 8. heinäk. 2019 klo 18.51 Surya Adhikari 
kirjoitti:

> i have a menu bar as, HOME   GALLERY
> When i click Home its the index page which is being display after when i
> click Gallary dropdown menu as  house it redirects to  search.html . BUT
> when i  again click hotel it redirects to  127.0.0.1/search/ search1
> insted of 127.0.0.1/search1.
>
>
>
> i have 3 web pages as:  search.html, search1.html, search2.html. i am
> inheriting search.html to all of those HTML file.
>
> My code:
>
>
>
> 
>
>   Home
>
>   
> Gallary
>   
> 
> 
>house
>   hotel
>   hospital
>
> 
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b9c81c3c-30e0-4b3c-84cc-5316ac408089%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ocs4%2BSPnYpAA0w29d8rXv8-OVuw%3DLxAs-D_o-ErP%3DxAFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: saving inherited model overwrites base model

2019-07-05 Thread Jani Tiainen
Hi.

I think you have a bit confused terms model inheritance and abstract models.

Normal model inheritance in Django means that there will be implicit one to
one relation to base model. Inherited model still receives all fields from
parent model. On save data is just saved to correct models. To both parent
and child. And both models do have separate tables.

If inherited model is abstract all fields are copied to inherited model and
django treats model as one. There is no parent table created but columns
are added to inheriting model table.

pe 5. heinäk. 2019 klo 20.42 Kalev Takkis 
kirjoitti:

> Hi all,
>
> tl;dr: saving inherited model overwrites fields in parent models with
> empty strings
>
> I have the following models:
>
> class Contact(models.Model):
> comment = models.CharField(max_length=255, blank=True)
> emails = models.ManyToManyField(
> Email,
> blank=True,
> through='ContactEmail',
> through_fields=('contact', 'email'),
> )
>
> # couple of more manytomanys, to addresses, phones, etc
>
>
> class ContactEmail(BaseContactJunctionModel):
> email = models.ForeignKey(Email, null=True, on_delete=models.SET_NULL)
> contact = models.ForeignKey(Contact, on_delete=models.CASCADE)
> event = models.ForeignKey(ContactEvent, on_delete=models.PROTECT)
> event_date = models.DateTimeField(default=timezone.now)
>
>
> # other similar through tables for the rest of the manytomanys and their
> target models
>
>
> class Organisation(Contact):
>
> name = models.CharField(max_length=255, blank=True)
> hierarchy = models.ManyToManyField(
> 'self',
> blank=True,
> symmetrical=False,
> through='OrganisationHierarchy',
> through_fields=('sender', 'target'),
> )
>
> # again, more manytomanys, not to self though
>
> # not sure this is relevant but as it's to self, then just in case
> class OrganisationHierarchy(BaseContactJunctionModel):
> # this, instance that specifies relationship
> sender = models.ForeignKey(
> Organisation,
> null=True,
> related_name='senders',
> on_delete=models.SET_NULL,
> )
>
> # instance that 'this' or 'sender' is related to
> target = models.ForeignKey(
> Organisation,
> null=True,
> related_name='targets',
> on_delete=models.SET_NULL,
> )
>
> connection_type = models.ForeignKey(
> ConnectionType,
> null=True,
> on_delete=models.PROTECT,
> )
>
> I have a view based on CreateView and a template to capture user
> input. The post request coming from browser is a-ok, saving
> emails, contact, contactemails and other manytomany targets and
> junction tables works without a problem but when getting to
> saving Organisation, this happens (pseudocode):
>
> save() is called from django/db/models/base.py
> save_base() is called with self=Organisation
> save_base calls _save_parents(self=Organisation, cls=Organisation)
> save_parents loops through cls._meta.parents and comes across
> relation
> parent=Contact, field=Organisation.contact_ptr
> calls _save_table with self=Organisation and cls=Contact
> _save_table finds from cls._meta that it has
> local concrete field "comment" and stores it in list
> non_pks
> it then finds the values for those fields like
> this:
> f.pre_save(self, false) for f in non_pks
>
> I then see a call to _update in queries.py and Contact instance
> is updated with new values.
>
> I don't really understand what's happening here, the code finds
> local concrete fields from "cls" which at this point is Contact
> and comes up, correctly, with "comment" but then it tries to
> query the field value form "self" which at this point is
> Organisation object. I'm not sure why Organisation has "comment"
> attribute at all, because the way I read the docs it should only
> happen when the base model is abstract or when the inherited
> model is proxy model, neither of which is the case. Anyway, the
> value returned by save_base for the "comment" from "self" is not
> the value I inserted into the form field (and what has previously
> been saved to Contact object) but is instead an empty string.
>
> The end result is, after Contact object is correctly saved it is,
> moments later, overwritten by an empty string. Does anybody have
> a clue as to what is happening and most importantly, how can I
> avoid it?
>
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web 

Re: Django 2.2 Media files

2019-07-05 Thread Jani Tiainen
Hi.

What you did is correct and expected.

Upload_to is relative path to MEDIA_ROOT in case of normal file upload
backend. There are many others like S3.

Now MEDIA_URL is absolute path of web server which points to MEDIA_ROOT. In
development you can use static file serving trick like you did.

Now when getting url in template you should use something like {{ image.url
}} which should render correct absolute url to your  uploaded file.

HTH.

pe 5. heinäk. 2019 klo 15.55 Michał Ratajczak 
kirjoitti:

> Hi, i'm new in Django, I'm trying to configure media files correctly.
>
> That's in my model.py:
>
> class Question(models.Model):
> description = models.CharField(max_length=200)
> image = models.ImageField(upload_to='media/', null=True, blank=True)
>
>
> in settings.py:
>
> STATIC_URL = '/static/'
> MEDIA_URL = '/media/'
>
> ENV_PATH = os.path.abspath(os.path.dirname(__file__))
> STATIC_ROOT = os.path.join(ENV_PATH, '../public/static/')
> MEDIA_ROOT = os.path.join(ENV_PATH, '../public/media/')
>
> in urls.py:
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('', include('barber.urls'))
> ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
>
> in view.py:
> def index(request):
> images = Question.objects.values('image')
> template = loader.get_template('barber/index.html')
> context = {
> 'images': images
> }
> return HttpResponse(template.render(context, request))
>
> I'am adding an image via admin site and next i render in template. Url for
> image is "media/image.png" bit file is in .../media/media/image.png, so i
> can't understand it. Can anyone help me ?
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5613b376-575f-4ab0-bdff-368f0fe8f1cf%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91odFeKH_FkZAuJ73w4scBbicSYsV%2BSpCD74P07Y%2B-%3DjC6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: help

2019-07-05 Thread Jani Tiainen
Hi.

Please don't hijack other people threads but start a new one.


pe 5. heinäk. 2019 klo 15.55 Manjunatha Sai Uppu 
kirjoitti:

> I am new to web development  in django , i have some questions that
> 1. Is it necessary to  learn html,css?
>

No. Absolutely no. You can write plain backend code for example by using
JSON respondses.

Though if you want to write full web sites HTML and CSS greatly helps.

2. what are the advantages and disadvantages of django?
>

A good friendly community. And it's written in Python. Best programming
language ever.

3. how it is useful?
>

In my opionion it's very fast tool to make ideas to real dynamic web apps.

Also there are tons of Python libraries that you can leverage plus huge
amount apps (kind of plugins) you can use in you Django projects to help
making things even faster.

4. any best resources that u can provide for me?
>

Do tutorials. Django Girls do provide excellent tutorial to get started.

 thanks in advance...!
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/af9761b8-a365-4b0f-8450-46450ffd70bf%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91of%2BdGkXmq-ut7kxwJyRCL_4m0p_HPVEwEDcf-8XYnb8-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Doubt about Custom User Model

2019-07-04 Thread Jani Tiainen
Hi

Models always do belong to app. All apps do have AppConfig (one or more)

So when adding app (and thus models) to INSTALLED_APPS you need to point to
which AppConfig you use (defined in apps.py)


to 4. heinäk. 2019 klo 11.58 pastrufazio  kirjoitti:

> Hi!
>
> I've read some examples about custom User Model. In all of them, it's
> suggested implement the class AbtractUser (in this case the app is called
> *users*)
>
> For instance, in this example
> https://wsvincent.com/django-custom-user-model-tutorial/ they do
>
>
>  users/models.pyfrom django.contrib.auth.models import AbstractUserfrom 
> django.db import models
> class CustomUser(AbstractUser):
>
>
>
> but then they say to include *users.apps.UserConfig*. Why? Where does it
> come from? Why not  the class *users.apps.CustomUser* ?
>
>
>
> # djauth/settings.pyINSTALLED_APPS = [
>
> ...
>
> 'users.apps.UsersConfig', ]
>
>
>
> Thank you very much
>
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5bcb0c0a-c83f-4a67-97a7-325ef6ecc87b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oem_UNNqrvPFiYOS6zn1tJjU9wVmCk5T%2B0wdnHaEFVCGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: order of loading css-files

2019-07-02 Thread Jani Tiainen
Hi.

It's your browser not Django. Django just emits HTML that is parsed by your
browser.


ti 2. heinäk. 2019 klo 15.14 Kai Kobschätzki 
kirjoitti:

> Hi:
>
> I tried to load bootstrap and an own css-file. But in which order does
> django load it?
>
> I have tried in my base.html:
>
> 
> {% load static %}
>
>
> 
> 
>
> {% block title %}gyousei{% endblock title %}
>
> 
> ...
>
> and the log is writing:
>
> [02/Jul/2019 11:54:38] "GET / HTTP/1.1" 200 6259
> [02/Jul/2019 11:54:38] "GET /static/css/base.css HTTP/1.1" 304 0
> [02/Jul/2019 11:54:38] "GET /static/bootstrap/css/site.css HTTP/1.1" 404 1690
> [02/Jul/2019 11:54:38] "GET /static/bootstrap/js/jquery.min.js HTTP/1.1" 404 
> 1702
> [02/Jul/2019 11:54:38] "GET /static/bootstrap/js/popper.js HTTP/1.1" 404 1690
> [02/Jul/2019 11:54:38] "GET /static/bootstrap/js/popper.js HTTP/1.1" 404 1690
>
> and if I write
>
> 
> {% load static %}
> 
>
> 
> 
>
>
> {% block title %}gyousei{% endblock title %}
>
> 
> ...
> the log writes
>
> [02/Jul/2019 11:54:11] "GET /static/css/base.css HTTP/1.1" 304 0
> [02/Jul/2019 11:54:11] "GET /static/bootstrap/js/jquery.min.js HTTP/1.1" 404 
> 1702
> [02/Jul/2019 11:54:11] "GET /static/bootstrap/js/popper.js HTTP/1.1" 404 1690
> [02/Jul/2019 11:54:11] "GET /static/bootstrap/css/site.css HTTP/1.1" 404 1690
>
> If I understand it correct in both cases django loads my base.css first so 
> bootstrap overwrites it.
> How can I change this?
>
> Thanks for your response,
>
> bengoshi
>
> -- herz-jesu-jugend.de
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d6be7f83-ca64-cd9d-b72e-2b9a4aa093cb%40herz-jesu-jugend.de
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ocYA%3Da%2BeZgEis76XXvcs0XqT69U5mXXPAV2W4aJ2mNLew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: OTP Verification

2019-07-02 Thread Jani Tiainen
Hi.

I wrote short blog post how to do simple OTP.

http://blog.jani.tiainen.cc/django/2019/02/19/django-otp-simple-way.html

HTH.

ti 2. heinäk. 2019 klo 4.33 ravikumar dingari 
kirjoitti:

> Actually generated OTP but , Don't know how to verify, can any one help
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2BvYKMTHoaHP3WL7V%2B_iT%2B6ssVPfm3jq7z5o-5nnwXZZWYMYyg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofcP865cwPNQnL10zUa-XN2%3D-_n9-YdkGpxMstr_%2BHP2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating pdf in python

2019-06-27 Thread Jani Tiainen
I've been also very succesful with wkhtmltopdf.

to 27. kesäk. 2019 klo 18.44 Larry Martell 
kirjoitti:

> On Thu, Jun 27, 2019 at 10:45 AM Django Dojo 
> wrote:
> >
> > Hello everyone,
> >
> > I have a pdf template and I need different Individuals(s) to fill out
> different sections of the document on the web using online form(s). Is
> there an Django package that will allow me to do this?
> >
> > Ex: end user will go to a web form and fill out information which will
> be imported into the pdf document.
>
> I have used this: https://wkhtmltopdf.org/
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACwCsY5%3DXjs5xQoXz1K4uUcz1jy_obD%3DswpXuD98nxYaMNF4VQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ocaMkzS9aP_cj268FeAdzwENwkHjt0bh0vZacK440iihA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating a log for any changes in any model data i.e creation, updation and deletion??

2019-06-24 Thread Jani Tiainen
Hi.

Note that there are still ways to modify data withouth signals getting
fired. Nor save or delete is called.


ma 24. kesäk. 2019 klo 18.54 Abhishek Tiwari  kirjoitti:

> That is the approach i have in mind.. Thank you..
>
> On Monday, 24 June 2019 20:08:06 UTC+5:30, Brandon Rosenbloom wrote:
>>
>> Try using Django signals
>> https://docs.djangoproject.com/en/2.2/topics/signals/
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e286a8ea-b2d6-45ed-a7fa-f4a0f5478274%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oef-PW0LiEbFYvy5yapCyp6HHQqW1ViWaV1HUTJ-Ad1Nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django background scheduled app

2019-05-20 Thread Jani Tiainen
Hi,

There are also other alternatives for background processing than celery.

Like django-rq or django-background-tasks.


ma 20. toukok. 2019 klo 16.14 Chetan Ganji 
kirjoitti:

> celery is what you need for this. It is very simple. Just stick to it,
> find some examples on youtube for celery, and you should get it.
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Mon, May 20, 2019 at 5:42 PM Oguz kagan Olmez 
> wrote:
>
>> i just started django, python and back-end. i want to ask you a question
>> for my first project. i have functions that creating json file. After that
>> i am showing that json file on my webpage. But that functions in view take
>> a lot of time and my webpage doesn't open for like 20-30 seconds. Actually
>> my functions should work hourly and my web page doesn't depends to it.
>> something like celery is too hard and i couldn't handle it. I tried cron
>> and it gives errors on windows. thanks
>> (Django Background Tasks is my last option. but i am really tired of
>> this. I am working for days now just solve this problem)
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/04a993fd-dbb5-48da-8c22-f35369c3fbd5%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMKMUjs%2B1pRM-BPMH9XKA9aSqTGRn2ycxXmQxkFz7g5OzwoeNw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oeKpcXTRFxT%3D5i9tktWx0VjR17%2BB0dgvTE%2B-BO%2BgTcHDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to make Django Project Mobile Compatible

2019-05-11 Thread Jani Tiainen
Hi,

After all it's just HTML and CSS you need and you can make responsive
layouting.

One quite common CSS library is Bootstrap that allows rather easily to
build layouts that works across the various sized devices.

Of course you can go with any JS framework if you're planning to build
single page app.

la 11. toukok. 2019 klo 10.05 Balaji Shetty 
kirjoitti:

> Hi
>
> How can i make my Django Project view Mobile Compatible.
> Should i use Angular JS / React  . Please let me know.
>
> Thanks in Advance
>
> --
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India*
> *Official: bsshe...@sggs.ac.in  *
> *  Mobile: +91-9270696267*
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAECSbOveKW_5aohHGKCJcVxPtwMg-wTBC8ttVRpPJc3YOA7dKg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91offk%2BV4uOJuLdA7vKS%3DPXRSgOz40ZzhrzmSQY3iAFs8Pg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: reg: Django model sequense of the fields

2019-05-09 Thread Jani Tiainen
Hi.

There is no correlation between field order in your model and order in
database or database tools.

They though accidentally be the same.

ke 8. toukok. 2019 klo 18.52 'Amitesh Sahay' via Django users <
django-users@googlegroups.com> kirjoitti:

> Hello Users,
>
> I am seeing a very strange issue with my Django models.
> in my models.py, I have 21 fields. Out of them , the 6th field is
> DASHBoard. However, when I see those fields in my postgres DB through
> PgAdminIII, it is listed at the very end of the list.
>
> Sorry, for security reasons I couldn't give the list of the fields here.
>
> Could there be any explanation for this situation?
>
> Regards,
> Amitesh Sahay
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1048828608.1995499.1557330720573%40mail.yahoo.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oed9R93bwtUosRvMBBBexfBvLMotjnVTUJrhcY_36kUJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to Create Program to get current temperature of computer cpu?

2019-05-09 Thread Jani Tiainen
Hi.

This is not actually Django issue.

I bet there are several libs that can do it.


ke 8. toukok. 2019 klo 17.01 Mayur Bagul  kirjoitti:

> Hello community,
>
> i searched on google bout this and what i found was psutil is no longer
> having check temperature attribute.
>
> im not getting how to do this.
>
> help me with this !
>
> thanking you,
> Mayur Bagul.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9d3c8e19-5371-4b9b-a814-bf90fdc53a96%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofkXSu-X6HKfUNz0iq6N1V3SoYqjEX7YYF9WRDhtdF-Nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cascadind Drop Down in Django Admin Panel

2019-05-09 Thread Jani Tiainen
You could try django-select2 for example.

to 9. toukok. 2019 klo 11.03 Balaji Shetty 
kirjoitti:

>
> HI
>
> *How can I add cascading drop down for Continent and Country in Django
> Admin Panel.*
>
> Here I add Continent and Country.
>
> When i change Continent, Country should be changed automatically.
>
> How can i achieve this.
>
> Consider my model.py
>
>
> class Continent(models.Model):
>
> name = models.CharField(max_length=255)
>
>
>
> class Country(models.Model):
>
> continent = models.ForeignKey(Continent)
>
> name = models.CharField(max_length=255)
>
>
>
> class Location(models.Model):
>
> continent = models.ForeignKey(Continent)
>
> country = models.ForeignKey(Country)
>
> city = models.CharField(max_length=50)
>
> street = models.CharField(max_length=100
>
> --
>
>
> *Mr. Shetty Balaji S.Asst. ProfessorDepartment of Information Technology,*
> *SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India *
> *Official: bsshe...@sggs.ac.in  *
> *  Mobile: +91-9270696267*
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAECSbOtZ580o4Jv-zR0FiRhy6pdacJwo74zpP9xsd0P4YoxBXw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oe%3DbEAEJp%2BOfAOqnJFY8yHVymW%2B3qn5RDnoM_WnkYWgnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unit conversions between model field value and form field value

2019-05-08 Thread Jani Tiainen
Hi.

You could create custom form field that makes conversions both ways.

ke 8. toukok. 2019 klo 1.25 Tim Bell  kirjoitti:

> Hi,
>
> I have a model with an integer field storing a duration in hours, while I
> want to present that to users in a form in days. (The choice of these
> different units is imposed by other factors not under my control.)
>
> So, when saving a form, I need to convert a value in days to hours by
> multiplying by 24. I've done that with a clean_() method on
> the form, as described at
> https://docs.djangoproject.com/en/2.2/ref/forms/validation/. That works
> fine for when saving a new model.
>
> When editing an existing model however, I need to take the value from the
> model stored in hours, and convert that to days for display in the edit
> form. I've considered various places where I could do that conversion, for
> instance in the edit view, or the form __init__() method, or the model
> field's value_from_object() method, but none of those choices seem like
> the obvious choice, and I can't find a recommendation for how to do this
> either.
>
> What would you suggest? And is the recommended approach actually
> documented somewhere that I've missed?
>
> Thanks,
>
> Tim
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0d786f87-8c6e-4e0d-abc5-aaa66ab4da2a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91od3y53TA%3DYt_x8noAdPYBni8Q4P8mSorJrb2Y%2BD6zcffg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: More controls on createsuperuser

2019-04-30 Thread Jani Tiainen
I've have to agree that any attempt to limit superuser creation through
manage.py is wrong solution to wrong problem.

Even it's possible to attempt it it is as easy to circumvent.

So do not give an access to manage.py to users that are not supposed to.
Problem solved for good.

ma 29. huhtik. 2019 klo 21.04  kirjoitti:

> Anyone capable of running the createsuperuser command on your project most
> probably has access to all and any of the project's files, specially your
> config file.
>
> Actually this user is either a valid su or you are in serious trouble
> because the security of your server sucks or you gave access to your
> project to the wrong person.
>
> So, no I don't think there is any point in doing so. Not because it can't
> be done but because it is both trivially useless.and uselessly trivial.
>
>
>
> On Sunday, April 28, 2019 at 11:24:57 PM UTC-4, JJ Zolper wrote:
>>
>> All,
>>
>> Curious what people think about more thought and control going into who
>> can run the createsuperuser method?
>>
>> For example say there's models that I don't want anyone to touch except
>> myself as a superuser. Is it not plausible that even if I make a Django
>> Group around that model that someone could still run createsuperuser and
>> give themselves the ability to have full control?
>>
>> Wouldn't it make sense if some random developer were to run
>> createsuperuser using django settings with any of the databases (as an
>> example) that it prevent them if say that email isn't on say an internal
>> list in the django admin of approved potential users?
>>
>> I see something like this being a good idea to prevent just anyone from
>> getting full control over the site without it being specifically provided.
>>
>> Maybe there's something I'm missing something but been reading about
>> third party options and more about what's there and I just feel there's a
>> hole when it comes to who can create a super user account. Obviously you
>> could have a script that you run to initialize who is a super user, what
>> the groups are etc, but then you're basically recording personal
>> information somewhere when that should only be typed in.
>>
>> Open to ideas and thoughts, mostly just curious what could be a good
>> answer.
>>
>> Best,
>>
>> JJ
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f85e2d9b-ec2d-4814-b4d5-df137bf8a883%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oeeEhnsdrWfur0pV-%2B-BGU_mT70fbbmc7qFM1SwB3Df%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unable to create the django_migrations table (ORA-00907: missing right parenthesis)

2019-04-28 Thread Jani Tiainen
And why you get the error is that Oracle 12 does have new identity column
(generates primary keys without explicit trigger) which was taken into use
in Django. Oracle 11g doesn't have it and thus you get pretty strange
errors when you try to create tables that don't have valid 11g SQL syntax.

On Sun, Apr 28, 2019 at 12:59 PM Jani Tiainen  wrote:

> Hi.
>
> Django 2.2 supports Oracle 12.1+. Oracle 11g support was dropped with
> Django 2.0. If you want to use Oracle 11g (which is out of support anyway
> from Oracle) you either need to downgrade to Django 1.11 and cx_Oracle 6.4.1
>
> I really suggest you to update at least latest Oracle 12.2 which is still
> supported by Oracle.
>
> la 27. huhtik. 2019 klo 22.56 tossouwisdom 
> kirjoitti:
>
>> Django 2.2.2
>> Cx_oracle 7.2
>> base Oracle 11g
>>
>> When I run the django migrate commande, i have error 
>> django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the 
>> django_migrations table (ORA-00907: missing right parenthesis)
>>
>>   Operations to perform:
>>   Apply all migrations: admin, auth, contenttypes, sessions
>> Running migrations:
>> Traceback (most recent call last):
>>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
>> 82, in _execute
>> return self.cursor.execute(sql)
>>   File "C:\Python37-32\lib\site-packages\django\db\backends\oracle\base.py", 
>> line 510, in execute
>> return self.cursor.execute(query, self._param_generator(params))
>> cx_Oracle.DatabaseError: ORA-00907: missing right parenthesis
>>
>> The above exception was the direct cause of the following exception:
>>
>> Traceback (most recent call last):
>>   File "C:\Python37-32\lib\site-packages\django\db\migrations\recorder.py", 
>> line 67, in ensure_schema
>> editor.create_model(self.Migration)
>>   File "C:\Python37-32\lib\site-packages\django\db\backends\base\schema.py", 
>> line 307, in create_model
>> self.execute(sql, params or None)
>>   File "C:\Python37-32\lib\site-packages\django\db\backends\base\schema.py", 
>> line 137, in execute
>> cursor.execute(sql, params)
>>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
>> 99, in execute
>> return super().execute(sql, params)
>>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
>> 67, in execute
>> return self._execute_with_wrappers(sql, params, many=False, 
>> executor=self._execute)
>>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
>> 76, in _execute_with_wrappers
>> return executor(sql, params, many, context)
>>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
>> 84, in _execute
>> return self.cursor.execute(sql, params)
>>   File "C:\Python37-32\lib\site-packages\django\db\utils.py", line 89, in 
>> __exit__
>> raise dj_exc_value.with_traceback(traceback) from exc_value
>>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
>> 82, in _execute
>> return self.cursor.execute(sql)
>>   File "C:\Python37-32\lib\site-packages\django\db\backends\oracle\base.py", 
>> line 510, in execute
>> return self.cursor.execute(query, self._param_generator(params))
>> django.db.utils.DatabaseError: ORA-00907: missing right parenthesis
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File "manage.py", line 21, in 
>> main()
>>   File "manage.py", line 17, in main
>> execute_from_command_line(sys.argv)
>>   File 
>> "C:\Python37-32\lib\site-packages\django\core\management\__init__.py", line 
>> 381, in execute_from_command_line
>> utility.execute()
>>   File 
>> "C:\Python37-32\lib\site-packages\django\core\management\__init__.py", line 
>> 375, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File "C:\Python37-32\lib\site-packages\django\core\management\base.py", 
>> line 323, in run_from_argv
>> self.execute(*args, **cmd_options)
>>   File "C:\Python37-32\lib\site-packages\django\core\management\base.py", 
>> line 364, in execute
>> output = self.handle(*args, **options)
>>   File "C:\Python37-32\lib\site-packages\django\core\management\base.py", 
>> line 83, in wrapped
>> res = handle_func(*a

Re: Unable to create the django_migrations table (ORA-00907: missing right parenthesis)

2019-04-28 Thread Jani Tiainen
Hi.

Django 2.2 supports Oracle 12.1+. Oracle 11g support was dropped with
Django 2.0. If you want to use Oracle 11g (which is out of support anyway
from Oracle) you either need to downgrade to Django 1.11 and cx_Oracle 6.4.1

I really suggest you to update at least latest Oracle 12.2 which is still
supported by Oracle.

la 27. huhtik. 2019 klo 22.56 tossouwisdom 
kirjoitti:

> Django 2.2.2
> Cx_oracle 7.2
> base Oracle 11g
>
> When I run the django migrate commande, i have error 
> django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the 
> django_migrations table (ORA-00907: missing right parenthesis)
>
>   Operations to perform:
>   Apply all migrations: admin, auth, contenttypes, sessions
> Running migrations:
> Traceback (most recent call last):
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 82, in _execute
> return self.cursor.execute(sql)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\oracle\base.py", 
> line 510, in execute
> return self.cursor.execute(query, self._param_generator(params))
> cx_Oracle.DatabaseError: ORA-00907: missing right parenthesis
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File "C:\Python37-32\lib\site-packages\django\db\migrations\recorder.py", 
> line 67, in ensure_schema
> editor.create_model(self.Migration)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\base\schema.py", 
> line 307, in create_model
> self.execute(sql, params or None)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\base\schema.py", 
> line 137, in execute
> cursor.execute(sql, params)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 99, in execute
> return super().execute(sql, params)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 67, in execute
> return self._execute_with_wrappers(sql, params, many=False, 
> executor=self._execute)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 76, in _execute_with_wrappers
> return executor(sql, params, many, context)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 84, in _execute
> return self.cursor.execute(sql, params)
>   File "C:\Python37-32\lib\site-packages\django\db\utils.py", line 89, in 
> __exit__
> raise dj_exc_value.with_traceback(traceback) from exc_value
>   File "C:\Python37-32\lib\site-packages\django\db\backends\utils.py", line 
> 82, in _execute
> return self.cursor.execute(sql)
>   File "C:\Python37-32\lib\site-packages\django\db\backends\oracle\base.py", 
> line 510, in execute
> return self.cursor.execute(query, self._param_generator(params))
> django.db.utils.DatabaseError: ORA-00907: missing right parenthesis
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "manage.py", line 21, in 
> main()
>   File "manage.py", line 17, in main
> execute_from_command_line(sys.argv)
>   File "C:\Python37-32\lib\site-packages\django\core\management\__init__.py", 
> line 381, in execute_from_command_line
> utility.execute()
>   File "C:\Python37-32\lib\site-packages\django\core\management\__init__.py", 
> line 375, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "C:\Python37-32\lib\site-packages\django\core\management\base.py", 
> line 323, in run_from_argv
> self.execute(*args, **cmd_options)
>   File "C:\Python37-32\lib\site-packages\django\core\management\base.py", 
> line 364, in execute
> output = self.handle(*args, **options)
>   File "C:\Python37-32\lib\site-packages\django\core\management\base.py", 
> line 83, in wrapped
> res = handle_func(*args, **kwargs)
>   File 
> "C:\Python37-32\lib\site-packages\django\core\management\commands\migrate.py",
>  line 234, in handle
> fake_initial=fake_initial,
>   File "C:\Python37-32\lib\site-packages\django\db\migrations\executor.py", 
> line 91, in migrate
> self.recorder.ensure_schema()
>   File "C:\Python37-32\lib\site-packages\django\db\migrations\recorder.py", 
> line 69, in ensure_schema
> raise MigrationSchemaMissing("Unable to create the django_migrations 
> table (%s)" % exc)
> django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the 
> django_migrations table (ORA-00907: missing right parenthesis)
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> 

Re: GraphQL and Django integration

2019-04-28 Thread Jani Tiainen
Hi,

REST is actually protocol independent. Though most common usage is to use
it through HTTP. Same applies to GraphQL even it's protocol independent
most common usage is still through HTTP.

Now there exists library called graphene and django-graphene for Django
integration.

Challenge is that GraphQL requires much more machinery on the server side
compared to REST (which is rather straightforward).

You could start with
https://stackabuse.com/building-a-graphql-api-with-django/ for example.


On Sun, Apr 28, 2019 at 4:32 AM Britto .  wrote:

> Hi,
>
> What are the coding challenges to integrate GraphQL with Django?
> GraphQL is not like REST it is protocol independent query language.
> How to handle mutations at Django?
>
>
> Regards
> Ab
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAF0v3b40%3Db-2U40JaYObpDZNx%3DLuFti7yr4yYBBptJKSA4LTgg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAF0v3b40%3Db-2U40JaYObpDZNx%3DLuFti7yr4yYBBptJKSA4LTgg%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen
Software wizard

https://blog.jani.tiainen.cc/

Always open for short term jobs or contracts to work with 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofMNg7%3Dh14ck1offnJJBKqFJc7CJfmGLvcFUV3DmESZNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: testing API

2019-04-22 Thread Jani Tiainen
Hi,

DRF does have built-in API viewer. To enable that you need to add
rest_framework app in your INSTALLED_APPS so it can find necessary
templates for showing.

On Tue, Apr 23, 2019 at 7:15 AM Shubham Joshi  wrote:

> I have created the custom model authentication in django rest , so far I
> dont have front end , so my question is , Im I done with the API, since on
> browser it gives an error TemplateDoesNotExist at /
> rest_framework/api.html that of course due to I dont have template, in
> postmen its giving {
> "detail": "Method \"GET\" not allowed."
> } , Am I going right?
>
> https://github.com/shubham1507/school
> <https://github.com/shubham1507/school?fbclid=IwAR0euI5CitlNhZWjn5hkJVZzWJylR4Zdznx0R3HN6EhgOSpXgFaMSJfSGO4>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5596723f-0358-41b5-9b0f-cf0f9dc84057%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/5596723f-0358-41b5-9b0f-cf0f9dc84057%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen
Software wizard

https://blog.jani.tiainen.cc/

Always open for short term jobs or contracts to work with 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ocacYW95Gq%3DwH9DrWZMFjN9mWu_xEssBo%2BePh_VhbHStQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Storing HTML in DB using DJANGO

2019-04-21 Thread Jani Tiainen
Well after all, HTML is just plain text... Though you probably want to
think to do some sanitization so you won't get nasty injections via html.

On Sat, Apr 20, 2019 at 9:09 PM Sipum Mishra  wrote:

> Hi friends,
>
> I want to store a html in database using python and need to retrieve that
> html and convert that in to PDF.
> can u plz suggest me how to store that HTML in DB ?
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f301b675-6587-434e-b25d-87de9d9fef10%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f301b675-6587-434e-b25d-87de9d9fef10%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen
Software wizard

https://blog.jani.tiainen.cc/

Always open for short term jobs or contracts to work with 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oe6hUWZtEYCx%3D8uNe%3DFEphZ4C_VRPv74oK2E-x9gvJjGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - always getting False in form.is_valid()

2019-04-21 Thread Jani Tiainen
Hi,

required attribute works in forms, not in models. For models fields that
are not required in forms you need to use blank=True.

Though that's not the right solution.

Why are you including "completed" field in a form (which you validate for
user input) if you are not going to have such a input (checkbox) in a form?


On Sun, Apr 21, 2019 at 3:02 PM Sipum Mishra  wrote:

> if i do changes as above in model then it throws error like -
>
>  class List(models.Model):
>   File "F:\django\to_do_list\todo\models.py", line 6, in List
> completed = models.BooleanField(required=False)
> TypeError: __init__() got an unexpected keyword argument 'required'
>
>
> On Sun, 21 Apr 2019 at 17:27, Sipum Mishra  wrote:
>
>> Jani, Do you mean I need to change completed field in model like as below
>> ?
>>
>> completed = models.BooleanField(default=False,required=False)
>>
>> On Sun, 21 Apr 2019 at 17:23, Sipum Mishra  wrote:
>>
>>> Hi Jani,
>>> form.errors gives error as -
>>>
>>> itemThis field is
>>> required.<
>>> /li>
>>>
>>> can u plz tell me where i did wrong?
>>>
>>> On Sun, 21 Apr 2019 at 16:43, Jani Tiainen  wrote:
>>>
>>>> completed is a required field and you're not passing any value with it.
>>>> If you print form.errors you would should see that it complains about
>>>> "completed" "this field is required"
>>>>
>>>> Note that providing default value in a model is not same as making
>>>> field optional.
>>>>
>>>> On Fri, Apr 19, 2019 at 2:05 PM Sipum Mishra  wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> I am always getting - form.is_valid returning False. kindly check
>>>>> where I am doing wrong.
>>>>> please find below code.
>>>>>
>>>>>
>>>>> views.py
>>>>> ---
>>>>> def home(request):
>>>>>
>>>>> if request.method == 'POST':
>>>>> form = ListForm(request.POST or None)
>>>>> print(form.is_valid(), "-->",request.POST['Item'])
>>>>> print(form.errors)
>>>>> print(form)
>>>>> if form.is_valid():
>>>>> form.save()
>>>>> all_items = List.objects.all
>>>>> messages.success(request, ('Item has been Added to the List!'))
>>>>> return render(request,'home.html', {'all_items' : all_items})
>>>>> else:
>>>>> print("deba-->",request.POST)
>>>>> return HttpResponse("Form is invalid!")
>>>>> else:
>>>>> all_items = List.objects.all
>>>>> return render(request,'home.html', {'all_items' : all_items})
>>>>>
>>>>> -
>>>>> form.py
>>>>> -
>>>>>
>>>>> class ListForm(forms.ModelForm):
>>>>> class Meta:
>>>>> model = List
>>>>> fields = ["item", "completed"]
>>>>>
>>>>>
>>>>> 
>>>>> model.py
>>>>> -
>>>>>
>>>>> class List(models.Model):
>>>>> item = models.CharField(max_length=200)
>>>>> completed = models.BooleanField(default=False)
>>>>>
>>>>>
>>>>> def __str__(self):
>>>>> return self.item + '|' + str(self.completed)
>>>>>
>>>>> --
>>>>> 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 post to this group, send email to django-users@googlegroups.com.
>>>>> Visit this group at https://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>> --
>

Re: Django - always getting False in form.is_valid()

2019-04-21 Thread Jani Tiainen
completed is a required field and you're not passing any value with it. If
you print form.errors you would should see that it complains about
"completed" "this field is required"

Note that providing default value in a model is not same as making field
optional.

On Fri, Apr 19, 2019 at 2:05 PM Sipum Mishra  wrote:

> Hi All,
>
> I am always getting - form.is_valid returning False. kindly check where I
> am doing wrong.
> please find below code.
>
>
> views.py
> ---
> def home(request):
>
> if request.method == 'POST':
> form = ListForm(request.POST or None)
> print(form.is_valid(), "-->",request.POST['Item'])
> print(form.errors)
> print(form)
> if form.is_valid():
> form.save()
> all_items = List.objects.all
> messages.success(request, ('Item has been Added to the List!'))
> return render(request,'home.html', {'all_items' : all_items})
> else:
> print("deba-->",request.POST)
> return HttpResponse("Form is invalid!")
> else:
> all_items = List.objects.all
> return render(request,'home.html', {'all_items' : all_items})
>
> -
> form.py
> -
>
> class ListForm(forms.ModelForm):
> class Meta:
> model = List
> fields = ["item", "completed"]
>
>
> 
> model.py
> -
>
> class List(models.Model):
> item = models.CharField(max_length=200)
> completed = models.BooleanField(default=False)
>
>
> def __str__(self):
> return self.item + '|' + str(self.completed)
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen
Software wizard

https://blog.jani.tiainen.cc/

Always open for short term jobs or contracts to work with 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91of6O55rPh6fJFDHQ1Pc2v5Lk%3DT8JtN1wS_4NVuP9vi3MA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Advanced permissions and role creation

2019-04-21 Thread Jani Tiainen
Hi,

We do in our applications pretty much same approach as Mike proposed in his
post. It's relatively efficient and works for both, UI and application side
pretty well and doesn't require building anything complex and pretty much
everything you need is already built-in in Django.



On Sun, Apr 21, 2019 at 5:12 AM Joel Mathew  wrote:

> I have an application for a hospital. There, I should be able to assign
> different roles like Doctor, Nurse, Attender, Auxillary Nurse, Pharmacist,
> Store Manager etc, each of would be having specific access to seperate
> areas (views), with some having restricted access. In addition, there are
> other hospitals who would be having no access to another hospital's
> records. All of these permissions should be customisable, and I should be
> able to create additional roles and permission groups for specific areas
> later (from within the application itself, in production). What would be
> the best solution to use? Is there a middleware which works well. I don't
> want to roll my own if I will be reinventing the wheel.
>
> Currently my application has no use permissions. But access to specific
> hospitals is being restricted by a model whoch stores hospital name, and
> user name.
> Sincerely yours,
>
>  Joel G Mathew
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAA%3Diw_9BrOEh4Ss3X0g_EnaFyp1XTXij5DoZvva_XxwKVzXsGQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAA%3Diw_9BrOEh4Ss3X0g_EnaFyp1XTXij5DoZvva_XxwKVzXsGQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen
Software wizard

https://blog.jani.tiainen.cc/

Always open for short term jobs or contracts to work with 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91od2vbV7F0WwAVp6Eppqmmd5-NgZciO_04Tm%3D9x9FSJyvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to provide function calling event for button in django html templates ?

2019-04-20 Thread Jani Tiainen
Hi,

I also suggest that take a look at Django Girls tutorial. It does pretty
good job at describing web basics and django same time.

https://tutorial.djangogirls.org/en/



On Sat, Apr 20, 2019 at 10:17 AM Mayur Bagul  wrote:

> Hello Community,
>
> i'm facing one problem. Scenario is such that i have one template
> login.html in Django Project, inside this file i have wrote html code for
> login purpose.
>
> what i want that once user click on Log-In Button it should call function
> ( onclick using Javascript cant use in Django) which will check password
> and username.
> if username and password is Correct then it will go to next page which is
> main page else it will return prompt or alert 'Wrong Credentials".
>
> but im not getting how i can do this in Django ?
>
> So guys Please help me out of this issue.
>
> Thanking you,
> Mayur Bagul.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0fd23be8-b2d7-437e-b3e7-05c1f5bcdf4e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0fd23be8-b2d7-437e-b3e7-05c1f5bcdf4e%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen
Software wizard

https://blog.jani.tiainen.cc/

Always open for short term jobs or contracts to work with 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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofPJ80DzUyJEO%3DqfLuE4emRMoQ_CH-0hAqBi2vyaSunFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ReportLab or Xhtml2pdf Please can any one guide me to convert the rendered in html to pdf

2019-04-19 Thread Jani Tiainen
Hi.

I've had pretty good success with wkthtmltopdf.


pe 19. huhtik. 2019 klo 21.11 Irfan Khan  kirjoitti:

> hi,
> i stucked in converting the pdf file from html
> can an one suggest me even any other possibility instead of using python
> library
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6862bdc2-bb4f-4253-99de-7606a6b5ac2b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oeTYfQS4tUaSJ6-KgR%2B5wD9gyM0AhmoeAtF4h1JXO7-%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: 'WSGIRequest' object has no attribute 'Files'

2019-04-16 Thread Jani Tiainen
Hi.

It is .FILES all in capital. Not just first letter.


ti 16. huhtik. 2019 klo 10.05 Soumen Khatua 
kirjoitti:

> Hi Folks,
> I'm getting this error 'WSGIRequest' object has no attribute 'Files' and
> i didn't get proper solution in google also. I alredaty took
> *enctype="multipart/form-data"* in my forms tag. Here is my code snippet
> please provide me the solution it's urgent.
>
> Thank you in advance.
>
> *.html*
>
>   
> {% csrf_token %}
> {{ p_form.as_p }}
> 
>   
>
>
> *models.py*
>
> *class Profile(models.Model):*
> *user = models.OneToOneField(User, on_delete=models.CASCADE)*
> *bio =  models.TextField(blank=True, null=True)*
> *image = models.ImageField(default='profile/default.jpg',
> upload_to='profile')*
>
> views.py
>
> *def profile_view(request): if request.method == 'POST': print("this is
> update form post method") p_form =
> ProfileUpdateForm(request.POST,request.Files,instance =
>
> request.user.profile) if  p_form.is_valid():
> p_form.save()  return redirect('profile')*
>
> Error:
>
> 'WSGIRequest' object has no attribute 'Files'
>
>
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPUw6WYQi_pc-GHt8-jsupbkuamL9RK7TZXV3J%3D%2B3yd%3DoWUtiQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofCbdtnEfKNeYjLVjgmPh6BH4BJVEUaV8p74DqzqYcxBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How this Line of code works

2019-04-15 Thread Jani Tiainen
Hi.

get_object_or_404 works so that first argument is the model class you want
to query. Rest of the parameters are filters that mus return a single
object.

You can find this information from the Django docs as well.


ma 15. huhtik. 2019 klo 7.23 Mayur Bagul  kirjoitti:

> how passing Question and pk=question_id gonna help?
>
> On Sunday, April 14, 2019 at 5:41:06 PM UTC+5:30, gulam rabbani wrote:
>>
>> It will give you to fetch the id ! Until end of the id
>>
>> On Sun, 14 Apr, 2019 at 1:47 PM, Mayur Bagul  wrote:
>>
>>> In below code i didnt understand how colored line of code is working
>>> with template code ?
>>>
>>> why we are passing Question and primary key? instead of dictionary to
>>> context variable.
>>>
>>> plz help me to get out of this confusion.
>>>
>>> thanking you.
>>>
>>>
>>>  *view.py*
>>>
>>>
>>> from django.shortcuts import get_object_or_404, render
>>>
>>> from .models import Question
>>> # ...
>>> def detail(request, question_id):
>>> question = get_object_or_404(Question, pk=question_id)
>>> return render(request, 'polls/detail.html', {'question': question})
>>>
>>>
>>>
>>>  *detail.html*
>>>
>>>
>>> {{ question.question_text }}
>>> 
>>> {% for choice in question.choice_set.all %}
>>> {{ choice.choice_text }}
>>> {% endfor %}
>>> 
>>>
>>>
>>>
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/73130e11-1eaf-4f03-8b56-3d6d4be6fd50%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0215a6f0-6a83-47a1-bf84-78c5608f8353%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ocSHH40kRXexvZJ-QzPLXHUGzZy3ZSJg1LtWPQk6DR9XQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to deploy migrations to production

2019-04-02 Thread Jani Tiainen
Hi.

You should deliver migrations as part of your product and run them on
production. Just like you do with collectstatic command you run migrate
command.

Eventually you will have data migrations and those you can't recreate on
production. Also if you recreate migrations on production again there is
not easy way to reproduce same db state locally for debugging purposes.

ti 2. huhtik. 2019 klo 15.51 Simon A  kirjoitti:

> There is a workflow section in the migration page from the django project
> documentation. But there are somethings I am confused about,
>
> It says that the migrations need to be created in the non production
> environment and then checked in to the repository along with the changes in
> models.py.
>
> My question is how would that migration be applied in the production
> environment.
>
> Once the new migrations and changes in the model are deployed in the
> server, should I execute *python manage.py migrate* in the server?
>
> Or is it also acceptable to just deploy the changes in production
> environment, then execute *makemigrations* and *migrate* in production?
>
> FYI, our deployment process is still a bit manual. There is a different
> person handling the production servers so I'd still have to document the
> deployment steps and endorse to the sysadmins that will perform the change
> in the server.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/35d6d27e-6210-4c8c-b31c-2adb424b9773%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oeLZCGByk6-fw8g8hrm7WQKsE82vrNUPf0ats71NkfZ_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   5   6   7   8   >