Re: A lot of Problems with Migrating (conceptual)

2017-08-27 Thread Alexander Joseph
OK, so I started over using postrgresql and so far I have one app named 
'accounts' - to hold user models, registration, etc. I tried to migrate and 
got the following error which looks a lot like some of the errors I was 
getting before..


(business_management) C:\Python36\Projects\business_management>python 
manage.py migrate --settings=config.settings.local
Traceback (most recent call last):
  File "manage.py", line 22, in 
execute_from_command_line(sys.argv)
  File 
"C:\Users\Alexander\Envs\business_management\lib\site-packages\django\core\management\__init__.py",
 
line 363, in execute_from_command_line
utility.execute()
  File 
"C:\Users\Alexander\Envs\business_management\lib\site-packages\django\core\management\__init__.py",
 
line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"C:\Users\Alexander\Envs\business_management\lib\site-packages\django\core\management\base.py",
 
line 283, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"C:\Users\Alexander\Envs\business_management\lib\site-packages\django\core\management\base.py",
 
line 330, in execute
output = self.handle(*args, **options)
  File 
"C:\Users\Alexander\Envs\business_management\lib\site-packages\django\core\management\commands\migrate.py",
 
line 86, in handle
executor.loader.check_consistent_history(connection)
  File 
"C:\Users\Alexander\Envs\business_management\lib\site-packages\django\db\migrations\loader.py",
 
line 298, in check_consistent_history
connection.alias,
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration 
admin.0001_initial is applied before its dependency accounts.0001_initial 
on database 'default'.



let me know if you need anymore info to help me out with this. Thanks in 
advance


On Friday, August 25, 2017 at 12:25:00 PM UTC-6, Alexander Joseph wrote:
>
> Awesome, thanks James, thats exactly what I'm looking for. I'll try layout 
> 1 first as you suggest
>
>
>
> On Wednesday, August 23, 2017 at 7:49:05 PM UTC-6, James Schneider wrote:
>>
>>
>>
>> On Wed, Aug 23, 2017 at 4:40 PM, Alexander Joseph > > wrote:
>>
>>> One more question - is there a way to put apps in folders/sub-folders 
>>> instead of creating sub-apps/modules? I just want to keep things easier to 
>>> navigate on the development side. I will eventually have about 20 sub-apps 
>>> in the 'Engineering' app alone.
>>>
>>> Even if I could just group all the engineering sub-apps i have now under 
>>> an engineering folder without any further hierarchy that would help as 
>>> there will also be HR, financial apps, administration apps, etc.
>>>
>>> Thanks again
>>>
>>
>> Technically you can go as deep as you'd like. You can use the module 
>> strategy to emulate a Django 'app' without all the registration fuss. A 
>> couple abbreviated examples:
>>
>>
>> # 1. Group resources and references by object type
>> project/
>> engineering/
>> __init__.py
>> models/
>> __init__.py
>>  widgets.py
>>  gadgets.py
>>  product1.py
>>  product2.py
>> views/
>> __init__.py
>> product1.py
>> product2.py
>>  # etc.
>>
>> All of the models for engineering would be grouped in a single 'models' 
>> module. Imports would look like 'from engineering.models.widgets import 
>> WonderWidget'
>>
>> The engineering/models/__init__.py file would contain lines like 'from 
>> .widgets import *' for all of your files that contain models.
>>
>>
>> # 2. Group by business segment or workflow
>> project/
>> engineering/
>> __init__.py
>> models.py
>> product1/
>> __init__.py
>> models.py
>> views.py
>> urls.py
>> product2/
>> __init__.py
>> models.py
>> views.py
>> urls.py
>>  # etc.
>> 
>> In this case, you're replicating the structure of an 'app' without 
>> creating one by Django's definition. The engineering/models.py file would 
>> then contain imports like 'from .product1.models import *' in order to get 
>> the model auto-discovery to work correctly. 
>>
>> I'm under the impression that most developers use layout #1, but a large 
>> project might work better with #2 if there aren't a lot of 
>> cross-dependencies. 
>>
>> Note that using Python modules rather than real Django apps will also 
>> keep your settings.INSTALLED_APPS list minimized. With as many 'apps' as 
>> you were originally talking about, that list could be dozens or hundreds of 
>> items long.
>>
>> IMHO I would start with #1 and see how it works for you. It could be the 
>> generalized term 'product' that you're using, but to me, a product would 
>> not trigger a new 'app' for me, just extra model/view/url/etc. files, 
>> especially given how often products change or are added/removed. In that 
>> case, #2 might work better since all of the related code

Re: Best way to implement a more complex user registration/auth flow?

2017-08-27 Thread Alexander Joseph
Thanks Eduardo, I will try that!



On Saturday, August 26, 2017 at 2:05:22 PM UTC-6, Eduardo Balbinot wrote:
>
> You could do like this: when the user signs in you create the user in the 
> database and flags is_active as False, so the user won't be able to log in. 
> In your extended User model you could have another flag like 
> has_confirmed_email which you also set to False. When the user confirms the 
> email you set has_confirmed_email to True so you can have a page that shows 
> the admin which users are not active but have confirmed their email 
> addresses. Finally, the admin confirms a user which means in the background 
> you set is_active to True and then the user is able to log in to your 
> system.
>

-- 
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/b853fe36-b96a-4820-921c-28207fd9a4f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django deployement Apache

2017-08-27 Thread sarfaraz ahmed
Thanks for your help. Yes it was permission issue. However I am not able to 
find anything under my site-packages. when I point the same to 
dist-packages it works. 

WSGIPythonHome /usr/local/lib/python2.7/dist-packages
WSGIPythonPath /var/www/firsttest


ServerName firsttest.com
ServerAlias www.firsttest.com
ServerAdmin webmaster@localhost

WSGIScriptAlias / /var/www/firsttest/firsttest/wsgi.py

ErrorLog   /var/log/apache2/firsttest/first_error.log
CustomLog   /var/log/apache2/firsttest/first_access.log combined
Alias /static/admin/ 
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/
Alias /static/ /var/www/firsttest/static


Require all granted



-


This is my new conf file and it works. However I am still not able to see 
my static files in admin. Any help would be appreciated.


Regards
Sarfaraz

On Sunday, 27 August 2017 10:57:12 UTC+5:30, Vernon Swanepoel wrote:
>
> Hello Sarfaraz,
>
> A couple things you could look at:
>
>1. Are you including both your site-packages (eg 
>python3.6/lib/site-packages) and your django project root (where you 
>actually built the project) in your WSGIPythonPath?  String them together 
>with a clone 
>(/path/to/python3.6/lib/site-packages:/path/to/django/project/myproject)
>2. Your wsgi is within your django app 
>(/path/to/django/project/myproject/myproject/wsgi...).  It sits in the 
> same 
>file as your settings.py.  Make sure it's pointing to the right place, 
>because in your examples above your directory for django and your 
> directory 
>for the wsgi don't match.
>3. Have you set execute permissions all the way down the django app 
>(using chmod +x /all/the/way/up/the/django/project/to/wsgi.py)
>
> Deploying the first time is a frustrating process, and it's hard to get 
> specific help because nobody knows exactly what you've got running, but if 
> you stick with it, you'll get it working.
>
> Regards,
> Vernon
>
> On Saturday, 26 August 2017 21:31:34 UTC+1, sarfaraz ahmed wrote:
>>
>> Hey Team,
>>
>> Please someone help.
>> I am still getting error
>>
>> * ImportError: No module named django.core.wsgi*mentioned below is my 
>> latest vhost file in ubuntu. 
>>
>> 
>> WSGIScriptAlias / /var/www/firstweb/firstweb/wsgi.py
>> ServerName firstweb.com
>>
>> ServerAlias www.firstweb.com
>> 
>> 
>> Require all granted
>> 
>> 
>> CustomLog /var/log/apache2/firstweb-access.log combined
>> ErrorLog /var/log/apache2/firstweb-error.log
>> 
>>
>> Earlier I missed WSGIScriptAlias argument.
>>
>> Regards,
>> Sarfaraz Ahmed
>>
>>
>>
>> On Saturday, 26 August 2017 20:02:47 UTC+5:30, sarfaraz ahmed wrote:
>>>
>>> Hello Friends,
>>>
>>> Please help me with this. 
>>>
>>> I am new to linux and I am attempting to deploy my trial app on AWS 
>>> ubuntu server.
>>>
>>> my vhost file looks like this 
>>> 
>>> WSGIScriptAlias / /var/www/firstweb/firstweb/wsgi.py
>>>
>>> WSGIPythonPath /var/www/firstweb
>>> ServerName firstweb.com
>>>
>>> ServerAlias www.firstweb.com
>>> 
>>> 
>>> Require all granted
>>> 
>>> 
>>> 
>>>
>>> now when I add WSGIPythonPath.. my apache fails to restart. 
>>>
>>> If I remove that that I get following error when I try to access this 
>>> from my computer. 
>>> ImportError: No module named django.core.wsgi
>>>
>>> Now, I searched on the web and found following link
>>> https://www.webforefront.com/django/setupapachewebserverwsgi.html
>>>  
>>> which has some solution which I am not able to understand so far.
>>>
>>> after wasting my time in attempting to deploy on windows server. 
>>> everyone suggested me to deploy on linux.
>>>
>>> I M NOT USING virualenv. 
>>>
>>> Thanks in advance. 
>>>
>>> Regards,
>>> Sarfaraz Ahmed
>>>
>>>
>>>
>>>
>>>

-- 
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/17bd4194-0ad2-495d-9281-e23383c28fa2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Polls tutorial suggested mysite/mysite/urls.py improvement

2017-08-27 Thread Mike Dewhirst

On 27/08/2017 12:45 AM, Derek wrote:

Mike

Not sure what your github skill level is;


Long ago I once set up  a github repo but lost my certificate when my 
laptop died and there it ended. I manage a number of subversion 
repositories for a number of people and all my dev is based on svn so I 
don't really have the brainspace for git as well. Anyway, git is 
probably just a passing fad.


but have you considered making a clone of the docs 
(https://github.com/django/django/blob/master/docs/), changing that 
page 
(https://github.com/django/django/blob/master/docs/intro/tutorial01.txt) 
and then submitting your changes as a new pull request?


OK - best effort here. I used svn to adjust that file and create a patch 
in (I believe) git format. It really needs to be reviewed by a Django 
beginner as well as a guru ... see below.


Index: tutorial01.txt
===
diff --git a/doc/tutorial01.txt b/doc/tutorial01.txt
--- a/doc/tutorial01.txt    (revision 0)
+++ b/doc/tutorial01.txt    (working copy)
@@ -235,7 +235,7 @@
 tests.py
 views.py

-This directory structure will house the poll application.
+This directory structure will house the polls application.

 Write your first view
 =
@@ -255,7 +255,7 @@
 This is the simplest view possible in Django. To call the view, we 
need to map

 it to a URL - and for this we need a URLconf.

-To create a URLconf in the polls directory, create a file called 
``urls.py``.
+To create a URLconf in the polls directory, create a new file called 
``urls.py``.

 Your app directory should now look like::

 polls/
@@ -282,10 +282,31 @@
 url(r'^$', views.index, name='index'),
 ]

-The next step is to point the root URLconf at the ``polls.urls`` module. In
-``mysite/urls.py``, add an import for ``django.conf.urls.include`` and 
insert
-an :func:`~django.conf.urls.include` in the ``urlpatterns`` list, so 
you have:

+The next step is to point the project URLconf at the ``polls.urls`` module.

+.. admonition:: Project urls.py vs. app urls.py vs. views.py
+
+    Your project has a project urls.py file ``mysite/mysite/urls.py`` 
(Recall

+    that this was automatically created when you issued the command ``$``
+    django-admin startproject mysite). It contains URLconfs. When a browser
+    requests a URL, it needs to trigger some software to make something 
happen.

+    Such software is known in Django as a view.
+
+    You have just written your first view in views.py in the polls 
application

+    directory. It must be mapped to the outside world via a URLconf.
+
+    While it is possible we don't want to use the project urls.py file, 
already
+    mentioned, for all the individual polls app URLs. There might be 
many of
+    them. And eventually, the project (or package) may contain many 
apps. The

+    polls app really needs its own urls.py for its own URLconfs and we just
+    include them in the project urls.py with a single reference. The 
bonus is

+    you can easily re-use the polls app in other projects.
+
+
+In the existing ``mysite/mysite/urls.py``, add an import for
+``django.conf.urls.include`` and insert an 
:func:`~django.conf.urls.include` in

+the ``urlpatterns`` list, so you have:
+
 .. snippet::
 :filename: mysite/urls.py



Cheers

Mike








I may be speaking out of turn, as I am not a maintainer; but I am sure 
if you add the above explanation to your submission it will be 
favorably considered.


Derek

On Saturday, 26 August 2017 09:51:51 UTC+2, Mike Dewhirst wrote:

A potential new Django user (a programmer of many decades experience)
tried Django at my suggestion and struck a problem. Eventually he
tracked me down and challenged me to prove the problem.

I found the problem and feel that the Polls tutorial docs can be
easily
improved.

https://docs.djangoproject.com/en/1.11/intro/tutorial01/


In the "Write your first view" section it says ...

The next step is to point the root URLconf at the |polls.urls|
module.
In |mysite/urls.py|, add an import for |django.conf.urls.include| and
insert an |include()|
>

in the |urlpatterns| list, so you have:

mysite/urls.py

from  django.conf.urls  import  include,  url from django.contrib
import  admin

urlpatterns  =  [
  url(r'^polls/',  include('polls.urls')),
  url(r'^admin/',  admin.site.urls),
]


The problem is we have two mysite dirs. The docs are helpful in
suggesting you copy code to paste into urls.py so the focus is on the
code rather than where to put it. On not finding a urls.py in the
outer
mysite dir he created one.

The suggestion for improving the docs here