django-registration-redux dont create the folder in my app - django

Im trying to install django-registration-redux to my app and it work but I can't see where is the folder 'registration'.
It's really extrange, it work, but I need change the templates but I cant see where they are. Somebody can explain me where is the folder?

If you are using virtualenv you can find it in
path_to_virtual_env/lib/pythonx.x/site-packages/registration
or in /usr/local/lib/pythonx.x/dist-packages/registration if you are don't using virtualenv

I had the same problem.
I solved this by cutting the folder from the lib/site-packages/registration and added the registration folder under my-project folder.
it will me something similar to this:
my-project
app
registration
Make sure that you have registration added in your INSTALLED_APPS
This suppose to work since you have your set urls.py

Related

How do I implement django-articles app into a new project via pip?

I'm trying to install the following django app from the cheeseshop:
https://bitbucket.org/codekoala/django-articles/overview
This is my first day of Django-ing and I'm unsure what to do to get the app's folder populated inside my project.
So far, I've pip installed the app into my virtualenv. This is verified by opening a python shell and getting no errors when I run "import articles"
I've edited the settings.py file and added it to the list of installed apps. I believe this to be OK as I can then run runserver without any "module not found" errors.
syncdb also ran fine.
Where do I go from here?
ie, I would like to have a section of the website called News which uses this app. I have no routes or other apps configured yet, just a clean Django with psycopg2.
EDIT: Enabling the default admin site, I can manage the Articles there, but still unsure of how these will be displayed on the site when I have no app folder created for them. When trying to startapp articles, I'm warned it's conflicting name with an existing module..
No need to create a new app called articles. As you are able to import articles via the python console you have successfully installed it. You can find it in your virtualenv folder in the folder site-packages:
/path_to_your_virtualenv/.virtualenvs/<virtualenvname>/lib/<pythonversion>/site-packages
You can use this app, installed via pip, as it is an app which lives in your project folder.
You just need to include the articles urls in your own urls.py. Since you say you want it under News, this would do fine:
urlpatterns = patterns('',
(r'^news/', include('articles.urls'),
)
Note though that the readme for the articles app implies that you'll need to create your own base template for it to inherit from. Just create a base.html file in a directory called templates under your project, give it a basic HTML structure, and put in {% block content %}{% endblock %} in the relevant place (and the same for the other blocks mentioned in the readme).
You should probably do the Django tutorial anyway, to understand exactly what's going on with the URL and the templates.

Django App not working: "Error: No module named app_name"

I'm new to Django, and I can't figure out why my app isn't loading. I've created all the files: models.py, views.py, urs.py with default code in. But when I run python manage.py runserver, it says the following:
Error: No module named app_name
What am I doing wrong?
Did you remember to include __init__.py in your folder?
If you did, make sure the permissions on the file are also correct. There's also a similar question here.
Just an additional hint: Instead of manually creating the files you can use django-admin.py startapp APPNAME to automatically create a directory with all necessary files for a new app.
I got your point the init file thing also dosen't work out for me as well. Just ensure that are you writing the proper command inside the proper directory while creating the app, using the terminal.
Like while writing the command "django-admin startapp APP_NAME", ensure that the command is written inside your root configuration directory (which gets created after you typein command "django-admin startproject PROJECT-NAME"), not anywhere else. Then mention the app name inside the settings.py file, under the INSTALLED_APPS[ ] list. Then finally run the command "python manage.py runserver" in the same root configuration directory. I assure you, this will work for sure and the "No modules found" thing will disappear. Have a try and tell me if it don't. Thank you.

Django: the role of the project name

I am thinking of stating a new Django project and I have to choose a project name now, so I can type:
djangoadmin startproject <something>
This raises doubts, I'm not sure of the name, and I think that I might want to change it in the future. So, I have two questions:
What role does project name play in the project code and deployment?
What steps do I need to take to change my project's name?
Thank you!
Main project name is used as a base for your namespace.
By default, you will have in settings.py line: "ROOT_URLCONF = 'something.urls'".
To change a project name, you need to change every single import that is referring to it.
Of course you can always use modules without 'something' prefix, then you must ensure that there will be no name/namespace conflict between modules. I'm using this option, because I can have same code in a few copies without additional hassle.
Late to this party, but for future reference this may help somebody. I've just had to change a project name because it clashed with the name of a third-part app. It's easier to change a project name than an app name! (Django 1.11)
Folder structure
project/
manage.py
project/
settings.py
urls.py
wsgi.py
venv/
If using a virtual environment in venv, generate an up to date requirements.txt with pip freeze
Rename both project/ folders to newproject
Change project to newproject in the python files:
manage.py, look for DJANGO_SETTINGS_MODULE
settings.py, look for DJANGO_SETTINGS_MODULE and WSGI_APPLICATION, and a comment. You can and should leave the name of the database and the database user unchanged, assuming you want to keep the data.
urls.py, in a triple-quoted string
wsgi.py, DJANGO_SETTINGS_MODULE plus a comment
If using a virtual environment, you need to recreate it. I renamed venv to old.venv, then virtualenv-3 venv, then use pip install and the requirements file you generated at 1. Trash old.venv when sure the new one is working AOK.
/path/to/project will also feature in system config files such as /etc/nginx and a .service file for gunicorn, which will need changing to /path/to/newproject.
Restart the server and test. Should be working.
Now you can add an app called project to your INSTALLED_APPS!
I now know that it's a good idea to call in-house Django projects ${my_org_name}_something, or similar, so they won't clash with third-party apps.

Django syncdb can't find my apps

I'm a django newbie and have been having a problem.
In my project root I created a folder called 'local_apps' and within it I put the app 'myapp'. I updated the INSTALLED_APPS within settings.py with: myproject.local_apps.myapp
However when I try to syncbd, Django gives an error: 'no module named local_apps.myapp exists'
When I put 'myapp' back in the project root, it works again but I dont want it that way. I want to keep my apps in the folder 'local_apps'.
Can you tell me what I am doing wrong here.
Thanks in advance.
I think that's a generic python error, not a Django error.
Maybe you need to create an __init__.py file in the local_apps directory, so python knows it's a module.
Do you have a models.py within the myapp folder? I think Django may need to see that file in the app.
[Edit: actually, I think wisty above may be right, make sure you have an __init__.py, if you do, try the models.py.]
I was facing the error: ImportError: No module named foo
To solve this, I just added the Django site package to the Python path at settings.py module like this:
PKG_DIR = os.path.dirname(__file__)
sys.path.append(PKG_DIR)

Appropriate placement for my testcases belonging to a non-app in Django

I have built my website in Django. And like any other django project I have got apps inside the project root directory and some special folders like(extensions a.k.a custom django command extensions). With an app, we dont have any problem with having testcases. "tests.py" inside the app directory will be the solution. But for a special folder(which is not an app or which doesn't have a models.py) where do I place the testcases. I tried placing the tests.py inside the extensions directory and it said the directory is not a model and unable to run the tests. HOw do I solve this? How can I have a proper placement of testcases related to non-apps?
I think it will work to put them in a tests/ directory at the project level.
If, for some reason, it doesn't then try creating an empty models.py in your extensions directory.