Makemigration not working.. Please help me

2018-07-02 Thread Tamilvanan Anbalagan

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.


Unable to Save form to mysql - How to save form field values to mysql database and get the value from database

2018-07-02 Thread Tamilvanan Anbalagan
Hi Team,

I am very new to django framework, iI am trying to using simple forms to 
save into mysql database. also any samples pls send it to me, which will 
help to understand the connectivity.

*see my sample code:*


*views.py*

from django.http import HttpResponseRedirect
from django.views import View
from django.shortcuts import render

from .forms import NameForm

def get_name(request):
# if this is a POST request we need to process the form data
if request.method == 'POST':
# create a form instance and populate it with data from the request:
form = NameForm(request.POST)
# check whether it's valid:
if form.is_valid():
# process the data in form.cleaned_data as required
# ...
# redirect to a new URL:
return HttpResponseRedirect('/thanks/')

# if a GET (or any other method) we'll create a blank form
else:
form = NameForm()

return render(request, 'portal/index.html', {'form': form})


djangoproject/urls.py

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

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


*forms.py*

from django import forms

# class NameForm(forms.Form):
# your_name = forms.CharField(label='Your name', max_length=100)


*urls.py*

from django.conf.urls import url
from . import views

urlpatterns = [
url(r'^$', views.index, name='index')
]

*Error message:*



(py1) c:\TransportPortal\djangoproject>python manage.py runserver
Performing system checks...

Unhandled exception in thread started by .wrappe
 at 0x0355E4F8>
Traceback (most recent call last):
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\utils\autoreload.py"
 line 225, in wrapper
fn(*args, **kwargs)
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\core\management\comm
nds\runserver.py", line 120, in inner_run
self.check(display_num_errors=True)
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\core\management\base
py", line 364, in check
include_deployment_checks=include_deployment_checks,
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\core\management\base
py", line 351, in _run_checks
return checks.run_checks(**kwargs)
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\core\checks\registry
py", line 73, in run_checks
new_errors = check(app_configs=app_configs)
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\core\checks\urls.py"
 line 13, in check_url_config
return check_resolver(resolver)
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\core\checks\urls.py"
 line 23, in check_resolver
return check_method()
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\urls\resolvers.py",
ine 399, in check
for pattern in self.url_patterns:
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\utils\functional.py"
 line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\urls\resolvers.py",
ine 540, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\utils\functional.py"
 line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
  File 
"C:\Users\nb97441\Envs\py1\lib\site-packages\django\urls\resolvers.py",
ine 533, in urlconf_module
return import_module(self.urlconf_name)
  File "C:\Users\nb97441\Envs\py1\lib\importlib\__init__.py", line 126, in 
impo
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:\TransportPortal\djangoproject\djangoproject\urls.py", line 22, 
in 
path('portal/', include('portal.urls')),
  File "C:\Users\nb97441\Envs\py1\lib\site-packages\django\urls\conf.py", 
line
4, in include
urlconf_module = import_module(urlconf_module)
  File "C:\Users\nb97441\Envs\py1\lib\importlib\__init__.py", line 126, in 
impo
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:\TransportPortal\djangoproject\portal\urls.py", line 6, in 

url(r'^$', views.index, name='index')
AttributeError: module 'portal.views' has no attribute 'index'

(py1) c:\TransportPortal\djangoproject>

-- 
You 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...@googleg