Re: django windows apache tell if apache is working

2018-07-03 Thread Bob Bobsled
Hi,
I think I see the problem now.

WAMP is a special case for aliases, and it's root directory default setup
in c:wamp\www for ex..  I need to do some more work on, say for ex. using
Django Tut 01, setting up mysite as an alias in wamp, and then putting the
polls app in it.  I believe apache might start to work then with django if
the wamp alias is setup correctly.

I also found this vid tut:  really good, but for XAMPP, not WAMP...but it
shows how to get the mod_wsgi.so from a renamed and extracted .whl file.
And using the mod_wsgi.so with apache simplifies things a bit, so this is
good too.

XAMPP
This shows how to create a mod_wsgi.so from the .pyd extracted from the
.whl file
https://www.youtube.com/watch?v=VnR5O4IjmOs

Regards


On Sat, Jun 30, 2018 at 10:08 AM, Jason  wrote:

> I meant the tutorial at https://docs.djangoproject.
> com/en/2.0/intro/tutorial01/
>
> That said, there's a few different ways you can actually deploy, but
> digitalocean has some good resources for starting out.
>
> https://www.digitalocean.com/community/tutorials/how-to-
> serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04
>
> This one shows how to use apache on ubuntu, and you should be able to
> extrapolate to use wamp.
>
> what I would do is just set up a simple view to return a http response
> saying "working", and map that to the root.  Something like
>
> app/views
>
> def index(request):
> return HttpResponse("Working!")
>
> app/urls
>
> from app.views import index
> urlpatterns = [
> path('', index),
> ]
>
> and hit localhost.  That'll be all you need.
>
> Hi,
>> Thanks.
>> Yes, I went thru the Mozilla library tutorial on a fedora dev machine to
>> the point where I realized I needed to do more with the last mile, so to
>> speak working on setup of the production server part on Windows and wamp.
>> Seems most tuts end at manage.py runserver, or start into deployment from
>> dev to production.  I can't seem to locate a good uptodate tut for wamp
>> that shows how to test everything is working properly in a simple manner
>> for the wsgi part.
>>
>> I'm just trying to verify the plumbing (httpd.conf, settings.py wsgi.py)
>> is working with apache, before spending too much more time building a site.
>>
>>
>> On Sat, Jun 30, 2018 at 2:54 AM, Jason  wrote:
>>
>>> appreciate the detailed report :-)
>>>
>>> so, have you set up the django tutorial project?  that application
>>> method in wsgi doesn't make any sense.  you should have urls and views set
>>> up in your project
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>> pic/django-users/-eJaLuJ85KE/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> django-users...@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/ms
>>> gid/django-users/6d241c04-55be-4524-959e-09630a7bc21f%40googlegroups.com
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/-eJaLuJ85KE/unsubscribe.
> To unsubscribe from this group and all its topics, 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/6f5e5996-a85e-4eb6-b5e4-804f7379a2b4%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/CALWZDaNY4miqCqxy%3DLvH4417%3DP4XGOuHAOepCBT2tPpg0wqkrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-raster rendering raster url

2018-07-03 Thread Jason
No, they don't mean coordinates, they mean the actual index location in a 
grid.

Say you have a 100x100 grid, each (x, y) coordinate like (1, 5) represents 
one tile image.

On Tuesday, July 3, 2018 at 3:43:07 PM UTC-4, Xristos Xristoou wrote:
>
> i want to add raster functionality in django using postgis database using 
> django-raster package and this docs 
> .
>
> here my code :
>
> models.py
>
> from django.contrib.gis.db import modelsclass RasterWithName(models.Model):
> raster = models.RasterField()
> name = models.TextField()
>
> add raster using console :
>
> from django.contrib.gis.gdal import GDALRasterfrom myapp.models import 
> RasterWithName
> gdal_raster = GDALRaster('C:/Users/username/Desktop/image.tif')
> rast = RasterWithName(name='one', raster=gdal_raster)
> rast.save()
>
> but i am very confused with Rendering tiles and urls.
>
> docs say :
>
> */raster/tiles/layer_id/{z}/{x}/{y}.png where the layer_id is the primary 
> key of a raster layer. This structure can be used directly in online 
> mapping software such as OpenLayers or Leaflet. An example request could 
> look like this: /raster/tiles/23/8/536/143.png, returning a tile in png 
> format of the layer with ID pk=23 at zoom level z=8 and indexes x=536 and 
> y=143*
>
> but indexes x,y mean some random x,y coordinate in image ?anyway i using 
> this url http://127.0.0.1:8000/raster/tiles/1/8/536/143.png or 
> http://127.0.0.1:8000/raster/tiles/1/8/20/40.png(origin x,y in my image) 
> and i take a black window in my browser,any idea where i have wrong in my 
> url rendering ?
>

-- 
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/77b21ebc-913f-48f9-a9f8-28b742a116fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django send_mail on production (gmail)

2018-07-03 Thread Jason
https://stackoverflow.com/help/how-to-ask

Learning how to ask a good question, whatever language you speak, is an 
invaluable skill.  

On Tuesday, July 3, 2018 at 10:10:19 AM UTC-4, Mikhailo Keda wrote:
>
> More details is needed? Do you have any error? What hosting are you using? 
> What port are you using, is it open?
>

-- 
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/f7fa4e6a-837c-4fd2-990f-631db081a1b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django-raster rendering raster url

2018-07-03 Thread Xristos Xristoou


i want to add raster functionality in django using postgis database using 
django-raster package and this docs 
.

here my code :

models.py

from django.contrib.gis.db import modelsclass RasterWithName(models.Model):
raster = models.RasterField()
name = models.TextField()

add raster using console :

from django.contrib.gis.gdal import GDALRasterfrom myapp.models import 
RasterWithName
gdal_raster = GDALRaster('C:/Users/username/Desktop/image.tif')
rast = RasterWithName(name='one', raster=gdal_raster)
rast.save()

but i am very confused with Rendering tiles and urls.

docs say :

*/raster/tiles/layer_id/{z}/{x}/{y}.png where the layer_id is the primary 
key of a raster layer. This structure can be used directly in online 
mapping software such as OpenLayers or Leaflet. An example request could 
look like this: /raster/tiles/23/8/536/143.png, returning a tile in png 
format of the layer with ID pk=23 at zoom level z=8 and indexes x=536 and 
y=143*

but indexes x,y mean some random x,y coordinate in image ?anyway i using 
this url http://127.0.0.1:8000/raster/tiles/1/8/536/143.png or 
http://127.0.0.1:8000/raster/tiles/1/8/20/40.png(origin x,y in my image) 
and i take a black window in my browser,any idea where i have wrong in my 
url rendering ?

-- 
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/50b2b584-2991-4b8a-84b5-8886354eb60d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Set null value for floatfield

2018-07-03 Thread Jason
sounds like you didn't make a migration after the change.

On Tuesday, July 3, 2018 at 1:24:40 AM UTC-4, Rakhee Menon wrote:
>
> Yeah! but now I get this error
>
> 'required': 'This field is required.', 'null': 'This field may not be 
> null.', 'invalid': 'Invalid data. Expected a dictionary, but got 
> {datatype}.'}
> ipdb> serializer.errors
> {'cast_weight': ['A valid number is required.']}
>
> In models.py 
> cast_weight = models.FloatField(null=True, blank=True)
>
>

-- 
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/50326925-a141-404d-bd87-bc7c7bf81fcc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


TestCase vs TransactionTestCase

2018-07-03 Thread clavierplayer
Hello, I'm looking for some insight for some odd behavior with some unit 
tests, which I think stems from some misunderstanding of how these classes 
actually work. 

1. For TestCase, the Django docs say that it does matter what order in 
which the tests are run. But elsewhere in the same doc, it says that 
TestCase methods are individually wrapped in a single transaction block 
that is rolled back after the test completes. So... does each test method 
start 'fresh' or not? I currently have a test method that is supposed to 
query two records, but so far it finds either 4 or 6 with no apparent 
pattern; so I don't know if it's my code that is causing problems or the 
order in which my tests are running. 

2. The strangest behavior comes from a test method that passes by itself, 
fails when run with all the others, but the code under test actually does 
seem to work. As one might expect, the section under test takes some 
records created especially for that purpose and modifies a few fields; the 
test calls the function, queries the test database, and assert-tests the 
results. The test fails, saying that only some of the fields were 
successfully changed. I thought that I perhaps forgot to call save() in one 
of my conditional branches, but I looked and found that save() was in 
indeed where it belonged. I stepped through the code and everything 
appeared to work as expected. The values looked correct. Finally, I stuck a 
query into the code under test itself immediately before the return 
statement, and printed the results; and the query proves that the database 
field values themselves did indeed change correctly. But after the return 
statement (when it goes back to the test method itself), an identical query 
gets different results. So I'm rather puzzled. I do use select_for_update 
in my section under test, which I know sometimes causes problems with 
TestCase, but all I'm doing is testing for correct results.

3. I thought subclassing TransactionTestCase instead might solve both 
problems, but set-up data that works flawlessly with TestCase breaks every 
single test with TransactionTestCase--get() complains about non-existent 
records, the db complains about broken constraints, etc. I use both 
create() and bulk_create() in setting up my data, but neither appears to 
work at all. I tried using them in setUpTestData(), setUpClass(), and 
setUp(), and not a single test would run with any of them. 

The docs say that the two classes 'are identical except for the manner in 
which the database is reset to a known state', so I'm not sure where I went 
wrong.

Using Django 2.0. And unfortunately we use MS SQL Server, which probably 
isn't helping. 

Thank you!
Heather

-- 
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/671d7dc0-ce5a-4e90-9a44-70357ecd8f6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dynamic model fields using mysql?

2018-07-03 Thread hanleybrand
One question I'd ask would be why you wouldn't just save the files either 
on disk or even in the database (using the  BLOB datatype) if it absolutely 
had to be in the database... then if you needed to manipulate/display/read 
them at a later date you would just load the files in question. 

If you really need to save the data in the database using a django model, 
take a look at MDID's solution in rooibos.data.models 
, 
especially the Record 

 
(which would be a row in the excel spreadsheet) and the Field 

 
(which would be a cell) models -- this isn't a copy/paste solution because 
the MDID app is more complicated than you want (it allows arbitrary 
metadata which may or may not be part of an established standard like 
Dublin Core, etc. to be stored as part of a record, and allows each field 
to be listed as an equivalent to another), but this implementation works 
with MySQL, and performance shouldn't be too bad, although if you wanted to 
implement good search capabilities you'll probably need to look at Solr or 
some other indexing solution. 

Good luck!


On Monday, July 2, 2018 at 3:48:46 PM UTC-4, hardik dadhich wrote:
>
> Hello,
> Can anyone tell me how can I make dynamic Django model fields? I mean to 
> say that I want to save excel file data in Django model using MySQL. and 
> excel column can vary. The user can upload 100 column table or he can be 
> upload 1000 column table in the database. so it is possible to add 
> dynamically in db. 
>
> Any help would be appreciated.
> 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/fe124fed-2924-4b5d-b86a-aeca431e0a11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Makemigration not working.. Please help me

2018-07-03 Thread Keshav Garg
Make sure that your app_name is there in setting.py under INSTALLED_APPS 
and register your model under admin.py
Also there is indentation error in your model POST. Please correct it 
before running makemigrations command.
I hope this will Work :-)

On Tuesday, July 3, 2018 at 11:10:16 AM UTC+5:30, Tamilvanan Anbalagan 
wrote:
>
>
> When i execute the makemigrations command i am getting below error 
> pleae help me to resolve this
>
>
>
>
> (py1) c:\TransportPortal\djangoproject>django-admin makemigrations portal
> Traceback (most recent call last):
>   File "c:\program files (x86)\python36-32\Lib\runpy.py", line 193, in 
> _run_modu
> le_as_main
> "__main__", mod_spec)
>   File "c:\program files (x86)\python36-32\Lib\runpy.py", line 85, in 
> _run_code
> exec(code, run_globals)
>   File "C:\Users\nb97441\Envs\py1\Scripts\django-admin.exe\__main__.py", 
> line 9,
>  in 
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\core\management\__ini
> t__.py", line 371, in execute_from_command_line
> utility.execute()
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\core\management\__ini
> t__.py", line 365, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\core\management\__ini
> t__.py", line 216, in fetch_command
> klass = load_command_class(app_name, subcommand)
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\core\management\__ini
> t__.py", line 36, in load_command_class
> module = import_module('%s.management.commands.%s' % (app_name, name))
>   File "c:\users\nb97441\envs\py1\lib\importlib\__init__.py", line 126, in 
> impor
> t_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 994, in _gcd_import
>   File "", line 971, in _find_and_load
>   File "", line 955, in 
> _find_and_load_unlocked
>   File "", line 665, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 219, in 
> _call_with_frames_removed
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\core\management\comma
> nds\makemigrations.py", line 10, in 
> from django.db.migrations.autodetector import MigrationAutodetector
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\db\migrations\autodet
> ector.py", line 11, in 
> from django.db.migrations.questioner import MigrationQuestioner
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\db\migrations\questio
> ner.py", line 9, in 
> from .loader import MigrationLoader
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\db\migrations\loader.
> py", line 8, in 
> from django.db.migrations.recorder import MigrationRecorder
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\db\migrations\recorde
> r.py", line 9, in 
> class MigrationRecorder:
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\db\migrations\recorde
> r.py", line 22, in MigrationRecorder
> class Migration(models.Model):
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\db\models\base.py", l
> ine 100, in __new__
> app_config = apps.get_containing_app_config(module)
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\apps\registry.py", li
> ne 244, in get_containing_app_config
> self.check_apps_ready()
>   File 
> "c:\users\nb97441\envs\py1\lib\site-packages\django\apps\registry.py", li
> ne 127, in check_apps_ready
> raise AppRegistryNotReady("Apps aren't loaded yet.")
> django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
>
>
> (py1) c:\TransportPortal\djangoproject>python manage.py check
> System check identified no issues (0 silenced).
>
> (py1) c:\TransportPortal\djangoproject>
>
>
> from django.db import models
> from django.contrib.auth.models import User
>
>
> class Post(models.Model):
> post = models.CharField(max_length=255)
> user = models.ForeignKey(User, on_delete=models.PROTECT)
>

-- 
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/17457afb-6ea8-4f3d-8f99-cc9302c41d90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django send_mail on production (gmail)

2018-07-03 Thread Mikhailo Keda
More details is needed? Do you have any error? What hosting are you using? 
What port are you using, is it open?

-- 
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/153e2c27-1953-4949-8766-a73763d14eb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: A few doubts with an implementation.

2018-07-03 Thread Bill Torcaso

I didn't deeply consider your problem, but the aspect of doing a repetitive 
task at unrelated time intervals reminds me of how the Unix kernel handles 
the alarm() system call for multiple, unrelated processes.  For you, it 
will take at most one thread to handle any number of users.


   1. Maintain a first-in-first-out queue, sorted by time.
   2. An item in the queue has identifying info about a user, and (*this is 
   the key fact*) a measure of time relative to the queue item before it.
   3. When a new user appears, create a queue entry for that user at the 
   appropriate spot in the time-relative queue.  That might always be at the 
   end, but if different users get the email fetched at different intervals, 
   the insertion spot might be in the interior of the queue.
   4. When a user logs out, or by whatever criteria you chose, scan the 
   list and remove any queue entry that refers to that user.

The API for other code to call the queue-management thread is only two 
things:  

   - Create an entry for this user, at this repetition interval.  
   - Remove the entry this user.

The rest of the code for the queue is internal implementation details.This 
is the action of the queue-management thread:

   1. At start-time, create this thread.  It is idle to start with.
   2. When a user logs in, other code will send a signal to the thread.  
   When a user logs out, likewise send a signal to the queue-management thread.
   3. The thread calculates how long to sleep before waking up and fetching 
   email for the entry at the head of the queue.
   4. When the thread wakes up, it does the work for the item at the head 
   of the queue.  If that work takes a long time, or has complex handling of 
   errors during the work, you might spawn a thread to do the work outside of 
   the queue-management thread.
   5. Remove that queue-head item. Re-insert it at the place in the queue 
   for its next execution on behalf of this user.  That will likely be at the 
   end, but might be in the interior of the queue.
   6. Loop back to #3.





On Monday, July 2, 2018 at 9:36:13 AM UTC-4, Vineeth Sagar wrote:
>
> Problem:
> We are developing a email-CRM. The task at hand is to fetch emails every N 
> minutes or hours. I have received a codebase written by another guy who 
> left the company,my job is to re-write/re-factor. The guy who previously 
> wrote the code started a thread whenever a user logged and he put a 
> time.sleep() inside it, There's no limit on number of threads that can be 
> initialized, if 100 users log in, we will have 100 active threads, he used 
> locks so that at any given time only one thread can be executed. 
>
> Solution:
> It's messy in so many ways(mentioned above) and I think writing django 
> middleware would be appropriate for this task. So here's what I plan to do, 
> using a Django cache I store a Python datetime object and a flag to see if 
> there is any other request that's already retrieving the mails, I don't 
> want multiple requests to retrieving mails at once. Is this a better idea? 
> Are there any other ways to do this particular task?
>
> One more doubt I have is I want the user to know that the mails are being 
> retrieved so he doesn't refresh the page passive-aggressively. How can I do 
> this? I want the user to know it's happening and in the background 
> middleware should be executed, I have to keep retrieving mails and once 
> it's completed I'll execute the view_func parameter received via the 
> process_request hook. 
>
> I am a junior at the company(Start up),I am fairly new to django, I keep 
> reading the documentation and find new things daily,after picking my mind 
> for a day this to me seems best, but please if you have any suggestion let 
> me know. Please help me out. 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 visit 
https://groups.google.com/d/msgid/django-users/f0f061c8-a04f-445a-aa16-210cfd9e693d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django send_mail on production (gmail)

2018-07-03 Thread Kamal Sharma
Dear django community,

I'm working on mail with django but it is working fine in my dev server
(local) but on production it is not working.

Can you help me please?

Thanks

Kamal Sharma

-- 
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/CAByCWTQR%3DfiUgMjEm1Rx7QQh4STcCnzTibt6zH-dbS%2B0FxYDxA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django production deployment on my VPS

2018-07-03 Thread Vinicius Assef
The first thing you really should install in your VPS server is fail2ban.

Read about it.


On 3 July 2018 at 03:04, Kamal Sharma  wrote:
> is this production environment with gunicorn and nginx is robust, can i
> develop a big portal and deploy into it with no problem??
>
> On Sun, Jul 1, 2018 at 9:45 AM Gerardo Palazuelos Guerrero
>  wrote:
>>
>> hi Kamal,
>> I found this link as part of a django training I did in a udemy course
>> (https://www.udemy.com/the-ultimate-beginners-guide-to-django-python-web-dev-website).
>>
>> Link is:
>>
>> https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
>>
>> I hopes that helps you.
>> Gerardo.
>>
>>
>>
>> El 30/06/2018, a la(s) 21:22, Kamal Sharma 
>> escribió:
>>
>> Dear Django community,
>>
>> I have developed my django application but i am facing problem to deploy
>> it on my "virtual private server". And tutorial of production deployment are
>> making me so confuse so i am unable to deploy it.
>> Can you please share with me the steps to deploy my django project on
>> production with VPS.
>>
>> Your immediate action will be highly appreciated.
>>
>> Thanks
>>
>> Kamal Sharma
>>
>> --
>> 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/095a451f-4b0a-49e6-8d2a-baa3f53832c9%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/AFCC3BE9-B379-430D-9D96-0AD19EB0F298%40gmail.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/CAByCWTRdssb0rROxHGc4a%3D6JUBtfdDFGchbVotTtZraS12iqPg%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/CAFmXjSDuB3XWgtwHjRLYR-%2BTvYBtB_Y%3Dei%3DU54oPHCTe_%3DwwNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Invalid HTTP_HOST header when website being accessed by public IP

2018-07-03 Thread Kasper Laudrup

Hej again Melvyn,

On 07/03/2018 12:13 AM, Melvyn Sopacua wrote:


The only reason to set it up like that for HTTPS is that it's possible the SNI
name differs from the HTTP Host header. For HTTP redirects it makes no sense:
the HTTP header is in plain text and is used to determine the server block to
pick. So putting an if statement there, is just doing it again, on every
request, because electrons are cheap. Save the electrons!



Thanks for your explanation.

So, if I understand you correctly, it does make sense to explicitly test 
for the host header in a HTTPS request, like I have done, but not in the 
setup I got from letsencrypt where HTTP traffic is redirected to HTTPS 
if the HOST headers matches?



Anyhow - instead of return 404, I would do:

return 301 https://$server_name$request_uri



I guess I could do that as well, but then I guess whatever is trying to 
crawl, exploit whatever my host would get redirected to the actual site, 
which I find unnecessary. Right?



How I normally set things up:

server {
listen 443 default_server ssl http2;
server_name localhost;

return 301 https://djangoserver.example.com$request_uri
}



Wouldn't this require having at least a self signed certifate for this 
server section, even if it's just used to redirect? Admittedly, I 
haven't tried it.


Thanks a lot for your help.

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 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/1c39fb17-cc6f-86fa-03e7-ed3699638997%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Set blank value for floatField

2018-07-03 Thread Rakhee Menon
ipdb> serializer.errors
{'cast_weight': ['A valid number is required.']}

In models.py 
cast_weight = models.FloatField(null=True, blank=True)

-- 
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/9ccb2e36-8278-4c1e-a34e-e365ff6248b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django production

2018-07-03 Thread PASCUAL Eric
Hi Kamal,


Of course you can. It's just a matter of defining virtual hosts in Nginx 
configuration and route them to the different Gunicorns serving your apps, 
based on the host found in the requests URLs.


Best regards


Eric


From: django-users@googlegroups.com  on behalf 
of Kamal Sharma 
Sent: Tuesday, July 3, 2018 9:01:09 AM
To: django-users@googlegroups.com
Subject: django production

Dear Django community,

i have deployed my django project at production server with gunicorn and nginx 
and it is working good.

My question is can i deploy more then one django project on production 
server(ubuntu 16.04) for running two websites?

Thank you

Kamal Sharma

--
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/CAByCWTQ-_wYAYZAB1r-wCHwXdJVxrOViHqTfg5dK%2BCKmJSqw5g%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/VI1P193MB0432BDA408F9E8B7B8197E388C420%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Django production deployment on my VPS

2018-07-03 Thread Gerardo Palazuelos Guerrero
hi Kamal,
In the course I did, we moved files using FTP.
In reality, you can use SSH / SCP, FTP or git repository (on the latter,
remember to avoid uploading any sensitive info to repository).

Whatever method you use, please consider first setting up a firewall and
proper firewall rules to minimize attacks.

I hopes that helps.
Gerardo.




--
Gerardo Palazuelos Guerrero


On Tue, Jul 3, 2018 at 1:06 AM, Kamal Sharma  wrote:

> Hi Gerado Palazuelos Guerrero,
>
> Thanks a lot is is working fine for me, now i am able to deploy my django
> project on production server.  But i have some questions related to the
> same, that how can i deploy my changes from local to production, can it is
> possible by copy my django app from local to production by winSCP and then
> i run???
>
> Please help me
>
> Thanks
>
> Kamal Sharma
>
> On Sun, Jul 1, 2018 at 9:45 AM Gerardo Palazuelos Guerrero <
> gerardo.palazue...@gmail.com> wrote:
>
>> hi Kamal,
>> I found this link as part of a django training I did in a udemy course (
>> https://www.udemy.com/the-ultimate-beginners-guide-to-
>> django-python-web-dev-website).
>>
>> Link is:
>> https://www.digitalocean.com/community/tutorials/how-to-
>> set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
>>
>> I hopes that helps you.
>> Gerardo.
>>
>>
>>
>> El 30/06/2018, a la(s) 21:22, Kamal Sharma 
>> escribió:
>>
>> Dear Django community,
>>
>> I have developed my django application but i am facing problem to deploy
>> it on my "virtual private server". And tutorial of production deployment
>> are making me so confuse so i am unable to deploy it.
>> Can you please share with me the steps to deploy my django project on
>> production with VPS.
>>
>> Your immediate action will be highly appreciated.
>>
>> Thanks
>>
>> Kamal Sharma
>>
>> --
>> 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/095a451f-4b0a-49e6-8d2a-baa3f53832c9%
>> 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/AFCC3BE9-B379-430D-9D96-0AD19EB0F298%40gmail.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/CAByCWTT%3D4Ck6jLCZM7xWtpYDGxoS%3Dns%
> 2Bqe-Q4_UC96OC-0pzNw%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/CAJ8iCyOW3hg37wZpUaWnUNkBEaTxB6RhAUQUHd8NS75D4BxgVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django production deployment on my VPS

2018-07-03 Thread Kamal Sharma
Hi Gerado Palazuelos Guerrero,

Thanks a lot is is working fine for me, now i am able to deploy my django
project on production server.  But i have some questions related to the
same, that how can i deploy my changes from local to production, can it is
possible by copy my django app from local to production by winSCP and then
i run???

Please help me

Thanks

Kamal Sharma

On Sun, Jul 1, 2018 at 9:45 AM Gerardo Palazuelos Guerrero <
gerardo.palazue...@gmail.com> wrote:

> hi Kamal,
> I found this link as part of a django training I did in a udemy course (
> https://www.udemy.com/the-ultimate-beginners-guide-to-django-python-web-dev-website
> ).
>
> Link is:
>
> https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
>
> I hopes that helps you.
> Gerardo.
>
>
>
> El 30/06/2018, a la(s) 21:22, Kamal Sharma 
> escribió:
>
> Dear Django community,
>
> I have developed my django application but i am facing problem to deploy
> it on my "virtual private server". And tutorial of production deployment
> are making me so confuse so i am unable to deploy it.
> Can you please share with me the steps to deploy my django project on
> production with VPS.
>
> Your immediate action will be highly appreciated.
>
> Thanks
>
> Kamal Sharma
>
> --
> 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/095a451f-4b0a-49e6-8d2a-baa3f53832c9%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/AFCC3BE9-B379-430D-9D96-0AD19EB0F298%40gmail.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/CAByCWTT%3D4Ck6jLCZM7xWtpYDGxoS%3Dns%2Bqe-Q4_UC96OC-0pzNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django production

2018-07-03 Thread Kamal Sharma
 Dear Django community,

i have deployed my django project at production server with gunicorn and
nginx and it is working good.

My question is can i deploy more then one django project on production
server(ubuntu 16.04) for running two websites?

Thank you

Kamal Sharma

-- 
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/CAByCWTQ-_wYAYZAB1r-wCHwXdJVxrOViHqTfg5dK%2BCKmJSqw5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django production deployment on my VPS

2018-07-03 Thread Kamal Sharma
is this production environment with gunicorn and nginx is robust, can i
develop a big portal and deploy into it with no problem??

On Sun, Jul 1, 2018 at 9:45 AM Gerardo Palazuelos Guerrero <
gerardo.palazue...@gmail.com> wrote:

> hi Kamal,
> I found this link as part of a django training I did in a udemy course (
> https://www.udemy.com/the-ultimate-beginners-guide-to-django-python-web-dev-website
> ).
>
> Link is:
>
> https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
>
> I hopes that helps you.
> Gerardo.
>
>
>
> El 30/06/2018, a la(s) 21:22, Kamal Sharma 
> escribió:
>
> Dear Django community,
>
> I have developed my django application but i am facing problem to deploy
> it on my "virtual private server". And tutorial of production deployment
> are making me so confuse so i am unable to deploy it.
> Can you please share with me the steps to deploy my django project on
> production with VPS.
>
> Your immediate action will be highly appreciated.
>
> Thanks
>
> Kamal Sharma
>
> --
> 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/095a451f-4b0a-49e6-8d2a-baa3f53832c9%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/AFCC3BE9-B379-430D-9D96-0AD19EB0F298%40gmail.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/CAByCWTRdssb0rROxHGc4a%3D6JUBtfdDFGchbVotTtZraS12iqPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Makemigration not working.. Please help me

2018-07-03 Thread Mark Phillips
To start with, in your Post class, you need to indent the post= and user=
lines. Like this:

class Post(models.Model):
post = models.CharField(
user = models. ForeignKey(..

Python depends on indentation -
https://www.python-course.eu/python3_blocks.php. You can Google "Python
indentation rules" for more explanation.

There may be other things wrong with your code, but start by fixing this
one thing and try again!

Mark

On Mon, Jul 2, 2018 at 10:40 PM, Tamilvanan Anbalagan <
tamilanbala...@gmail.com> wrote:

>
> When i execute the makemigrations command i am getting below error
> pleae help me to resolve this
>
>
>
>
> (py1) c:\TransportPortal\djangoproject>django-admin makemigrations portal
> Traceback (most recent call last):
>   File "c:\program files (x86)\python36-32\Lib\runpy.py", line 193, in
> _run_modu
> le_as_main
> "__main__", mod_spec)
>   File "c:\program files (x86)\python36-32\Lib\runpy.py", line 85, in
> _run_code
> exec(code, run_globals)
>   File "C:\Users\nb97441\Envs\py1\Scripts\django-admin.exe\__main__.py",
> line 9,
>  in 
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\core\
> management\__ini
> t__.py", line 371, in execute_from_command_line
> utility.execute()
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\core\
> management\__ini
> t__.py", line 365, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\core\
> management\__ini
> t__.py", line 216, in fetch_command
> klass = load_command_class(app_name, subcommand)
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\core\
> management\__ini
> t__.py", line 36, in load_command_class
> module = import_module('%s.management.commands.%s' % (app_name, name))
>   File "c:\users\nb97441\envs\py1\lib\importlib\__init__.py", line 126,
> in impor
> t_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 994, in _gcd_import
>   File "", line 971, in _find_and_load
>   File "", line 955, in
> _find_and_load_unlocked
>   File "", line 665, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 219, in
> _call_with_frames_removed
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\core\
> management\comma
> nds\makemigrations.py", line 10, in 
> from django.db.migrations.autodetector import MigrationAutodetector
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\
> migrations\autodet
> ector.py", line 11, in 
> from django.db.migrations.questioner import MigrationQuestioner
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\
> migrations\questio
> ner.py", line 9, in 
> from .loader import MigrationLoader
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\
> migrations\loader.
> py", line 8, in 
> from django.db.migrations.recorder import MigrationRecorder
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\
> migrations\recorde
> r.py", line 9, in 
> class MigrationRecorder:
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\
> migrations\recorde
> r.py", line 22, in MigrationRecorder
> class Migration(models.Model):
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\db\models\base.py",
> l
> ine 100, in __new__
> app_config = apps.get_containing_app_config(module)
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\apps\registry.py",
> li
> ne 244, in get_containing_app_config
> self.check_apps_ready()
>   File "c:\users\nb97441\envs\py1\lib\site-packages\django\apps\registry.py",
> li
> ne 127, in check_apps_ready
> raise AppRegistryNotReady("Apps aren't loaded yet.")
> django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
>
>
> (py1) c:\TransportPortal\djangoproject>python manage.py check
> System check identified no issues (0 silenced).
>
> (py1) c:\TransportPortal\djangoproject>
>
>
> from django.db import models
> from django.contrib.auth.models import User
>
>
> class Post(models.Model):
> post = models.CharField(max_length=255)
> user = models.ForeignKey(User, on_delete=models.PROTECT)
>
> --
> 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/617b0048-6e23-4d82-b879-6e3b187ca039%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