Web page -form-update - not working
Hi all; I have a problem when edit my form ... my page doesn't update models.py class Hard_number(models.Model): hard = ( ('SD1', 'SDD1'), ('SD2', 'SDD2'), ('SD3', 'SDD3'), ('SD4', 'SDD4'), ('SD5', 'SDD5'), ('SD6', 'SDD6'), ('SD7', 'SDD7'), ('SD8', 'SDD8'), ('SD9', 'SDD9'), ('SD10','SDD10'), ('SD11','SDD11'), ('SD12','SDD12'), ('SD13','SDD13'), ('SD14','SDD14'), ('SDD15','SDD15'), ) hard_n = models.CharField(max_length=20, choices=hard) lend_period = models.CharField(max_length=20) lend_by = models.CharField(max_length=20) due_back= models.DateField(null=True, blank=False) LOAN_STATUS = ( ('d', 'Maintaince'), ('o', 'On Loan'), ('a', 'Available') ) status = models.CharField(max_length=1, choices=LOAN_STATUS, blank= True, default='a') def __str__(self): return self.hard_n class Meta: ordering = ['due_back'] verbose_name = 'Hards' verbose_name_plural = 'HARDS' db_table = 'Hard_number' def get_absolute_url(self): return reverse('archive:show',args=[str(self.id)]) views.py def hard_form(request): if request.method == "POST": form = Hard_numberForm(request.POST) if form.is_valid(): try: form.save() return redirect('archive:show') except: pass else: form = Hard_numberForm() return render(request, 'hardindex.html', {'form': form}) # https://www.javatpoint.com/django-crud-application def show_hard(request): hard = Hard_number.objects.all() return render(request, "show.html", {"hard": hard}) def edit_hard(request, id ): hards_update = Hard_number.objects.get(id=id) return render(request, 'hard_edit.html',{'hards_update': hards_update}) def update_hard(request, id): hards_update = Hard_number.objects.get(id=id) form = Hard_numberForm(request.POST,instance=hards_update) if form.is_valid(): form.save() return redirect('archive:update') return render(request, 'hard_edit.html', {'hards_update': hards_update}) urls.py path('form_hard', views.hard_form, name='form_hard'), path('form_hard/show', views.show_hard, name='show'), #path('form_hard/show/edit/', views.edit_hard, name='edit'), path('form_hard/show/update/', views.update_hard, name='update'), hard_edit.html Edit {% load static %} {%csrf_token %} Update Details Hard number Lend period Lend by Due back status Update -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/df52651a-f8bd-4ef7-8733-1c4ab586c148%40googlegroups.com.
Test -Error :AssertionError: 404 != 200
Dear all I can't do the test -error is self.assertEqual(response.status_code, 200) AssertionError: 404 != 200 My code is views.py class DetailPageView(DetailView): model = Series template_name='/var/www/project/tapelss/movies/archive/templates/archive/detail.html' urls.py app_name = 'archive' urlpatterns =[ path('',views.indexing, name ='indexing'), path('post//', DetailPageView.as_view(), name='post_detail'), path('post',HomePageView.as_view(), name ='home'), path('page',views.page, name= 'page'), tests.py def test_post_detail_view(self): response = self.client.get('/post/264/') no_response = self.client.get('/post/100/') self.assertEqual(response.status_code, 200) self.assertEqual(no_response.status_code, 404) self.assertContains(response,'Nice body content') self.assertTemplateUsed(response, 'detail.html') -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/284f9aed-8da2-4697-936c-a86a380f00a5%40googlegroups.com.
Error in admin page- TemplateSyntaxError at /admin/login/
Dear all , I've error when accesses in admin page : 'admin_static' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls cache django_ajax_tags i18n import_export_tags l10n log static tags tz -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b6c50ff6-5a9c-4fd3-baff-7cf35a58f983%40googlegroups.com.
I can't use DurationField
I get error : ValueError: Enter a valid duration. When i'm importing excel file - i'm using postgresql my models.py An Series class - for describe series in the system """ id = models.CharField(max_length=20) program = models.CharField(max_length=100) tape = models.CharField(max_length=100) duration = models.DurationField() -- 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/effaae57-6378-45a4-82ab-a5e1c1425064%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
I can't import views
I'm trying to import view in my url in base project but i can't File "/var/www/project/venvs/lib64/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 978, in _gcd_import File "", line 961, in _find_and_load File "", line 950, in _find_and_load_unlocked File "", line 655, in _load_unlocked File "", line 678, in exec_module File "", line 205, in _call_with_frames_removed File "/var/www/project/tapelss/movies/movies/urls.py", line 4, in from .import views ImportError: cannot import name 'views' -- 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/48d69e8e-ce35-4863-8903-7c637eb3442c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
how can i fix ImportError: No module named 'archive.settings'
python manage.py runserver Traceback (most recent call last): File "manage.py", line 22, in execute_from_command_line(sys.argv) File "/var/www/project/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line utility.execute() File "/var/www/project/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 307, in execute settings.INSTALLED_APPS File "/var/www/project/venv/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__ self._setup(name) File "/var/www/project/venv/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup self._wrapped = Settings(settings_module) File "/var/www/project/venv/lib/python3.5/site-packages/django/conf/__init__.py", line 110, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/var/www/project/venv/lib64/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 986, in _gcd_import File "", line 969, in _find_and_load File "", line 956, in _find_and_load_unlocked ImportError: No module named 'archive.settings' *my setting:* import os import sys # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'd*d9q(5zn)6uv9ep$-qjsh3e&o^63=n64j%s&*w#*1voa3+e$x' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] IMPORT_EXPORT_USE_TRANSACTIONS = True # Application definition INSTALLED_APPS = [ 'archive', 'import_export', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'bootstrap3', -- 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/60c53c4a-3b34-4564-8bbf-b3e292ea16b1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.