django-urls

“Import Error: No module named urls” with Django 1.8 and Rest Framework 3.7

谁说我不能喝 提交于 2020-01-21 11:26:29
问题 I'm using django==1.8, rest_framework=3.7.7, python==2.7.12 urls.py urlpatterns += [ url(r'^api/core/', include('core.urls')), ] core/urls.py urlpatterns=[ url(r'^/users/', core_view.userlist), ] views.py class UserList(generics.ListAPIView): queryset = User.objects.all() serializer_class = UserSerializer userlist = UserList.as_view() When I'm navagating to: http://localhost:8000/api/core/users I'm getting the following error: ImportError at /api/core/users No module named urls Request Method

“Import Error: No module named urls” with Django 1.8 and Rest Framework 3.7

心已入冬 提交于 2020-01-21 11:26:26
问题 I'm using django==1.8, rest_framework=3.7.7, python==2.7.12 urls.py urlpatterns += [ url(r'^api/core/', include('core.urls')), ] core/urls.py urlpatterns=[ url(r'^/users/', core_view.userlist), ] views.py class UserList(generics.ListAPIView): queryset = User.objects.all() serializer_class = UserSerializer userlist = UserList.as_view() When I'm navagating to: http://localhost:8000/api/core/users I'm getting the following error: ImportError at /api/core/users No module named urls Request Method

TypeError at /confirmemail/amlqctnhel/confirmemail() takes exactly 2 arguments (1 given), why?

假如想象 提交于 2020-01-15 11:08:29
问题 Error: TypeError at /confirmemail/amlqctnhel/ confirmemail() takes exactly 2 arguments (1 given) Request Method: GET Request URL: http://127.0.0.1:8000/confirmemail/amlqctnhel/ Django Version: 1.3.1 Exception Type: TypeError Exception Value: confirmemail() takes exactly 2 arguments (1 given) Exception Location: /usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py in get_response, line 111 Python Executable: /usr/bin/python Python Version: 2.6.6 Python Path: ['/home/user1

Django 1.9 URLField removing the necessary http:// prefix

流过昼夜 提交于 2020-01-15 03:41:29
问题 I've seen a bunch of questions about this, but havent found an answer yet. This is my models: class UserProfile(models.Model): user = models.OneToOneField(User) . . . website = models.URLField(max_length=100, blank=True, null=True) and my forms.py: class UserProfileForm(forms.ModelForm): class Meta: model = UserProfile fields = ('website') def clean_website(self): website = self.cleaned_data['website'] if website and not website.startswith('http://'): website = 'http://' + website return

Django 2.2 breaks previously working views/urls

别等时光非礼了梦想. 提交于 2020-01-14 09:47:19
问题 Decided to take out Django 2.2 for a spin (project is currently running 2.1.8) and now I can't even get the server to start. I have been maintaining this project for nearly two years and this should be a minor update. The error seems to be related to my views, but I can't find anything in the release notes that has meaningfully changed between 2.1.8 and 2.2. I suspect it may be due to my rather non-standard view system. Instead of a single file called views.py , I use a folder of view files

Django view getting called twice (double GET request)

北慕城南 提交于 2020-01-13 05:56:52
问题 I'm creating a classifieds website in Django. A single view function handles global listings, city-wise listings, barter-only global listings and barter-only city-wise listings. This view is called ads . The url patterns are written in the following order (note that each has a unique name although it's tied to the same ads view): urlpatterns = patterns('', url(r'^buy_and_sell/$', ads,name='classified_listing'), url(r'^buy_and_sell/barter/$', ads,name='barter_classified_listing'), url(r'^buy

How do I redirect by URL pattern in Django?

半腔热情 提交于 2020-01-11 05:35:15
问题 I have a Django based website. I would like to redirect URLs with the pattern servertest in them to the same URL except servertest should be replaced by server-test . So for example the following URLs would be mapped be redirected as shown below: http://acme.com/servertest/ => http://acme.com/server-test/ http://acme.com/servertest/www.example.com => http://acme.com/server-test/www.example.com http://acme.com/servertest/www.example.com:8833 => http://acme.com/server-test/www.example.com:8833

django url parameters before include url with namespace

我的未来我决定 提交于 2020-01-10 05:37:05
问题 In my last question I asked how to get urls working for parameter before included urls.py and it worked. Django {% url %} when urls with parameters like: url(r'^foo/<parameter>/$', include(some.urls)) Now I want to use the same included urls.py with namespaces . urls.py urlpatterns = patterns('', url(r'^/foo/(?P<parameter_1>\d+)/', include('bar.urls', namespace='foo', app_name='foo')), ) bar.urls.py urlpatterns = patterns('', url(r'^/bar/$', 'bar.views.index', name='bar'), url(r'^/bar/(?P

Django - urls.py REGEX

倖福魔咒の 提交于 2020-01-07 05:41:05
问题 I am having some trouble writing the regex portion of the url for a Django project. I want to be able to route along with capturing a profile ID URL Example: www.somesite.com/profile/12345678901 This is what I have so far url(r'^profile/$', views.dashboard, name='widget') Whats the correct REGEX that should go after the profile/? How would I capture the numeric part after the profile/? once I am in the view? Thanks, 回答1: url(r'^profile/(?P<id>[\d]+)/$', profile_view, name="profile"), and in

Unable to link Blog Posts to Specific Category Django

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-06 20:16:50
问题 I used Tango with Django to create a database containing categories, and I used the Django Girls tutorial to add a blog to the database. Both are working fine, but I have been having trouble linking each blog post to its respective category. Right now, all posts go to my post_list.html page. If I were doing this from scratch, I would add a new view, add a new template, add a url mapping, and then add a link from the category page. I also am aware that I need to edit my blog post model to