[Solved] cannot import name patterns – django

patterns was removed in Django 1.10. Instead, use a regular list: from django.conf.urls import url from . import views urlpatterns = [ url(r’^articles/2003/$’, views.special_case_2003), url(r’^articles/([0-9]{4})/$’, views.year_archive), url(r’^articles/([0-9]{4})/([0-9]{2})/$’, views.month_archive), url(r’^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$’, views.article_detail), ] Refer to the docs for more info. 4 solved cannot import name patterns – django

[Solved] What is the best way to give a Linux command from one machine to a different machine? [closed]

Solution 1: use SSH pre-shared key to login via SSH without a password. See this link for how to do it. After you have configured it properly, you are able to run a command on your server: ssh hostname-or-ip-of-the-raspi command arg1 arg2 … and will execute command arg1 arg2 … on the Raspberry PI, without … Read more

[Solved] Python in django Template [closed]

As already mentionned, you cannot (at least not out of the box and not without huge pain) directly embed Python code in an Django template, and as far as I’m concerned that’s a GoodThing(tm) – the “server page” model (PHP, ASP1 etc) has long proven to be a failure wrt/ maintainability. Now for the good … Read more

[Solved] How does UserPassesTestMixin in django work?

The user id coming from the user in the request object is an integer, while the self.kwargs[‘pk’] is a string unless you do something about it. You’d see the difference if you printed repr() of the values because the string would have quotes around it because it’s extracted from the url path which itself is … Read more

[Solved] How can we use html for Django model form?

Yes, you can get a beautiful interface that way, just pass the name you use in the form.py Example: forms.py class NameForm(forms.ModelForm): class Meta: model = MyModel fields = [ “whatever” ] Html Template <form method=”POST”>{% csrf_token %} <input type=”text” name=”whatever” placeholder=”Write whatever”> </form> solved How can we use html for Django model form?

[Solved] Django websites not loading

The problem isn’t having multiple websites, using mod wsgi or even using Windows. The actual problem is the database. For some reason (no idea why) the default database becomes corrupt. The solution was for me to switch to MySQL from the default database. I’m not entirely sure why the default database becomes corrupt. This is … Read more

[Solved] Python run from subdirectory

I added empty __init__.py files to Main/, A/, B/, and C/. I also put the following function in each of the .py files just so we had something to call: def f(): print __name__ In main.py, the significant function is get_module, which calls import_module from importlib. import errno from importlib import import_module import os from … Read more

[Solved] I keep getting Error while trying to deploy my django app to heroku:[ remote rejected] master -> master (pre-receive hook declined)

I think you need: settings.py STATIC_ROOT = os.path.join(BASE_DIR, ‘staticfiles’) and then create a directory “staticfiles” in your project root directory. You have to put some file inside to upload it to git (you can’t upload empty dirs to git). 3 solved I keep getting Error while trying to deploy my django app to heroku:[ remote … Read more

[Solved] How to hide location of image in django?

Using image = forms.ImageField(widget=forms.FileInput,) in forms class ProfileUpdate(forms.ModelForm): image = forms.ImageField(widget=forms.FileInput,) class Meta: model = UserInfo fields = (‘image’, ‘fullname’, ‘mobile’, ‘occupation’, ‘address’, ‘city’, ‘state’, ‘pincode’) solved How to hide location of image in django?